Documentation
¶
Index ¶
- func NewShardedInMemoryCache[K comparable, V any](shards uint64, newCache func() base.InMemoryCache[K, V], fn Hasher[K]) base.InMemoryCache[K, V]
- type Hasher
- type ShardedInMemoryCache
- func (c *ShardedInMemoryCache[K, V]) Algorithm() string
- func (c *ShardedInMemoryCache[K, V]) Capacity() int
- func (c *ShardedInMemoryCache[K, V]) Delete(key K) bool
- func (c *ShardedInMemoryCache[K, V]) DeleteMany(keys []K) map[K]bool
- func (c *ShardedInMemoryCache[K, V]) Get(key K) (value V, ok bool)
- func (c *ShardedInMemoryCache[K, V]) GetMany(keys []K) (map[K]V, []K)
- func (c *ShardedInMemoryCache[K, V]) Has(key K) bool
- func (c *ShardedInMemoryCache[K, V]) HasMany(keys []K) map[K]bool
- func (c *ShardedInMemoryCache[K, V]) Keys() []K
- func (c *ShardedInMemoryCache[K, V]) Len() int
- func (c *ShardedInMemoryCache[K, V]) Peek(key K) (value V, ok bool)
- func (c *ShardedInMemoryCache[K, V]) PeekMany(keys []K) (map[K]V, []K)
- func (c *ShardedInMemoryCache[K, V]) Purge()
- func (c *ShardedInMemoryCache[K, V]) Range(f func(K, V) bool)
- func (c *ShardedInMemoryCache[K, V]) Set(key K, value V)
- func (c *ShardedInMemoryCache[K, V]) SetMany(items map[K]V)
- func (c *ShardedInMemoryCache[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewShardedInMemoryCache ¶
func NewShardedInMemoryCache[K comparable, V any](shards uint64, newCache func() base.InMemoryCache[K, V], fn Hasher[K]) base.InMemoryCache[K, V]
Types ¶
type Hasher ¶
Hasher is responsible for generating unsigned, 16 bit hash of provided key. Hasher should minimize collisions. For great performance, a fast function is preferable.
type ShardedInMemoryCache ¶
type ShardedInMemoryCache[K comparable, V any] struct { // contains filtered or unexported fields }
ShardedInMemoryCache is a cache with safe concurrent access.
func (*ShardedInMemoryCache[K, V]) Algorithm ¶
func (c *ShardedInMemoryCache[K, V]) Algorithm() string
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Capacity ¶
func (c *ShardedInMemoryCache[K, V]) Capacity() int
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Delete ¶
func (c *ShardedInMemoryCache[K, V]) Delete(key K) bool
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) DeleteMany ¶
func (c *ShardedInMemoryCache[K, V]) DeleteMany(keys []K) map[K]bool
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Get ¶
func (c *ShardedInMemoryCache[K, V]) Get(key K) (value V, ok bool)
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) GetMany ¶
func (c *ShardedInMemoryCache[K, V]) GetMany(keys []K) (map[K]V, []K)
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Has ¶
func (c *ShardedInMemoryCache[K, V]) Has(key K) bool
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) HasMany ¶
func (c *ShardedInMemoryCache[K, V]) HasMany(keys []K) map[K]bool
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Keys ¶
func (c *ShardedInMemoryCache[K, V]) Keys() []K
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Len ¶
func (c *ShardedInMemoryCache[K, V]) Len() int
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Peek ¶
func (c *ShardedInMemoryCache[K, V]) Peek(key K) (value V, ok bool)
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) PeekMany ¶
func (c *ShardedInMemoryCache[K, V]) PeekMany(keys []K) (map[K]V, []K)
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Purge ¶
func (c *ShardedInMemoryCache[K, V]) Purge()
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Range ¶
func (c *ShardedInMemoryCache[K, V]) Range(f func(K, V) bool)
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Set ¶
func (c *ShardedInMemoryCache[K, V]) Set(key K, value V)
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) SetMany ¶
func (c *ShardedInMemoryCache[K, V]) SetMany(items map[K]V)
implements base.InMemoryCache
func (*ShardedInMemoryCache[K, V]) Values ¶
func (c *ShardedInMemoryCache[K, V]) Values() []V
implements base.InMemoryCache