Documentation
¶
Overview ¶
Package cache implements interfaces for caches.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCacheMiss is returned if a Get failed because the item wasn't present. ErrCacheMiss = errors.New("cache: miss") // ErrNotStored is returned if conditional write (Add or Replace) failed because // the condition was not met. ErrNotStored = errors.New("cache: not stored") // Null is the null Cache instance. Null = &nullCache{} )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Get gets the item for the given key.
Get(k string) Item
// GetMulti gets the items for the given keys.
GetMulti(ks ...string) ([]Item, error)
// Set sets the item in the cache.
Set(k string, v interface{}, expire time.Duration) error
// Add sets the item in the cache, but only if the key does not already exist.
Add(k string, v interface{}, expire time.Duration) error
// Replace sets the item in the cache, but only if the key already exists.
Replace(k string, v interface{}, expire time.Duration) error
// Delete deletes the item with the given key.
Delete(k string) error
// Inc increments a key by the Value.
Inc(k string, v uint64) (int64, error)
// Dec decrements a key by the Value.
Dec(k string, v uint64) (int64, error)
}
Cache represents a cache instance.
type Decoder ¶
type Decoder interface {
Bool(interface{}) (bool, error)
Bytes(interface{}) ([]byte, error)
Int64(interface{}) (int64, error)
Uint64(interface{}) (uint64, error)
Float64(interface{}) (float64, error)
String(interface{}) (string, error)
}
Decoder represents a value decoder.
type Item ¶
type Item struct {
Value interface{}
Err error
// contains filtered or unexported fields
}
Item represents an item to be returned or stored in the cache.
Click to show internal directories.
Click to hide internal directories.