storer

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package storer is implements a cache deleting its entries after each interval.

Index

Constants

View Source
const (
	// DefaultTTL is default ttl of the ache entries.
	DefaultTTL = 10 * time.Minute
	// DefaultInterval is default interval to execute the "garbage collection" of the cache.
	DefaultInterval = 15 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryStore

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

InMemoryStore is similar to the sdk one, the main difference is cleanCache method executed each interval.

func NewInMemoryStore

func NewInMemoryStore(ttl time.Duration, interval time.Duration, logger *logrus.Logger) *InMemoryStore

NewInMemoryStore will create and initialize an InMemoryStore.

func (InMemoryStore) Delete

func (ims InMemoryStore) Delete(_ string) error

Delete implementation to respect interface.

func (InMemoryStore) Get

func (ims InMemoryStore) Get(key string, valuePtr interface{}) (int64, error)

Get gets the value associated to a given key and stores it in the value referenced by the pointer passed as second argument.

func (*InMemoryStore) Save

func (ims *InMemoryStore) Save() error

Save implementation to respect interface.

func (InMemoryStore) Set

func (ims InMemoryStore) Set(key string, value interface{}) int64

Set stores a value for a given key.

func (InMemoryStore) StopVacuum

func (ims InMemoryStore) StopVacuum()

StopVacuum Stops the goroutine in charge of the vacuum of the cache.

type Storer added in v3.3.0

type Storer interface {
	Set(key string, value interface{}) int64
	Get(key string, valuePtr interface{}) (int64, error)
}

Jump to

Keyboard shortcuts

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