Documentation
¶
Overview ¶
Package cache provides a generic concurrency-safe in-memory cache store.
The primary type is Store, a generic map-based cache that satisfies the cache interfaces used by higher-level packages:
- *jwks.CacheEntry satisfies jwks.CacheStore for JWKS key caching
- *metadata.CacheEntry satisfies metadata.CacheStore for discovery caching
The default in-memory caches in the metadata and jwks packages are both backed by cache.Store. Most callers do not need to interact with this package directly; it is exported for callers who want to share a single cache instance across multiple metadata.Client or *jwks.RemoteKeySet instances, or who need to implement custom cache eviction.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store[V any] struct { // contains filtered or unexported fields }
Store is a generic in-memory cache. Store is safe for concurrent use.
func NewStore ¶
NewStore creates a new in-memory cache store.
Example ¶
package main
import (
"fmt"
"github.com/Kunde21/lanyard/cache"
)
func main() {
store := cache.NewStore[string]()
store.Set("key", "value")
v, ok := store.Get("key")
fmt.Println(ok)
fmt.Println(v)
}
Output: true value