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 item with the given key, otherwise returns false.
Get(ctx context.Context, key string) (Item, bool)
// Set sets the item at the given key.
Set(ctx context.Context, key string, i Item)
// Deletes the item at the given key.
Del(ctx context.Context, key string)
// The number of items in the cache.
Len() int
// The size in bytes.
Size() int
}
Cache is the interface that describes a cache.
type Expire ¶
type Item ¶
type Item interface {
// The size that the item occupies in a cache.
Size() int
}
Item is the interface that describes a cacheable item.
type LRU ¶
type LRU struct {
// The maximum cache size in bytes. Default is 16MB.
MaxSize int
// The duration while an item is cached.
ItemTTL time.Duration
// The function called when an item is evicted.
OnEvict func(key string, i Item)
// contains filtered or unexported fields
}
LRU represents an LRU (Least Recently Used) cache implementation.
Click to show internal directories.
Click to hide internal directories.