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) // GetOrLoad gets value from the cache or load by loader. GetOrLoad(key interface{}, loader LoaderFunc) (interface{}, error) // Peek returns value without updating the "recently used"-ness of the key. Peek(key interface{}) (interface{}, bool) // Del the specified key from the cache. Del(key interface{}) bool // Contain checks if a key exists in the cache. Contain(key interface{}) bool // Len returns the number of items in the cache. Len(withoutExpired ...bool) int // Keys returns a slice of the keys in the cache. Keys(withoutExpired ...bool) []interface{} // Purge clears 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)
GetOrLoad gets value from the cache or load by loader.
type LoaderFunc ¶
Click to show internal directories.
Click to hide internal directories.