cache

package
v0.0.0-...-7360598 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const CacheMissError = "not found"

CacheMissError is the generic error text for a cache miss

Variables

This section is empty.

Functions

This section is empty.

Types

type ICache

type ICache interface {
	Init(interface{}) error
	Get(string) (interface{}, error)
	Set(string, interface{}) error
	SetWithCustomExpiration(string, interface{}, time.Duration) error
	Delete(string) error
}

ICache is an interface for a pluggable cache

type InMemoryCache

type InMemoryCache struct {
	Cache *cache.Cache
}

InMemoryCache is a cache running in memory, not shared between any nodes

func (*InMemoryCache) Delete

func (c *InMemoryCache) Delete(key string) error

Delete removes a key If the key is not present, this is a no-op

func (*InMemoryCache) Get

func (c *InMemoryCache) Get(key string) (any, error)

Get retrieves an item by key

func (*InMemoryCache) Init

func (c *InMemoryCache) Init(_ any) error

Init initializes the in memory cache

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(key string, item any) error

Set adds or updates a key

func (*InMemoryCache) SetWithCustomExpiration

func (c *InMemoryCache) SetWithCustomExpiration(key string, item any, expiration time.Duration) error

SetWithCustomExpiration adds or updates a key with an expiration time other than the default

Jump to

Keyboard shortcuts

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