Documentation
¶
Index ¶
- type CacheEntry
- type Expirable
- type ExpirationTime
- type KeyedCache
- func (c *KeyedCache[T]) Clear()
- func (c *KeyedCache[T]) Delete(key string)
- func (c *KeyedCache[T]) GC()
- func (c *KeyedCache[T]) Get(key string) (T, bool)
- func (c *KeyedCache[T]) Pop(key string) (T, bool)
- func (c *KeyedCache[T]) Set(key string, value T)
- func (c *KeyedCache[T]) SetWithExpirable(key string, value T, exp Expirable)
- func (c *KeyedCache[T]) SetWithTTL(key string, value T, ttl time.Duration)
- type TypedCache
- func (c *TypedCache[T]) Clear()
- func (c *TypedCache[T]) DeleteKey(key string)
- func (c *TypedCache[T]) GC()
- func (c *TypedCache[T]) GetType(key, typeKey string) (T, bool)
- func (c *TypedCache[T]) SetType(key, typeKey string, value T)
- func (c *TypedCache[T]) SetTypeWithExpirable(key, typeKey string, value T, exp Expirable)
- func (c *TypedCache[T]) SetTypeWithTTL(key, typeKey string, value T, ttl time.Duration)
- type WeakCacheMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheEntry ¶
type ExpirationTime ¶
func (ExpirationTime) Expired ¶
func (e ExpirationTime) Expired() bool
type KeyedCache ¶
type KeyedCache[T any] struct { // contains filtered or unexported fields }
func NewKeyedCache ¶
func NewKeyedCache[T any](ttl time.Duration) *KeyedCache[T]
func (*KeyedCache[T]) Clear ¶
func (c *KeyedCache[T]) Clear()
func (*KeyedCache[T]) Delete ¶
func (c *KeyedCache[T]) Delete(key string)
func (*KeyedCache[T]) GC ¶
func (c *KeyedCache[T]) GC()
func (*KeyedCache[T]) Get ¶
func (c *KeyedCache[T]) Get(key string) (T, bool)
func (*KeyedCache[T]) Pop ¶ added in v4.1.9
func (c *KeyedCache[T]) Pop(key string) (T, bool)
func (*KeyedCache[T]) Set ¶
func (c *KeyedCache[T]) Set(key string, value T)
func (*KeyedCache[T]) SetWithExpirable ¶
func (c *KeyedCache[T]) SetWithExpirable(key string, value T, exp Expirable)
func (*KeyedCache[T]) SetWithTTL ¶
func (c *KeyedCache[T]) SetWithTTL(key string, value T, ttl time.Duration)
type TypedCache ¶
type TypedCache[T any] struct { // contains filtered or unexported fields }
func NewTypedCache ¶
func NewTypedCache[T any](ttl time.Duration) *TypedCache[T]
func (*TypedCache[T]) Clear ¶
func (c *TypedCache[T]) Clear()
func (*TypedCache[T]) DeleteKey ¶
func (c *TypedCache[T]) DeleteKey(key string)
func (*TypedCache[T]) GC ¶
func (c *TypedCache[T]) GC()
func (*TypedCache[T]) GetType ¶
func (c *TypedCache[T]) GetType(key, typeKey string) (T, bool)
func (*TypedCache[T]) SetType ¶
func (c *TypedCache[T]) SetType(key, typeKey string, value T)
func (*TypedCache[T]) SetTypeWithExpirable ¶
func (c *TypedCache[T]) SetTypeWithExpirable(key, typeKey string, value T, exp Expirable)
func (*TypedCache[T]) SetTypeWithTTL ¶
func (c *TypedCache[T]) SetTypeWithTTL(key, typeKey string, value T, ttl time.Duration)
type WeakCacheMap ¶ added in v4.2.3
type WeakCacheMap[K comparable, V any] struct { // contains filtered or unexported fields }
WeakCacheMap is a map that holds weak references to values. Use for shared expensive objects and automatic cleanup when no longer used. This object can be GC and no goroutine is used for cleanup.
func NewWeakCacheMap ¶ added in v4.2.3
func NewWeakCacheMap[K comparable, V any]() *WeakCacheMap[K, V]
func (*WeakCacheMap[K, V]) Clear ¶ added in v4.2.3
func (c *WeakCacheMap[K, V]) Clear()
func (*WeakCacheMap[K, V]) Delete ¶ added in v4.2.3
func (c *WeakCacheMap[K, V]) Delete(key K) bool
func (*WeakCacheMap[K, V]) Load ¶ added in v4.2.3
func (c *WeakCacheMap[K, V]) Load(key K) (value *V, ok bool)
func (*WeakCacheMap[K, V]) Store ¶ added in v4.2.3
func (c *WeakCacheMap[K, V]) Store(key K, value *V)
Click to show internal directories.
Click to hide internal directories.