Documentation ¶
Overview ¶
Package inmem implements in-memory cache for storing data
Index ¶
- type Cache
- func (c Cache) Add(_ context.Context, k string, val []byte) error
- func (c Cache) Delete(_ context.Context, key string)
- func (c Cache) ExpiredItems() map[string]*item
- func (c Cache) Flush()
- func (c Cache) Get(_ context.Context, k string) ([]byte, bool)
- func (c Cache) GetItem(k string) (*item, bool)
- func (c Cache) Items() map[string]*item
- func (c Cache) MarkExpired()
- func (c Cache) OnEvicted(fn func(string, []byte))
- func (c Cache) OnExpired(fn func(string, []byte))
- func (c Cache) Purge()
- func (c Cache) Replace(_ context.Context, k string, val []byte) error
- func (c Cache) Set(_ context.Context, k string, val []byte)
- func (c Cache) SetWithDuration(_ context.Context, k string, val []byte, expiration time.Duration)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is sharable object which encapsulates cache
func (Cache) Add ¶
Add an item to the cache only if an item doesn't exist for the given key or if the existing item has expired. Returns error otherwise
func (Cache) ExpiredItems ¶
func (c Cache) ExpiredItems() map[string]*item
func (Cache) Items ¶
func (c Cache) Items() map[string]*item
Item Returns items which aren't expired
func (Cache) MarkExpired ¶
func (c Cache) MarkExpired()
Click to show internal directories.
Click to hide internal directories.