Documentation ¶
Index ¶
- Constants
- type Cache
- type EvictType
- type LRUCache
- func (c *LRUCache) Contain(key interface{}) bool
- func (c *LRUCache) Del(key interface{}) bool
- func (c *LRUCache) Get(key interface{}) (interface{}, bool)
- func (c *LRUCache) GetOrLoad(key interface{}, loader LoaderFunc) (interface{}, error)
- func (c *LRUCache) Keys(withoutExpired ...bool) []interface{}
- func (c *LRUCache) Len(withoutExpired ...bool) int
- func (c *LRUCache) Peek(key interface{}) (interface{}, bool)
- func (c *LRUCache) Purge()
- func (c *LRUCache) Set(key, value interface{}, expire time.Duration)
- type LoaderFunc
- type Option
Constants ¶
View Source
const (
DefaultSize = 100
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Set key-value pair with an expiration. Set(key, value interface{}, expire time.Duration) // Get value from the cache by the key. Get(key interface{}) (interface{}, bool) // Get value from the cache or load by loader. GetOrLoad(key interface{}, loader LoaderFunc) (interface{}, error) // Return value without updating the "recently used"-ness of the key. Peek(key interface{}) (interface{}, bool) // Delete the specified key from the cache. Del(key interface{}) bool // Check if a key exists in the cache. Contain(key interface{}) bool // Return the number of items in the cache. Len(withoutExpired ...bool) int // Return a slice of the keys in the cache. Keys(withoutExpired ...bool) []interface{} // Clear the cache entities. Purge() }
Cache is the interface for LRU/ARC cache.
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
func (*LRUCache) GetOrLoad ¶
func (c *LRUCache) GetOrLoad(key interface{}, loader LoaderFunc) (interface{}, error)
type LoaderFunc ¶
Click to show internal directories.
Click to hide internal directories.