Documentation ¶
Overview ¶
Package caches provides LRU cache and Redis cache
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LCache ¶
type LCache struct { // MaxEntries is the maximum number of cache entries before // an item is evicted. Zero means no limit. MaxEntries int // contains filtered or unexported fields }
Cache is an LRU cache. It is not safe for concurrent access. But it is not necessary for project samaritan.
var LRUCache *LCache
func NewLRUCache ¶
New creates a new Cache. If maxEntries is zero, the cache has no limit and it's assumed that eviction is done by the caller.
func (*LCache) GetOrRedis ¶
Get looks up a key's value from the cache. If failed, load from redis.
func (*LCache) RemoveOldest ¶
func (c *LCache) RemoveOldest()
RemoveOldest removes the oldest item from the cache.
type SimpleCache ¶
type SimpleCache struct {
// contains filtered or unexported fields
}
func (*SimpleCache) Delete ¶
func (c *SimpleCache) Delete(key string)
Delete deletes a key immediately
func (*SimpleCache) Get ¶
func (c *SimpleCache) Get(key string) (value string)
Get looks up a key's value from the cache.
func (*SimpleCache) GetSet ¶
func (c *SimpleCache) GetSet(key, newValue string) (value string)
GetSet looks up a key's value from the cache and set a new value.
Click to show internal directories.
Click to hide internal directories.