memory

package
v0.0.0-...-226ad4c Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: AGPL-3.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdapter

func NewAdapter(opts ...AdapterOptions) (cache.Adapter, error)

NewAdapter initializes memory adapter.

Types

type Adapter

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

Adapter is the memory adapter data structure.

func (*Adapter) Get

func (a *Adapter) Get(key uint64) ([]byte, bool)

Get implements the cache Adapter interface Get method.

func (*Adapter) Release

func (a *Adapter) Release(key uint64)

Release implements the Adapter interface Release method.

func (*Adapter) Set

func (a *Adapter) Set(key uint64, response []byte, expiration time.Time)

Set implements the cache Adapter interface Set method.

type AdapterOptions

type AdapterOptions func(a *Adapter) error

AdapterOptions is used to set Adapter settings.

func AdapterWithAlgorithm

func AdapterWithAlgorithm(alg Algorithm) AdapterOptions

AdapterWithAlgorithm sets the approach used to select a cached response to be evicted when the capacity is reached.

func AdapterWithCapacity

func AdapterWithCapacity(cap int) AdapterOptions

AdapterWithCapacity sets the maximum number of cached responses.

type Algorithm

type Algorithm string

Algorithm is the string type for caching algorithms labels.

const (
	// LRU is the constant for Least Recently Used.
	LRU Algorithm = "LRU"

	// MRU is the constant for Most Recently Used.
	MRU Algorithm = "MRU"

	// LFU is the constant for Least Frequently Used.
	LFU Algorithm = "LFU"

	// MFU is the constant for Most Frequently Used.
	MFU Algorithm = "MFU"
)

Jump to

Keyboard shortcuts

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