Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K comparable, U comparable, V any] interface { // Set inserts or replaces an entry. userID is used for bulk invalidation. Set(key K, user U, value V, expiry time.Time) // Get returns the cached value if present and not expired, updating its access time. Get(key K) (V, bool) // Delete removes a single entry by key. Delete(key K) // DeleteByUser removes all entries associated with the given user ID. DeleteByUser(user U) // Prune removes all expired entries, returning the count removed. Prune() int // Stats returns a snapshot of cache statistics. Stats() CacheStats }
Cache is a generic in-memory LRU cache with per-entry expiry and user-based invalidation.
func New ¶
func New[K comparable, U comparable, V any](maxSize int) Cache[K, U, V]
Click to show internal directories.
Click to hide internal directories.