cache

package
v0.9.9-rc5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 5 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 is a struct that holds the context, options, and the client for a Redis database.

func New

func New(ctx context.Context, opts options.Cache) (*Redis, error)

New creates a new Redis client with the provided context and options. It returns a pointer to the Redis struct and an error if any occurred during the creation of the client.

func (*Redis) Exists

func (r *Redis) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists in the Redis database. It returns a boolean indicating the existence of the key and an error if any occurred during the check.

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves the value of a key from the Redis database. It returns the value as a byte slice and an error if any occurred during the retrieval.

func (*Redis) GetClient

func (r *Redis) GetClient() *redis.Client

GetClient returns the Redis client.

func (*Redis) ValidateOptions

func (r *Redis) ValidateOptions() error

ValidateOptions checks the validity of the options used to create a Redis client. It returns an error if any of the options are invalid.

func (*Redis) Write

func (r *Redis) Write(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Write sets the value of a key in the Redis database with an optional expiration duration. It returns an error if any occurred during the write operation.

Jump to

Keyboard shortcuts

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