memory

package
v0.0.0-...-fdc8e6b Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const COMPACTION_INTERVAL = 5 * time.Second

Duration between times when we clear out all old data from the memory cache.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryCache

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

This is a simple in-memory cache that uses prefix trees to insert and retrieve cache items from memory.

func New

func New(maxEntries int) (*MemoryCache, error)

func (*MemoryCache) Close

func (m *MemoryCache) Close()

func (*MemoryCache) Flush

func (m *MemoryCache) Flush() error

func (*MemoryCache) Insert

func (m *MemoryCache) Insert(key string, value []byte, ttl time.Duration) error

func (*MemoryCache) Len

func (m *MemoryCache) Len() uint

func (*MemoryCache) Retrieve

func (m *MemoryCache) Retrieve(key string) ([]byte, error)

func (*MemoryCache) Size

func (m *MemoryCache) Size() uint64

Size will not be accurate for an in-memory Cache

Jump to

Keyboard shortcuts

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