Documentation
¶
Overview ¶
Package cache provides a simple LRU cache implementation
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Set data
// Return FALSE if data was added; TRUE if data was replaced
Set(key, val []byte) bool
// Get data
// Return nil if item with this key doesn't exist
Get(key []byte) []byte
// Delete data
Del(key []byte)
// Clear all data and statistics
Clear()
// Get statistics data
Stats() Stats
}
Cache - interface
type Config ¶
type Config struct {
// Max. cache size (in bytes) of keys and values. Default: unlimited
MaxSize uint
// Max. element size (in bytes). Default: =MaxSize
MaxElementSize uint
// Max. elements number. Default: unlimited
MaxCount uint
// When cache is full, the least recently used element is deleted automatically
EnableLRU bool
// User callback function which is called after an element has been deleted automatically
OnDelete onDeleteType
}
Config - configuration
Click to show internal directories.
Click to hide internal directories.