Versions in this module Expand all Collapse all v1 v1.3.27 Aug 11, 2023 Changes in this version + const DefaultExpiration + const NoExpiration + type Cache struct + func New(defaultExpiration, cleanupInterval time.Duration) *Cache[K, T] + func NewFrom(defaultExpiration, cleanupInterval time.Duration, items map[K]Item[T]) *Cache[K, T] + func (c Cache) Add(k K, x T, ds ...time.Duration) error + func (c Cache) Delete(k K) + func (c Cache) DeleteExpired() + func (c Cache) Flush() + func (c Cache) Get(k K) (T, bool) + func (c Cache) GetOrSet(k K, x T, ds ...time.Duration) T + func (c Cache) GetOrSetFun(k K, ff func(k K) T, ds ...time.Duration) T + func (c Cache) GetTLL(k K, ds ...time.Duration) (T, bool) + func (c Cache) GetWithExpiration(k K) (T, time.Time, bool) + func (c Cache) ItemCount() int + func (c Cache) Items() map[K]Item[T] + func (c Cache) Load(r io.Reader) error + func (c Cache) LoadFile(fname string) error + func (c Cache) OnEvicted(f func(K, T)) + func (c Cache) Replace(k K, x T, ds ...time.Duration) error + func (c Cache) Save(w io.Writer) (err error) + func (c Cache) SaveFile(fname string) error + func (c Cache) Set(k K, x T, ds ...time.Duration) + type Item struct + Expiration int64 + Object T + func (item Item[T]) Expired() bool