Documentation
¶
Overview ¶
Package cache defines common interfaces and error types which are implemented by drivers
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCacheMiss is returned when the key isn't in the cache ErrCacheMiss = errors.New("cache miss") // ErrInvalidDstVal is returned with the dstVal of the Get() func cannot be set. It's probably because the // dstVal is not a pointer. ErrInvalidDstVal = errors.New("cannot set dst value") // ErrInvalidDataFormat is returned when the data retrieved from a storage engine is not in the expected format ErrInvalidDataFormat = errors.New("Invalid data format") // ErrKeyExists indicates that the item you are trying to store with // a "cas" command has been modified since you last fetched it. ErrKeyExists = errors.New("key already exists") // ErrNotStored indicate the data was not stored, but not // because of an error. This normally means that the // condition for an "add" or a "replace" command wasn't met. ErrNotStored = errors.New("not stored") // ErrNotFound indicates that the item you are trying to store // with a "cas" command did not exist. ErrNotFound = errors.New("not found") // ErrUnsupportedAction indicates that the selected driver doesn't support the given action ErrUnsupportedAction = errors.New("not supported") // ErrCannotSetValue is returned when an previously set cache value pointer cannot be set. ErrCannotSetValue = errors.New("cannot set value of interface") // ErrCannotAssignValue is returned when a previously set cache value pointer cannot be // updated because the new value's type cannot be assigned to the previous value's type. ErrCannotAssignValue = errors.New("cannot assign value") // ErrCASConflict means that a CompareAndSwap call failed due to the // cached value being modified between the Get and the CompareAndSwap. // If the cached value was simply evicted rather than replaced, // ErrNotStored will be returned instead. ErrCASConflict = errors.New("compare-and-swap conflict") // NeverExpires is the duration which should be set for a key to never expire because of duration NeverExpires = time.Duration(0) )
Functions ¶
Types ¶
type Add ¶
Add defines an interface which adds the key/value to the cache but only if the key doesn't already exist in the cache. If it does exist, it must return an ErrNotStored error
type Append ¶
Append defines an interface which appends the value to the current value for the key. If the key doesn't already exist, it must return a ErrCacheMiss error
type Cache ¶
type Cache interface {
Set(key string, value interface{}, expiration time.Duration) error
Get(key string, dstVal interface{}) error
Exists(key string) bool
Del(key string) error
}
Cache defines a cache with key expiration. Implementations of this interface are expected to be thread safe.
type Cachestore ¶
Cachestore defines a cache interface which supports exporting all it's keys and also transferring all it's data to another Cache.
type Flush ¶
type Flush interface {
Flush() error
}
Flush defines an interface which store can clear all it's key/value pairs at once.
type KeyList ¶
type KeyList interface {
Keys() []string
}
KeyList defines an interface for announcing all keys currently set
type KeyProvider ¶
type KeyProvider interface {
Key() string
}
KeyProvider is an interface which can describe it's own key. It's used for getting/setting key/value pairs without a directly supplied key string. Instead, the supplied interface can announce it's own key, and that's used in getting/setting.
type Prepend ¶
Prepend defines an interface which prepends the value to the current value for the key. If the key doesn't already exist, it must return a ErrCacheMiss error
type Replace ¶
Replace defines an interface which replaces the value to the current value for the key. If the key doesn't already exist, it must return a ErrNotStored error