cache

package module
v0.0.0-...-da3cc26 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 1 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get retrieves the value associated with the given key.
	Get(key string) (string, error)
	// Set sets the value associated with the given key and expiration time.
	Set(key string, value string, expire time.Duration) error
	// Load loads the value associated with the given key.
	// If the value is not found, the loader function is called to load the value and store it in the cache.
	Load(key string, loader func() (value string, err error), expire time.Duration) (string, error)
	// Delete deletes the value associated with the given key.
	Delete(key string) error
	// Has checks if the cache has the given key.
	Has(key string) bool
	// Clear clears the cache.
	Clear() error
}

Cache is an interface for caching data.

type CacheManager

type CacheManager interface {
	Cache
	SetDefaultStore(name string)
	HasStore(name string) bool
	AddStore(name string, store Cache)
	GetStore(name string) Cache
}

type Driver

type Driver interface {
	// Open opens the cache driver.
	Open(config map[string]any) (Cache, error)
}

Driver is an interface for cache drivers.

Jump to

Keyboard shortcuts

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