data

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func NewDataStore

func NewDataStore(options Options) (authz.Store, error)

NewDataStore creates a BigCache store.

Types

type DataStore

type DataStore struct {
	// contains filtered or unexported fields
}

func (*DataStore) Close

func (s *DataStore) Close() error

Close closes the DataStore. When called, the cache is left for removal by the garbage collector.

func (*DataStore) Delete

func (s *DataStore) Delete(key string) error

Delete deletes the stored value for the given key. The key must not be "".

func (*DataStore) Get

func (s *DataStore) Get(key string, value interface{}) (found bool, err error)

Get retrieves the Stored value for the given key. If no value is found it returns (false, nil). The key must not be "" and the pointer must not be nil.

func (*DataStore) Set

func (s *DataStore) Set(key string, value interface{}) error

Set stores the given value for the given key. The key must not be "" and the value must not be nil.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL