cache

package
v5.0.0-...-ad4f444 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: AGPL-3.0 Imports: 3 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 {
	Get(key string, value interface{}) (ok bool)
	GetBytes(key string) (value []byte, ok bool)
	Set(key string, value interface{}) error
	SetWithExpiry(key string, value interface{}, duration time.Duration) error
	Delete(k string) error
	Reset() error
	Exists(key string) (ok bool)
	KeysByPrefix(prefix string) ([]string, error)
	Iterate(it func(key string, val interface{})) error
	Close(ctx context.Context) error
}

func MustDiscard

func MustDiscard() Cache

MustDiscard opens a discard-cache that can be used as fallback for openCache-related errors

type Config

type Config struct {
	// Cache identifier, should be always set
	Prefix string
	// Eviction is a golang duration expressed as string ("10s", "1m", etc...). Using -1 means no expiration
	Eviction string
	// CleanWindow may be used by caches to trigger expired keys cleaning
	CleanWindow string
	// DiscardFallback switches to a "no-op" cache if the cache opening fails
	DiscardFallback bool
}

Config holds cache configurations

type Option

type Option func(o *Options)

func WithCleanWindow

func WithCleanWindow(t time.Duration) Option

func WithEviction

func WithEviction(t time.Duration) Option

type Options

type Options struct {
	EvictionTime time.Duration
	CleanWindow  time.Duration
}

type URLOpener

type URLOpener openurl.URLOpener[Cache]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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