cache

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Set adds item to cache replacing existing one
	Set(
		cx context.Context,
		kye string,
		val []byte,
	)

	// Add adds item to cache only if the item doesn't exist or
	// the key has expired. It won't remove an active existing value
	Add(
		cx context.Context,
		key string,
		val []byte,
	) error

	// Replace an item if it exists
	Replace(
		cx context.Context,
		key string,
		val []byte,
	) error

	// SetWithDuration sets the key with a value for a time period
	SetWithDuration(
		cx context.Context,
		key string,
		val []byte,
		expiration time.Duration,
	)

	// Get returns the value for the key from the cache and sets found flag as
	// true or it returns false if the value is not found
	Get(
		cx context.Context,
		key string,
	) (val []byte, found bool)

	// Delete deletes the key from the cache, and doesn't do anything
	// if key is not found
	Delete(
		cx context.Context,
		key string,
	)
}

func NewInMemoryCache

func NewInMemoryCache(
	expiry time.Duration,
	eviction time.Duration,
	options ...inmem.Option,
) (Cache, error)

func NewRedisCache

func NewRedisCache(
	logger log.Logger,
	addr string,
	options ...redis.Option,
) (Cache, error)

Directories

Path Synopsis
Package inmem implements in-memory cache for storing data
Package inmem implements in-memory cache for storing data

Jump to

Keyboard shortcuts

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