Documentation
¶
Index ¶
- type Cache
- func (a *Cache[K, V]) All() iter.Seq2[K, V]
- func (a *Cache[K, V]) Capacity() int64
- func (a *Cache[K, V]) Clear()
- func (a *Cache[K, V]) Get(k K) (_ V, ok bool)
- func (a *Cache[K, V]) Len() int
- func (a *Cache[K, V]) Peek(k K) (V, bool)
- func (a *Cache[K, V]) Promote(k K)
- func (a *Cache[K, V]) Set(k K, v V)
- func (a *Cache[K, V]) SetAvailableCapacity(available, max int64)
- func (a *Cache[K, V]) SetCapacity(c int64)
- func (a *Cache[K, V]) SetLargerCapacity(available, max int64)
- func (a *Cache[K, V]) SetS(k K, v V, size uint32)
- func (a *Cache[K, V]) Size() int64
- type CacheOptions
- type CacheValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[K, V any] struct { // contains filtered or unexported fields }
Concurrent safe.
func NewCache ¶
func NewCache[K comparable, V any](o CacheOptions[K, V]) *Cache[K, V]
func (*Cache[K, V]) Clear ¶
func (a *Cache[K, V]) Clear()
Evicts all and resets. Does not change capacity. Will block.
func (*Cache[K, V]) SetAvailableCapacity ¶
available (+/-) should not consider taken space in cache.
func (*Cache[K, V]) SetCapacity ¶
func (*Cache[K, V]) SetLargerCapacity ¶
Noop if smaller. available (+/-) should not consider taken space in cache. DEPRECATED. Please use SetAvailableCapacity.
type CacheOptions ¶
type CacheOptions[K, V any] struct { Expiration time.Duration // Defaults to forever. Evict func(K, V) // Might be called concurrently. Capacity int64 // Defaults to 100. RLock bool // Whether to use an RLock when possible. Defaults to false. MapCreator func() maps.Map[K, *CacheValue[V]] // defaults to maps.Sync. PolicyCreator func() policy.Policy[K] // defaults to policy.NewARC. }
type CacheValue ¶
type CacheValue[V any] struct { // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.