Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{ HardMaxCacheSize: maxCacheSizeInMB, Shards: totalShards, LifeWindow: ttlInMins * time.Minute, CleanWindow: cleanupInMins * time.Minute, MaxEntriesInWindow: maxEntriesInWin, MaxEntrySize: maxEntrySize, Verbose: false, }
DefaultOptions is an Options object with default values. Bigcache provides option to give hash function however we are going with default it uses FNV 1a: https://en.wikipedia.org/wiki/Fowler–Noll–Vo_hash_function#FNV-1a_hash Key : email address/oid - Max length of email is 264 chars but 95% email length is 31 Value: result bool true means access allowed false means access denied We will tweak MaxEntrySize and MaxEntriesInWindows as per requirement and testing.
Functions ¶
Types ¶
type DataStore ¶
type DataStore struct {
// contains filtered or unexported fields
}
func (*DataStore) Close ¶
Close closes the DataStore. When called, the cache is left for removal by the garbage collector.
func (*DataStore) Delete ¶
Delete deletes the stored value for the given key. The key must not be "".
type Options ¶
type Options struct { // Number of cache shards, value must be a power of two Shards int // Time after which entry can be evicted LifeWindow time.Duration // Interval between removing expired entries (clean up). // If set to <= 0 then no action is performed. Setting to < 1 second is counterproductive — bigcache has a one second resolution. CleanWindow time.Duration // Max number of entries in life window. Used only to calculate initial size for cache shards. // When proper value is set then additional memory allocation does not occur. MaxEntriesInWindow int // Max size of entry in bytes. Used only to calculate initial size for cache shards. MaxEntrySize int // StatsEnabled if true calculate the number of times a cached resource was requested. StatsEnabled bool // Verbose mode prints information about new memory allocation Verbose bool // HardMaxCacheSize is a limit for cache size in MB. Cache will not allocate more memory than this limit. // It can protect application from consuming all available memory on machine, therefore from running OOM Killer. // Default value is 0 which means unlimited size. When the limit is higher than 0 and reached then // the oldest entries are overridden for the new ones. HardMaxCacheSize int }
Options are the options for the BigCache store.