cache

package
v6.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cache contains provider's cache instance

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDisabled is returned when Get or Set is called on a disabled cache
	ErrDisabled = errors.New("cache disabled")
	// ErrEntryNotFound is returned when object under the given key does not exist
	ErrEntryNotFound = errors.New("cache entry not found")
)

Functions

func Enable

func Enable(enabled bool)

Enable is used to enable or disable cache

func Get

func Get(bucket Bucket, key string, out any) error

Get returns value stored under the key from cache and writes it into out

func IsEnabled

func IsEnabled() bool

IsEnabled returns whether cache is enabled

func Set

func Set(bucket Bucket, key string, val any) error

Set sets the given value under the key in cache

Types

type Bucket

type Bucket interface {
	Name() string
}

Bucket defines a contract for a bucket used to form a key

type BucketName

type BucketName string

BucketName can be used as a bucket argument to Set and Get functions

func (BucketName) Name

func (b BucketName) Name() string

Name returns BucketID as a string

Jump to

Keyboard shortcuts

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