memory

package
v1.9.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[E any] struct {
	// contains filtered or unexported fields
}
Cache is an in-memory cache. Each key-value pair stored in this cache have a TTL and one goroutine removes the

key-value pair form the cache which is older than TTL time.

func New

func New[E any]() (*Cache[E], error)

New method initiates the cache object. To initiate, this sets certain properties of the cache like keyTTL, cleanupFreq, size, empty cacheMap

func (*Cache[E]) Read

func (c *Cache[E]) Read(key string) ([]E, error)
ReadAndPopData reads the data by taking a string key,

if there is any data available corresponding to the given key then it removes the data from the cache and returns it in the form of []byte

func (*Cache[E]) Stop

func (c *Cache[E]) Stop() error

func (*Cache[E]) Update

func (c *Cache[E]) Update(key string, value E) error

Update Inserts the data in the cache, This method expects a string as a key and []byte as the data

Jump to

Keyboard shortcuts

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