Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Get returns the cache value associated with key // // Parameters: // * `key` - the key to retrieve // // Returns the value associated with key and a bool that is `false` // if the key was not found Get(key interface{}) (interface{}, bool) // Put puts a value in cache associated with key // // Parameters: // * `key` - the key to put // * `value` - the value to put Put(key interface{}, value interface{}) // Delete deletes the cache entry associated with key // // Parameters: // * `key` - the key to delete Delete(key interface{}) // ToMap returns the current cache entries copied into a map ToMap() map[interface{}]interface{} }
Cache represents a key-value storage where to put cached data
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRUCache is a Least Recently Used (LRU) Cache with given capacity
func NewLRUCache ¶
NewLRUCache creates a new Least Recently Used (LRU) Cache
Parameters:
- `capacity` - a positive integer indicating the max capacity of this cache
Returns the new allocated LRU Cache and an error
func (*LRUCache) Delete ¶
func (c *LRUCache) Delete(key interface{})
Delete deletes the cache entry associated with key
Parameters:
- `key` - the key to delete
func (*LRUCache) Get ¶
Get returns the cache value associated with key
Parameters:
- `key` - the key to retrieve
Returns the value associated with key and a bool that is `false` if the key was not found
type MapCache ¶
type MapCache struct {
// contains filtered or unexported fields
}
MapCache is a cache backed by a map
func (*MapCache) Delete ¶
func (c *MapCache) Delete(key interface{})
Delete deletes the cache entry associated with key
Parameters:
- `key` - the key to delete
func (*MapCache) Get ¶
Get returns the cache value associated with key
Parameters:
- `key` - the key to retrieve
Returns the value associated with key and a bool that is `false` if the key was not found