cache

package
v0.0.0-...-680f63d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoExpiration      = gocache.NoExpiration
	DefaultExpiration = gocache.DefaultExpiration
)

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
	ErrRead     = errors.New("could not read value at cache key")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get gets the cache value as an byte array
	Get(ctx context.Context, key string) ([]byte, error)

	// Set saves the value as an byte array. if `expire` is set to zero it will use the cache default expiration time.
	Set(ctx context.Context, key string, value []byte, expire time.Duration) error

	// Delete object from cache
	Delete(ctx context.Context, key string) error
}

Cache allows the caller to set, get and delete items in the cache.

type Config

type Config struct {
	Expiry          time.Duration
	CleanupInterval time.Duration
}

type LocalCache

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

func NewLocalCache

func NewLocalCache(cfg Config) *LocalCache

func (*LocalCache) Delete

func (lc *LocalCache) Delete(ctx context.Context, key string) error

func (*LocalCache) Get

func (lc *LocalCache) Get(ctx context.Context, key string) ([]byte, error)

func (*LocalCache) Set

func (lc *LocalCache) Set(ctx context.Context, key string, data []byte, exp time.Duration) error

Jump to

Keyboard shortcuts

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