redis

package
v0.0.0-...-fb81480 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package redis provides a Redis-based caching implementation for the application. It includes functionality to store and retrieve data in a Redis cache.

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 represents a Redis cache client. It includes the Redis client and cache expiry time.

func New

func New(ctx context.Context, cfg *configs.ServerConfig) (*Redis, error)

New initializes a new Redis cache client using the provided server configuration. It returns a Redis instance or an error if the connection to Redis fails.

func (*Redis) Get

func (c *Redis) Get(ctx context.Context, key string, v any) error

Get retrieves data from the Redis cache using the specified key. It deserializes the cached data from JSON format into the provided value.

func (*Redis) Set

func (c *Redis) Set(ctx context.Context, key string, data any) error

Set stores data in the Redis cache under the specified key. It serializes the data into JSON format and sets the expiration time based on the Redis's expiry.

Jump to

Keyboard shortcuts

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