redis

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: Zlib Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultExpiration = 5 * time.Minute

Variables

View Source
var (
	// UseRedis indicates whether to use redis.
	UseRedis bool
)

Functions

func Add

func Add(key string, value any) error

Add adds a key/value pair to the redis only if the key doesn't already exist, or if the key has expired. Returns an error otherwise.

func Delete

func Delete(key string)

Delete deletes a key/value pair by key from the redis whether it exists or not.

func Get

func Get(key string) (any, bool)

Get gets a value by key from the redis. It returns the value and a boolean indicating whether the key was found in the redis.

func Set

func Set(key string, value any)

Set sets a key/value pair in the reids. If the key already exists, it will be overwritten.

func SetWithExpiration

func SetWithExpiration(key string, value any, expiration time.Duration)

SetWithExpiration sets a key/value pair in the reids with a given expiration. If the key already exists, it will be overwritten. If expiration is 0, the default expiration time will be used.

Types

This section is empty.

Jump to

Keyboard shortcuts

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