Versions in this module Expand all Collapse all v1 v1.2.4 Oct 8, 2021 Changes in this version + const DefaultMaxSize + const Gigabyte + const JanitorMaxIterationsPerShift + const JanitorMaxShiftBackOff + const JanitorMinShiftBackOff + const JanitorShiftTarget + const Kilobyte + const Megabyte + const NoExpiration + const NoMaxMemoryUsage + const NoMaxSize + var Debug = false + var ErrJanitorAlreadyRunning = errors.New("janitor is already running") + var ErrKeyDoesNotExist = errors.New("key does not exist") + var ErrKeyHasNoExpiration = errors.New("key has no expiration") + func MatchPattern(pattern, s string) bool + type Cache struct + func NewCache() *Cache + func (cache *Cache) Clear() + func (cache *Cache) Count() int + func (cache *Cache) Delete(key string) bool + func (cache *Cache) DeleteAll(keys []string) int + func (cache *Cache) EvictionPolicy() EvictionPolicy + func (cache *Cache) Expire(key string, ttl time.Duration) bool + func (cache *Cache) Get(key string) (interface{}, bool) + func (cache *Cache) GetAll() map[string]interface{} + func (cache *Cache) GetByKeys(keys []string) map[string]interface{} + func (cache *Cache) GetKeysByPattern(pattern string, limit int) []string + func (cache *Cache) GetValue(key string) interface{} + func (cache *Cache) MaxMemoryUsage() int + func (cache *Cache) MaxSize() int + func (cache *Cache) MemoryUsage() int + func (cache *Cache) ReadFromFile(path string) (int, error) + func (cache *Cache) SaveToFile(path string) error + func (cache *Cache) Set(key string, value interface{}) + func (cache *Cache) SetAll(entries map[string]interface{}) + func (cache *Cache) SetWithTTL(key string, value interface{}, ttl time.Duration) + func (cache *Cache) StartJanitor() error + func (cache *Cache) Stats() Statistics + func (cache *Cache) StopJanitor() + func (cache *Cache) TTL(key string) (time.Duration, error) + func (cache *Cache) WithEvictionPolicy(policy EvictionPolicy) *Cache + func (cache *Cache) WithForceNilInterfaceOnNilPointer(forceNilInterfaceOnNilPointer bool) *Cache + func (cache *Cache) WithMaxMemoryUsage(maxMemoryUsageInBytes int) *Cache + func (cache *Cache) WithMaxSize(maxSize int) *Cache + type Entry struct + Expiration int64 + Key string + RelevantTimestamp time.Time + Value interface{} + func (entry *Entry) Accessed() + func (entry *Entry) SizeInBytes() int + func (entry Entry) Expired() bool + type EvictionPolicy string + var FirstInFirstOut EvictionPolicy = "FirstInFirstOut" + var LeastRecentlyUsed EvictionPolicy = "LeastRecentlyUsed" + type Statistics struct + EvictedKeys uint64 + ExpiredKeys uint64 + Hits uint64 + Misses uint64 Other modules containing this package github.com/TwiN/gocache/v2