Versions in this module Expand all Collapse all v1 v1.1.0 Apr 23, 2024 v1.0.1 Apr 5, 2024 Changes in this version + func WithDataSizeFn(fn func(string, any) (uint64, error)) cacheOptFn + func WithOnEvictionFn(fn func(string, any)) cacheOptFn type Cache + func (c *Cache) ChangeOnEvictionFn(fn func(string, any)) v1.0.0 Apr 3, 2024 Changes in this version + var ErrDuration = errors.New("non-positive duration") + var ErrExists = errors.New("already exists") + var ErrExpired = errors.New("is expired") + var ErrMaxLength = errors.New("max data limit") + var ErrMaxSize = errors.New("max size limit") + var ErrNotExists = errors.New("does not exist") + var ErrNotInt = errors.New("data type is not integer") + func Decrement[T Integer](c *Cache, k string, n T) (T, error) + func Increment[T Integer](c *Cache, k string, n T) (T, error) + func WithCleanupInteval(d time.Duration) cacheOptFn + func WithDataSize(fn func(string, any) (uint64, error)) cacheOptFn + func WithDefaultLifetime(lt uint64) cacheOptFn + func WithLifetime(lt uint64) unitOptFn + func WithMaxSize(ms uint64) cacheOptFn + func WithMaxUnits(mu uint64) cacheOptFn + func WithOnEviction(fn func(string, any)) cacheOptFn + func WithSize(s uint64) unitOptFn + func WithoutJanitorEviction(co *cacheOpts) + type Cache struct + func New(opts ...cacheOptFn) *Cache + func (c *Cache) Add(k string, a any, opts ...unitOptFn) error + func (c *Cache) Alive() map[string]any + func (c *Cache) ChangeDefaultLifeTime(lt uint64) + func (c *Cache) ChangeJanitorOnEviction(b bool) + func (c *Cache) ChangeMaxLength(ml uint64) error + func (c *Cache) ChangeMaxSize(i uint64) error + func (c *Cache) ChangeOnEviction(fn func(string, any)) + func (c *Cache) ChangeSizeFn(fn func(string, any) (uint64, error)) + func (c *Cache) Delete(k string) + func (c *Cache) DeleteAll() + func (c *Cache) DeleteExpired() + func (c *Cache) Get(k string) (any, error) + func (c *Cache) Length() int + func (c *Cache) Load(r io.Reader) error + func (c *Cache) OrderCleaning() + func (c *Cache) Remove(k string) + func (c *Cache) RemoveAll() + func (c *Cache) RemoveExpired() + func (c *Cache) Rename(oldKey, newKey string) error + func (c *Cache) Replace(k string, a any) error + func (c *Cache) RescheduleCleaning(d time.Duration) error + func (c *Cache) Revive(k string) error + func (c *Cache) ReviveUntil(k string, lt uint64) error + func (c *Cache) Save(w io.Writer) error + func (c *Cache) Scan(sub string) map[string]any + func (c *Cache) ScanFunc(fn func(string) bool) map[string]any + func (c *Cache) Set(k string, a any, opts ...unitOptFn) error + func (c *Cache) Size() uint64 + func (c *Cache) Snapshot() map[string]any + func (c *Cache) Stats() *Stats + func (c *Cache) StopCleaning() + type Integer interface + type Stats struct + CleanupInterval time.Duration + CurrentLength int + CurrentSize uint64 + DefaultLifetime uint64 + MaxLength uint64 + MaxSize uint64