Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache cache
func New ¶
func New(options MemoryCacheOptions) (memorycache *MemoryCache)
New construct and load cache data from file if set FileName
func (*MemoryCache) Close ¶
func (m *MemoryCache) Close()
Close destruct and save cache data in file if set FileName
func (*MemoryCache) Count ¶
func (m *MemoryCache) Count() (count int)
Count provide count entries in cache
func (*MemoryCache) Get ¶
func (m *MemoryCache) Get(key string) (value interface{}, ok bool)
Get provide entry value by key
func (*MemoryCache) Set ¶
func (m *MemoryCache) Set(key string, value interface{}, options MemoryCacheEntryOptions)
Set add entry or update value by key
type MemoryCacheEntryDurability ¶
type MemoryCacheEntryDurability int
MemoryCacheEntryDurability resistance to evicting entries from cache when limit is reached
const ( Weak MemoryCacheEntryDurability = -1 // lowest resistance, evicted first Normal MemoryCacheEntryDurability = 0 // evicted if there are no records with priority Weak Strong MemoryCacheEntryDurability = 1 // evicted if there are no records with priority Normal )
type MemoryCacheEntryOptions ¶
type MemoryCacheEntryOptions struct { // Lifetime entry lifetime, if not set, then 0 Lifetime time.Duration // Durability eviction resistance, if not set, then Normal Durability MemoryCacheEntryDurability }
MemoryCacheEntryOptions
type MemoryCacheOptions ¶
type MemoryCacheOptions struct { // CleanupInterval interval for clearing cache from obsolete entries, if not set, then it does not start CleanupInterval time.Duration // LimitEntries limit of entries in cache, upon reaching which eviction begins, if not set, then unlimited LimitEntries int // FileName file to restore cache when application is restarted, if not set, it does not restore FileName string }
MemoryCacheOptions cache options
Click to show internal directories.
Click to hide internal directories.