cache

package
v0.0.0-...-b11ff8e Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Redis

type Redis struct {
	// contains filtered or unexported fields
}

Redis creates and manages the redis connection information

func (*Redis) AddCache

func (r *Redis) AddCache(key string, data any, expiration time.Duration) (string, error)

AddCache inserts an object into the cache

func (*Redis) CacheExists

func (r *Redis) CacheExists(key string) (bool, error)

CacheExists retrieve an object from the cache

func (*Redis) Connect

func (r *Redis) Connect() error

Connect to the redis server

func (*Redis) Disconnect

func (r *Redis) Disconnect() error

Disconnect from the redis server

func (*Redis) GetConfig

func (r *Redis) GetConfig() RedisConfig

GetConfig get the redis config

func (*Redis) Init

func (r *Redis) Init(database int) (*Redis, error)

Init create a new redis manager with a given config

func (*Redis) RemoveCache

func (r *Redis) RemoveCache(key string) error

RemoveCache inserts an object into the cache

func (*Redis) RemoveKeyLock

func (r *Redis) RemoveKeyLock(key string) error

RemoveKeyLock irequests to use a key for locking purposes Will return false if the key lock already exists

func (*Redis) RequestKeyLock

func (r *Redis) RequestKeyLock(key string, expiration time.Duration) (bool, error)

RequestKeyLock irequests to use a key for locking purposes Will return false if the key lock already exists

func (*Redis) RetrieveCache

func (r *Redis) RetrieveCache(key string, result any) error

RetrieveCache retrieve an object from the cache

type RedisConfig

type RedisConfig struct {
	Host string
	Pass string
}

RedisConfig configuration structure for the redis connection

func (*RedisConfig) FromEnv

func (r *RedisConfig) FromEnv() (*RedisConfig, error)

FromEnv creates a nats config using environmental variables

func (*RedisConfig) IsSet

func (r *RedisConfig) IsSet() bool

IsSet checks if the configuration has been set Note: All fields required

Jump to

Keyboard shortcuts

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