Documentation
¶
Overview ¶
Package testocache provides caching primitives to be used by external plugins.
By default, it stores cache in a directory "$TWD/.testo_cache", where "$TWD" refers to the "test working directory" (not necessary a project root). Usually, this is a directory where "_test.go" file, which calls this package, is located.
Can be overridden passing "-cache.dir ~/My/Dir" flag to the "go test" command OR (with lesser priority) with environment variable "TESTO_CACHE_DIR".
Caching can also be disabled with flag "-cache.disable" or environtment variable "TESTO_CACHE_DISABLE" (e.g. "=true").
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDisabled indicates that caching is disabled. ErrDisabled = errors.New("testocache: cache is disabled") // ErrInvalidKey indicates that passed key is invalid. // Currently, key is invalid if it contains a NUL-byte. ErrInvalidKey = errors.New("testocache: invalid key") // ErrNotFound indicates that value was not found the passed key. ErrNotFound = errors.New("testocache: not found") )
Functions ¶
func Disabled ¶
func Disabled() bool
Disabled returns true if caching is disabled. It's up to the package user to handle disabled state, e.g. do not save objects in cache when this function returns true.
func Get ¶
Get cached object by the given key. Key must not contain a NUL-byte.
If cache is disabled (see Disabled), this function returns ErrDisabled.
func Keys ¶
Keys returns all glob-matched keys by the given pattern.
The pattern syntax is:
pattern:
{ term }
term:
'*' matches any sequence of non-/ characters
'?' matches any single non-/ character
'[' [ '^' ] { character-range } ']'
character class (must be non-empty)
c matches character c (c != '*', '?', '\\', '[')
'\\' c matches character c
character-range:
c matches character c (c != '\\', '-', ']')
'\\' c matches character c
lo '-' hi matches character c for lo <= c <= hi
Keys requires pattern to match all of name, not just a substring.
If cache is disabled (see Disabled), this function returns ErrDisabled.
func Remove ¶
Remove object from cache by the given key. Key must not contain a NUL-byte.
If cache is disabled (see Disabled), this function returns ErrDisabled.
Types ¶
This section is empty.