Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( DefaultWindowRatio = 0.1 DefaultSLRUSplit = 0.2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Evicted ¶
type Evicted[K comparable, V any] struct { Key K Value V }
Evicted holds key/value pair that was evicted from cache.
type Tannin ¶
type Tannin[K comparable, V any] struct { // contains filtered or unexported fields }
Tannin is a thread-safe fixed size cache with windowed TinyLFU eviction policy.
Example ¶
package main import ( "fmt" tannin "github.com/floatdrop/tannin" ) func main() { cache := tannin.New[string, int](256, 100) cache.Set("Hello", 5) if e := cache.Get("Hello"); e != nil { fmt.Println(*e) } }
Output: 5
func (*Tannin[K, V]) Peek ¶
func (T *Tannin[K, V]) Peek(key K) *V
Peek returns value for key (if key was in cache), but does not modify its recency.
Click to show internal directories.
Click to hide internal directories.