cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendConfig

type BackendConfig struct {
	// Base redis connection options
	RedisOptions *redis.Options
}

type Cache

type Cache interface {
	Set(ctx context.Context, key string, value []byte, expiration time.Duration) error
	BulkSet(ctx context.Context, entries ...CacheEntry) error
	Remove(ctx context.Context, keys ...string) error
	Get(ctx context.Context, key string) ([]byte, error)
	BulkGet(ctx context.Context, keys ...string) ([][]byte, error)
	Has(ctx context.Context, key string) (bool, error)

	Shutdown(ctx context.Context) error
}

func New

func New(url string) (Cache, error)

Creates new cache instance and initializes tracing

type CacheEntry

type CacheEntry struct {
	// Key under wich to store data
	Key string
	// Stored data
	Value []byte
	// After what time in miliseconds, cache entry should be deleted. Use 0 if you want this entry last as long as possible
	Timeout time.Duration
}

Jump to

Keyboard shortcuts

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