Documentation
¶
Index ¶
- type S3FIFOCache
- func (c *S3FIFOCache[K, V]) Algorithm() string
- func (c *S3FIFOCache[K, V]) All() map[K]V
- func (c *S3FIFOCache[K, V]) Capacity() int
- func (c *S3FIFOCache[K, V]) Delete(key K) bool
- func (c *S3FIFOCache[K, V]) DeleteMany(keys []K) map[K]bool
- func (c *S3FIFOCache[K, V]) Get(key K) (value V, ok bool)
- func (c *S3FIFOCache[K, V]) GetMany(keys []K) (map[K]V, []K)
- func (c *S3FIFOCache[K, V]) Has(key K) bool
- func (c *S3FIFOCache[K, V]) HasMany(keys []K) map[K]bool
- func (c *S3FIFOCache[K, V]) Keys() []K
- func (c *S3FIFOCache[K, V]) Len() int
- func (c *S3FIFOCache[K, V]) Peek(key K) (value V, ok bool)
- func (c *S3FIFOCache[K, V]) PeekMany(keys []K) (map[K]V, []K)
- func (c *S3FIFOCache[K, V]) Purge()
- func (c *S3FIFOCache[K, V]) Range(f func(K, V) bool)
- func (c *S3FIFOCache[K, V]) Set(key K, value V)
- func (c *S3FIFOCache[K, V]) SetMany(items map[K]V)
- func (c *S3FIFOCache[K, V]) SizeBytes() int64
- func (c *S3FIFOCache[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type S3FIFOCache ¶
type S3FIFOCache[K comparable, V any] struct { // contains filtered or unexported fields }
S3FIFOCache is a Simple, Scalable cache with 3 FIFO queues. It uses three queues: Small (10%), Main (90%), and Ghost (metadata only).
func NewS3FIFOCache ¶
func NewS3FIFOCache[K comparable, V any](capacity int) *S3FIFOCache[K, V]
NewS3FIFOCache creates a new S3 FIFO cache with the specified capacity.
func NewS3FIFOCacheWithEvictionCallback ¶
func NewS3FIFOCacheWithEvictionCallback[K comparable, V any](capacity int, onEviction base.EvictionCallback[K, V]) *S3FIFOCache[K, V]
NewS3FIFOCacheWithEvictionCallback creates a new S3 FIFO cache with the specified capacity and eviction callback.
func (*S3FIFOCache[K, V]) Algorithm ¶
func (c *S3FIFOCache[K, V]) Algorithm() string
Algorithm returns the name of the eviction algorithm used by the cache.
func (*S3FIFOCache[K, V]) All ¶
func (c *S3FIFOCache[K, V]) All() map[K]V
All returns all key-value pairs in the cache.
func (*S3FIFOCache[K, V]) Capacity ¶
func (c *S3FIFOCache[K, V]) Capacity() int
Capacity returns the maximum number of items the cache can hold.
func (*S3FIFOCache[K, V]) Delete ¶
func (c *S3FIFOCache[K, V]) Delete(key K) bool
Delete removes a key from the cache. Returns true if the key was found and removed, false otherwise.
func (*S3FIFOCache[K, V]) DeleteMany ¶
func (c *S3FIFOCache[K, V]) DeleteMany(keys []K) map[K]bool
DeleteMany removes multiple keys from the cache.
func (*S3FIFOCache[K, V]) Get ¶
func (c *S3FIFOCache[K, V]) Get(key K) (value V, ok bool)
Get retrieves a value from the cache and increments its frequency. Returns the value and a boolean indicating if the key was found.
func (*S3FIFOCache[K, V]) GetMany ¶
func (c *S3FIFOCache[K, V]) GetMany(keys []K) (map[K]V, []K)
GetMany retrieves multiple values from the cache.
func (*S3FIFOCache[K, V]) Has ¶
func (c *S3FIFOCache[K, V]) Has(key K) bool
Has checks if a key exists in the cache.
func (*S3FIFOCache[K, V]) HasMany ¶
func (c *S3FIFOCache[K, V]) HasMany(keys []K) map[K]bool
HasMany checks if multiple keys exist in the cache.
func (*S3FIFOCache[K, V]) Keys ¶
func (c *S3FIFOCache[K, V]) Keys() []K
Keys returns all keys currently in the cache.
func (*S3FIFOCache[K, V]) Len ¶
func (c *S3FIFOCache[K, V]) Len() int
Len returns the current number of items in the cache.
func (*S3FIFOCache[K, V]) Peek ¶
func (c *S3FIFOCache[K, V]) Peek(key K) (value V, ok bool)
Peek retrieves a value from the cache without updating frequency or position. Returns the value and a boolean indicating if the key was found.
func (*S3FIFOCache[K, V]) PeekMany ¶
func (c *S3FIFOCache[K, V]) PeekMany(keys []K) (map[K]V, []K)
PeekMany retrieves multiple values from the cache without updating access order.
func (*S3FIFOCache[K, V]) Purge ¶
func (c *S3FIFOCache[K, V]) Purge()
Purge removes all keys and values from the cache.
func (*S3FIFOCache[K, V]) Range ¶
func (c *S3FIFOCache[K, V]) Range(f func(K, V) bool)
Range iterates over all key-value pairs in the cache. The iteration stops if the function returns false.
func (*S3FIFOCache[K, V]) Set ¶
func (c *S3FIFOCache[K, V]) Set(key K, value V)
Set stores a key-value pair in the cache. If the key already exists, its value is updated without changing frequency. If the cache is at capacity, items are evicted according to S3 FIFO policy.
func (*S3FIFOCache[K, V]) SetMany ¶
func (c *S3FIFOCache[K, V]) SetMany(items map[K]V)
SetMany stores multiple key-value pairs in the cache.
func (*S3FIFOCache[K, V]) SizeBytes ¶
func (c *S3FIFOCache[K, V]) SizeBytes() int64
SizeBytes returns the total size of all cache entries in bytes.
func (*S3FIFOCache[K, V]) Values ¶
func (c *S3FIFOCache[K, V]) Values() []V
Values returns all values currently in the cache.