Documentation ¶
Index ¶
- Constants
- func ShellProcessor() command.Processor
- func StubShellCache(t *testing.T, c *Cache)
- type Cache
- func (c *Cache) Changed() bool
- func (c *Cache) Delete(key string) error
- func (c *Cache) Get(key string) (string, bool, error)
- func (c *Cache) GetBytes(key string) ([]byte, bool, error)
- func (c *Cache) GetStruct(key string, obj interface{}) (bool, error)
- func (c *Cache) List() ([]string, error)
- func (c *Cache) Name() string
- func (c *Cache) Node() command.Node
- func (c *Cache) Put(key, data string) error
- func (c *Cache) PutStruct(key string, i interface{}) error
- func (c *Cache) Setup() []string
Constants ¶
const ( // ShellOSEnvVar is an environment variable pointing to the // directory used for the shell-level cache. ShellOSEnvVar = "COMMAND_CLI_CACHE_SHELL_DIR" // ShellDataKey is the data key used to store the shell-level cache. // Callers should use the `ShellProcessor` and `ShellFromData` functions // rather than using this key. ShellDataKey = "COMMAND_CLI_CACHE_SHELL" )
Variables ¶
This section is empty.
Functions ¶
func ShellProcessor ¶
ShellProcessor returns a processor that creates a shell-level `Cache`. This needs to be done at the processor level so we can update an environment variable via `ExecuteData`.
func StubShellCache ¶
StubShellCache stubs the cache created and set by `ShellProcessor`.
Types ¶
type Cache ¶
type Cache struct { // Dir is the location for storing the cache data. Dir string // contains filtered or unexported fields }
Cache is a type for caching data in JSON files. It implements the `sourcerer.CLI` interface.
func FromEnvVar ¶
FromEnvVar creates a new cache pointing to the directory specified by the provided environment variable.
func FromEnvVarOrDir ¶
FromEnvVar creates a new cache pointing to the directory specified by the provided environment variable.
func ShellFromData ¶
ShellFromData retrieves the shell-level `Cache` that was set by `ShellProcessor`.
func (*Cache) Changed ¶
Changed returns whether or not the `Cache` object (not cache data) has changed.
func (*Cache) Get ¶
Get retrieves data from the cache and returns the data (as a string), whether the file exists, and any error encountered.
func (*Cache) GetStruct ¶
GetStruct retrieves data from the cache and stores it in the provided object. This function returns whether the cache exists and any error encountered.