cache

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 13 Imported by: 1

README

Sphire Mantis::Cache

The Cache package of Mantis provides helpers for Big Cache, Memcache, and a custom Disk Cache implementation.

Documentation

Index

Constants

View Source
const (
	RELEASED = iota
	UPDATED
	CREATED
	NOOP
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BigCache

type BigCache struct {
	Cache  *bigcache.BigCache
	Config bigcache.Config
}

BigCache primary struct with bigcache pointer and config

func (*BigCache) Init

func (b *BigCache) Init() error

Init creates a new Allegro BigCache based on b.Config

type DiskCache

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

DiskCache primary struct with an array of diskCache (key:filename) and the primary directory

func New

func New() *DiskCache

New creates a new DiskCache using the tmp directory

func (*DiskCache) Get

func (D *DiskCache) Get(key string) (any, error)

Get the data pointed to by a key

func (*DiskCache) Set

func (D *DiskCache) Set(key string, data any) error

Set some data to a given key

type MemCache

type MemCache struct {
	Client     *cache.Client
	Algorithm  memory.Algorithm
	Capacity   int
	RefreshKey string
	// contains filtered or unexported fields
}

MemCache primary struct for victorspringers http-cache

func NewMemCache

func NewMemCache(algorithm memory.Algorithm, capacity int, refreshKey string, cacheTime time.Duration) MemCache

NewMemCache creates a new MemCache instance

func (*MemCache) Init

func (m *MemCache) Init() error

Init starts our in-memory cache.

func (*MemCache) String

func (m *MemCache) String() string

type Memory added in v1.5.6

type Memory struct {
	Config memoryConfig
	// contains filtered or unexported fields
}

func NewMemoryCache added in v1.5.6

func NewMemoryCache(capacity int64, expiry string) *Memory

func (*Memory) Get added in v1.5.6

func (m *Memory) Get(key uint64) (any, bool)

func (*Memory) Release added in v1.5.6

func (m *Memory) Release(key uint64)

func (*Memory) Set added in v1.5.6

func (m *Memory) Set(key uint64, value any, expiration time.Time)

Jump to

Keyboard shortcuts

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