cache

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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