cache

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverMemory = "memory"
	DriverRedis  = "redis"

	NoExpiration = -1 * time.Second
)

Variables

View Source
var (
	// ErrInvalidCacheDriver is returned when an invalid cache driver is provided
	ErrInvalidCacheDriver = errors.New("invalid cache driver")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get returns the value for the given key
	// returns the value if the key was found
	// returns an error if the key was not found
	Get(ctx context.Context, key string) (interface{}, error)

	// Set sets the value for the given key
	// returns nil if the key was set successfully
	// returns an error if the key was not set successfully
	Set(ctx context.Context, key string, value string, ttl time.Duration) error

	// Delete deletes the value for the given key
	// returns nil if the key was deleted successfully
	// returns an error if the key was not deleted successfully
	Delete(ctx context.Context, key string) error
}

Cache implements a generic interface for cache clients

func New

func New(config *Config) (Cache, error)

New returns a new cache client

type Config

type Config struct {
	// Driver is the type of cache client
	Driver string

	// InMemory is the configuration for the inmemory cache client
	InMemory *inmemory.Config

	// Redis is the configuration for the redis client
	Redis *redis.Config
}

Config is the configuration for the cache client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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