cache

package
v1.0.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

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

func NewStore[V any]() *Store[V]

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

func (*Store[V]) Delete

func (s *Store[V]) Delete(key string)

Delete removes a value by key.

func (*Store[V]) Get

func (s *Store[V]) Get(key string) (value V, ok bool)

Get returns a value by key.

func (*Store[V]) Set

func (s *Store[V]) Set(key string, value V)

Set stores a value by key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL