Documentation
¶
Index ¶
- func ShardInt[T constraints.Integer](v T) uint64
- type Cache
- func (c *Cache[K, V]) Capacity() int64
- func (c *Cache[K, V]) Contains(key K) bool
- func (c *Cache[K, V]) CurrentSeq(key K) (uint64, bool)
- func (c *Cache[K, V]) Delete(ctx context.Context, key K)
- func (c *Cache[K, V]) Evict(ctx context.Context, done chan int64, capacityCut int64)
- func (c *Cache[K, V]) EvictToTargetWithWait(ctx context.Context, target int64) int64
- func (c *Cache[K, V]) EvictWithWait(ctx context.Context, capacityCut int64) int64
- func (c *Cache[K, V]) ForceEvict(ctx context.Context, n int64)
- func (c *Cache[K, V]) ForceEvictWithWait(ctx context.Context, n int64) int64
- func (c *Cache[K, V]) Get(ctx context.Context, key K) (value V, ok bool)
- func (c *Cache[K, V]) Replace(ctx context.Context, key K, value V, size int64) bool
- func (c *Cache[K, V]) Set(ctx context.Context, key K, value V, size int64) (inserted bool, rejected bool)
- func (c *Cache[K, V]) SetAdmissionTarget(admissionTarget func(capacity int64) (int64, bool))
- func (c *Cache[K, V]) Used() int64
- type DataCache
- func (d *DataCache) Available() int64
- func (d *DataCache) Capacity() int64
- func (d *DataCache) Contains(key query.CacheKey) bool
- func (d *DataCache) CurrentSeq(key query.CacheKey) (uint64, bool)
- func (d *DataCache) DeletePaths(ctx context.Context, paths []string)
- func (d *DataCache) EnsureNBytes(ctx context.Context, want int)
- func (d *DataCache) Evict(ctx context.Context, ch chan int64)
- func (d *DataCache) EvictToTargetWithWait(ctx context.Context, target int64) int64
- func (d *DataCache) Flush(ctx context.Context)
- func (d *DataCache) ForceEvictWithWait(ctx context.Context, n int64) int64
- func (d *DataCache) Get(ctx context.Context, key query.CacheKey) (fscache.Data, bool)
- func (d *DataCache) Set(ctx context.Context, key query.CacheKey, value fscache.Data) error
- func (d *DataCache) SetAdmissionTarget(admissionTarget func(capacity int64) (int64, bool))
- func (d *DataCache) Used() int64
- type Queue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShardInt ¶
func ShardInt[T constraints.Integer](v T) uint64
Types ¶
type Cache ¶
type Cache[K comparable, V any] struct { // contains filtered or unexported fields }
Cache implements an in-memory cache with FIFO-based eviction
func New ¶
func New[K comparable, V any]( capacity fscache.CapacityFunc, keyShardFunc func(K) uint64, postSet func(ctx context.Context, key K, value V, size int64, seq uint64), postGet func(ctx context.Context, key K, value V, size int64), postEvict func(ctx context.Context, key K, value V, size int64, seq uint64), ) *Cache[K, V]
func NewWithPrepareSet ¶
func NewWithPrepareSet[K comparable, V any]( capacity fscache.CapacityFunc, keyShardFunc func(K) uint64, prepareSet func(ctx context.Context, key K, value V, size int64, seq uint64) func(inserted bool), postSet func(ctx context.Context, key K, value V, size int64, seq uint64), postGet func(ctx context.Context, key K, value V, size int64), postEvict func(ctx context.Context, key K, value V, size int64, seq uint64), ) *Cache[K, V]
func (*Cache[K, V]) CurrentSeq ¶
func (*Cache[K, V]) EvictToTargetWithWait ¶
func (*Cache[K, V]) EvictWithWait ¶
EvictWithWait is like Evict but blocks until the eviction lock is acquired, guaranteeing that eviction actually runs before returning. This is used by EnsureNBytes to prevent unbounded memory growth under high concurrency where TryLock-based Evict would skip eviction entirely. It returns actual used bytes after eviction stops.
func (*Cache[K, V]) ForceEvict ¶
ForceEvict evicts n bytes despite capacity
func (*Cache[K, V]) ForceEvictWithWait ¶
ForceEvictWithWait evicts n bytes despite capacity and waits for callbacks.
func (*Cache[K, V]) SetAdmissionTarget ¶
type DataCache ¶ added in v1.2.3
type DataCache struct {
// contains filtered or unexported fields
}
func NewDataCache ¶ added in v1.2.3
func NewDataCache( capacity fscache.CapacityFunc, postSet func(ctx context.Context, key fscache.CacheKey, value fscache.Data, size int64, seq uint64), postGet func(ctx context.Context, key fscache.CacheKey, value fscache.Data, size int64), postEvict func(ctx context.Context, key fscache.CacheKey, value fscache.Data, size int64, seq uint64), ) *DataCache
func NewDataCacheWithPrepareSet ¶
func NewDataCacheWithPrepareSet( capacity fscache.CapacityFunc, prepareSet func(ctx context.Context, key fscache.CacheKey, value fscache.Data, size int64, seq uint64) func(inserted bool), postSet func(ctx context.Context, key fscache.CacheKey, value fscache.Data, size int64, seq uint64), postGet func(ctx context.Context, key fscache.CacheKey, value fscache.Data, size int64), postEvict func(ctx context.Context, key fscache.CacheKey, value fscache.Data, size int64, seq uint64), ) *DataCache
func (*DataCache) DeletePaths ¶ added in v1.2.3
func (*DataCache) EnsureNBytes ¶ added in v1.2.3
func (*DataCache) EvictToTargetWithWait ¶
func (*DataCache) ForceEvictWithWait ¶
func (*DataCache) SetAdmissionTarget ¶
Click to show internal directories.
Click to hide internal directories.