Documentation ¶
Overview ¶
Package cache is an abstraction for cache clients.
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(ctx context.Context, k string) Item // GetMulti gets the items for the given keys. GetMulti(ctx context.Context, ks ...string) ([]Item, error) // Set sets the item in the cache. Set(ctx context.Context, 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(ctx context.Context, k string, v interface{}, expire time.Duration) error // Replace sets the item in the cache, but only if the key already exists. Replace(ctx context.Context, k string, v interface{}, expire time.Duration) error // Delete deletes the item with the given key. Delete(ctx context.Context, k string) error // Inc increments a key by the Value. Inc(ctx context.Context, k string, v uint64) (int64, error) // Dec decrements a key by the Value. Dec(ctx context.Context, 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.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
decoder
Package decoder implements cache decoders.
|
Package decoder implements cache decoders. |
Package memcache implements a memcache adapter for github.com/hamba/pkg/cache.
|
Package memcache implements a memcache adapter for github.com/hamba/pkg/cache. |
Package redis implements a redis adapter for github.com/hamba/pkg/cache.
|
Package redis implements a redis adapter for github.com/hamba/pkg/cache. |
Click to show internal directories.
Click to hide internal directories.