Skip to content

Repository files navigation

evcache

Go ReferenceGo Report Card

Package evcache implements a concurrent key-value cache with capacity overflow eviction, item expiry and deduplication.

Example

package main
import (
"time""github.com/mgnsk/evcache/v4"
)
funcmain() {
c:=evcache.New[string, string](
evcache.WithCapacity(128),
evcache.WithPolicy(evcache.LRU),
evcache.WithTTL(time.Minute),
)
// Fetches an existing value or calls the callback to get a new value.result, err:=c.Fetch("key", func() (string, error) {
// Possibly a very long network call. It only blocks write access to this key.// Read access for this key returns as if the value does not exist.return"value", nil
})
iferr!=nil {
panic(err)
}
// Use the result.println(result)
}

About

Package evcache implements a concurrent key-value cache with capacity overflow eviction, item expiry and deduplication.

Topics

Resources

Stars

5 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages