cache

package
v0.7.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("key not found")
	ErrMaxItems = errors.New("max items reached")
)

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	Get(string) (any, bool)
	Set(string, any)
	Len() int
	SetWithTTL(string, any, time.Duration)
	Delete(string) bool
}

type BucketOptions

type BucketOptions struct {
	// TTL is the time after which the key will be deleted from the cache.
	DefaultTTL time.Duration
	// MaxItems is the maximum number of items that can be stored in the cache.
	// If set to 0, there is no limit.
	MaxItems int
}

type CacheOptions

type CacheOptions struct {
	CheckInterval time.Duration
	Logger        *zerolog.Logger
}

type TCache

type TCache interface {
	Bucket(string) Bucket
	BucketWithOpts(string, BucketOptions) Bucket
}

func New

func New() TCache

func NewWithOpts

func NewWithOpts(opts CacheOptions) TCache

Jump to

Keyboard shortcuts

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