redis

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 4 Imported by: 5

Documentation

Overview

Package redis is a wrapper of the original "github.com/redis/go-redis" library.

Only contains basic get, set, delete, and close methods.

Data will be encoded to JSON before saving to cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is redis client.

func New

func New(address, password string, expiredTime time.Duration) (*Client, error)

New to create cache cache with default config.

func NewFromGoRedis

func NewFromGoRedis(client *redis.Client, expiredTime time.Duration) *Client

NewFromGoRedis to create cache from go-redis client.

func NewWithConfig

func NewWithConfig(option redis.Options, expiredTime time.Duration) (*Client, error)

NewWithConfig to create cache from go-redis options.

func (*Client) Close

func (c *Client) Close() error

Close to close cache connection.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) error

Delete to delete data from cache.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string, data interface{}) error

Get to get data from cache.

func (*Client) Set

func (c *Client) Set(ctx context.Context, key string, data interface{}, ttl ...time.Duration) error

Set to save data to cache,

Jump to

Keyboard shortcuts

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