Documentation
¶
Index ¶
- Constants
- func ToInt64(b []byte) (int64, bool)
- type Cache
- func (c *Cache) Del(key string)
- func (c *Cache) Get(key string) (any, bool)
- func (c *Cache) GetBytes(key string) ([]byte, bool)
- func (c *Cache) GetInt64(key string) (int64, bool)
- func (c *Cache) Inspect(ipr inspector)
- func (c *Cache) LRU2(capPerBkt uint16) *Cache
- func (c *Cache) Len() int
- func (c *Cache) Put(key string, val any)
- func (c *Cache) PutBytes(key string, b []byte)
- func (c *Cache) PutEx(key string, val any, ex time.Duration)
- func (c *Cache) PutExAt(key string, val any, ea int64)
- func (c *Cache) PutInt64(key string, d int64)
- func (c *Cache) Walk(walker func(key string, ifc any, bytes []byte, expireAt int64) bool)
Constants ¶
View Source
const ( PUT = iota + 1 GET DEL EVICT )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache - concurrent cache structure
func NewLRUCache ¶
NewLRUCache - create lru cache `bucketCnt` is buckets that shard items to reduce lock racing `capPerBkt` is length of each bucket, can store `capPerBkt * bucketCnt` count of items in Cache at most optional `expiration` is item alive time (and we only use lazy eviction here), default `0` stands for permanent
func (*Cache) LRU2 ¶
LRU2 - add LRU-2 support (especially LRU-2 that when item visited twice it moves to upper-level-cache) `capPerBkt` is length of each LRU-2 bucket, can store extra `capPerBkt * bucketCnt` count of items in Cache at most
Click to show internal directories.
Click to hide internal directories.