Documentation ¶
Overview ¶
Package gocache implements a set of drivers and a common interface for working with different cache systems
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) AddNode(name string, node cache.Cache) error
- func (c *Client) Del(key string) (err error)
- func (c *Client) Exists(key string) (exists bool)
- func (c *Client) Get(key string, dstVal interface{}) (err error)
- func (c *Client) GetTimeout(dur time.Duration)
- func (c *Client) RemoveNode(name string) error
- func (c *Client) ReplaceNode(name string, node cache.Cache) error
- func (c *Client) ReplicateToN(numNodes int) error
- func (c *Client) Set(key string, value interface{}, exp time.Duration) (err error)
- func (c *Client) SetNode(name string, node cache.Cache) error
- func (c *Client) SetReplicateMethod(m ReplicationMethod)
- func (c *Client) SetRetrievalMethod(m RetrievalMethod)
- func (c *Client) SetTimeout(dur time.Duration)
- type ReplicationMethod
- type RetrievalMethod
Constants ¶
const ( // ReplicateAsync indicates that replication will be done asyncronously. // Set commands will return without error as soon as at least one node has // the value ReplicateAsync ReplicationMethod = iota // ReplicateSync indicates that replication will be done syncronously. // Set commands will return without error only if all nodes return without error ReplicateSync = iota // RetrieveSync indicates that get commands(get, exists) will be send to one // node at a time starting with the closest node, and the first result will be used RetrieveSync RetrievalMethod = iota // RetrieveAsync indicates that get commands(get, exists) will be send in parallel // to the given nodes, and the first result will be used RetrieveAsync = iota )
Variables ¶
var ( // ErrGetTimeout indicates a retrieval command timed out ErrGetTimeout = errors.New("get timeout") // ErrSetTimeout indicates a storage command timed out ErrSetTimeout = errors.New("set timeout") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a cache client with built in replication to any number of different caches. This allows replication and syncronization across various caches using the set of drivers available as subpackages, including Memcached, Redis, in-memory caches, and more.
func (*Client) AddNode ¶
AddNode adds a cache node with the given name, but only if it doesn't already exist
func (*Client) Del ¶
Del implements the "cache.Cache".Del() interface. It deletes the given key across all replicated nodes and returns error if any of those delete operations fail.
func (*Client) Get ¶
Get implements the "cache.Cache".Get() interface. It checks nodes in order of priority, and returns success if the value exists on any of them.
func (*Client) GetTimeout ¶
GetTimeout updates the get command timeout duration
func (*Client) RemoveNode ¶
RemoveNode removes a node with the given name from the node list
func (*Client) ReplaceNode ¶
ReplaceNode adds a cache node with the given name, but only if it already exists
func (*Client) ReplicateToN ¶
ReplicateToN sets how many nodes each key should be replicated to
func (*Client) SetNode ¶
SetNode sets the cache node with the given name, regardless of whether it already exists or not
func (*Client) SetReplicateMethod ¶
func (c *Client) SetReplicateMethod(m ReplicationMethod)
SetReplicateMethod sets the replication method
func (*Client) SetRetrievalMethod ¶
func (c *Client) SetRetrievalMethod(m RetrievalMethod)
SetRetrievalMethod sets the retrieval method
func (*Client) SetTimeout ¶
SetTimeout updates the set command timeout duration
type ReplicationMethod ¶
type ReplicationMethod int
ReplicationMethod determines whether replication takes place asyncronously or syncronously. Use ReplicateAsync for asyncronous replication, ReplicateSync for syncronous replication.
type RetrievalMethod ¶
type RetrievalMethod int
RetrievalMethod determines whether get commands (get, exists) are sent to all nodes simultaneously or are sent one-by-one.
Directories ¶
Path | Synopsis |
---|---|
Package cache defines common interfaces and error types which are implemented by drivers
|
Package cache defines common interfaces and error types which are implemented by drivers |
Package codec implements codecs for marshaling/unmarshaling of native Go types into byte slices
|
Package codec implements codecs for marshaling/unmarshaling of native Go types into byte slices |
drivers
|
|
appengine/memcache
Package memecache implements a cache driver for Google App Engine Go mememcache
|
Package memecache implements a cache driver for Google App Engine Go mememcache |
bigcache
Package bigcache implements a BigCache driver for github.com/allegro/bigcache
|
Package bigcache implements a BigCache driver for github.com/allegro/bigcache |
freecache
Package freecache implements a FreeCache driver for github.com/coocood/freecache
|
Package freecache implements a FreeCache driver for github.com/coocood/freecache |
gocache
Package gocache is a wrapper for Patrick Mylund Nielsen's go-cache package fouund at github.com/patricknm/go-cache
|
Package gocache is a wrapper for Patrick Mylund Nielsen's go-cache package fouund at github.com/patricknm/go-cache |
kv
Package kv is a wrapper for permanent key/value drivers at github.com/bradberger/gokv This allows using permanent key/value datastores like BoltDB, DiskV, LevelDB, etc., for persistent caching.
|
Package kv is a wrapper for permanent key/value drivers at github.com/bradberger/gokv This allows using permanent key/value datastores like BoltDB, DiskV, LevelDB, etc., for persistent caching. |
lru
Package lru implements a least recently used in-memory cache.
|
Package lru implements a least recently used in-memory cache. |
memcache
Package memcache implements a memcache driver for github.com/bradfitz/gomemcache/memcache
|
Package memcache implements a memcache driver for github.com/bradfitz/gomemcache/memcache |
memory
Package memory implements a very basic, fully functional cache.Cache interface with in-memory caching and key expiration.
|
Package memory implements a very basic, fully functional cache.Cache interface with in-memory caching and key expiration. |
radix
Package radix implements a driver for github.com/armon/go-radix
|
Package radix implements a driver for github.com/armon/go-radix |
redis
Package redis implements a driver for github.com/garyburd/redigo/redis
|
Package redis implements a driver for github.com/garyburd/redigo/redis |