Documentation ¶
Overview ¶
Package cache implements simple caching.
Index ¶
- type Manager
- func (a *Manager[K, V]) Cap() int
- func (a *Manager[K, V]) Delete(key K)
- func (a *Manager[K, V]) Len() int
- func (a *Manager[K, V]) Load(key K) (value V, ttl int64)
- func (a *Manager[K, V]) LoadAndDelete(key K) (value V, ttl int64)
- func (a *Manager[K, V]) LoadOrStore(key K, value V) (actual V, ttl int64)
- func (a *Manager[K, V]) Store(key K, value V)
- func (a *Manager[K, V]) TTL() int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager[K comparable, V any] struct { // contains filtered or unexported fields }
Manager represents a cache manager.
func (*Manager[K, V]) Delete ¶
func (a *Manager[K, V]) Delete(key K)
Delete deletes the value for a key.
func (*Manager[K, V]) Load ¶
Load returns the value stored in the cache for a key, or zero value if no value is present.
func (*Manager[K, V]) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any.
func (*Manager[K, V]) LoadOrStore ¶
LoadOrStore returns the value by key, if not exist, puts value in the key, and returns it.
Click to show internal directories.
Click to hide internal directories.