Versions in this module Expand all Collapse all v2 v2.11.1 Mar 24, 2022 Changes in this version + const ErrClosed + const ErrNotFound + const ItemExpireWithGlobalTTL + const ItemNotExpire + type Cache struct + func NewCache() *Cache + func (cache *Cache) Close() error + func (cache *Cache) Count() int + func (cache *Cache) Get(key string) (interface{}, error) + func (cache *Cache) GetByLoader(key string, customLoaderFunction LoaderFunction) (interface{}, error) + func (cache *Cache) GetByLoaderWithTtl(key string, customLoaderFunction LoaderFunction) (interface{}, time.Duration, error) + func (cache *Cache) GetItems() map[string]interface{} + func (cache *Cache) GetKeys() []string + func (cache *Cache) GetMetrics() Metrics + func (cache *Cache) GetWithTTL(key string) (interface{}, time.Duration, error) + func (cache *Cache) Purge() error + func (cache *Cache) Remove(key string) error + func (cache *Cache) Set(key string, data interface{}) error + func (cache *Cache) SetCacheSizeLimit(limit int) + func (cache *Cache) SetCheckExpirationCallback(callback CheckExpireCallback) + func (cache *Cache) SetExpirationCallback(callback ExpireCallback) + func (cache *Cache) SetExpirationReasonCallback(callback ExpireReasonCallback) + func (cache *Cache) SetLoaderFunction(loader LoaderFunction) + func (cache *Cache) SetNewItemCallback(callback ExpireCallback) + func (cache *Cache) SetTTL(ttl time.Duration) error + func (cache *Cache) SetWithTTL(key string, data interface{}, ttl time.Duration) error + func (cache *Cache) SkipTTLExtensionOnHit(value bool) + func (cache *Cache) Touch(key string) error + type CheckExpireCallback func(key string, value interface{}) bool + type EvictionReason int + const Closed + const EvictedSize + const Expired + const Removed + func EvictionReasonString(s string) (EvictionReason, error) + func EvictionReasonValues() []EvictionReason + func (i EvictionReason) IsAEvictionReason() bool + func (i EvictionReason) String() string + type ExpireCallback func(key string, value interface{}) + type ExpireReasonCallback func(key string, reason EvictionReason, value interface{}) + type LoaderFunction func(key string) (data interface{}, ttl time.Duration, err error) + type Metrics struct + Evicted int64 + Hits int64 + Inserted int64 + Misses int64 + Retrievals int64 + type SimpleCache interface + Close func() error + Get func(key string) (interface{}, error) + GetWithTTL func(key string) (interface{}, time.Duration, error) + Purge func() error + Remove func(key string) error + Set func(key string, data interface{}) error + SetTTL func(ttl time.Duration) error + SetWithTTL func(key string, data interface{}, ttl time.Duration) error Other modules containing this package github.com/jellydator/ttlcache github.com/jellydator/ttlcache/v3