package cache
import "git.sr.ht/~xn/cache/v2"
Index ¶
Types ¶
type Cache ¶
type Cache[V any] interface { // Get an item from cache Get(key string) V // Set an item to cache Set(key string, value V) // Has an item in cache Has(key string) bool // Remove an item from cache Remove(key string) // Purge all items from cache Purge() }
Cache interface, used by any cache implementation
func NewKV ¶
NewKV creates a Key Value store
func NewLFU ¶
NewLFU creates new Least Frequently Used cache
func NewLRU ¶
NewLRU creates new Least Recently Used cache
func NewNull ¶
NewNull creates an empty cache client, usable for testing
func NewTLRU ¶
NewTLRU cerates new Time aware Least Recently Used cache Arguments: size - max amount if items in cache ttl - cached item expiration duration stale - if true, stale cached item will be returned instead of nil, but only once
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
kv | |
lfu | |
lru | |
null | |
tlru | |
utils |
- Version
- v2.1.0 (latest)
- Published
- Aug 29, 2022
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 11 hours ago –
Tools for package owners.