redis

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*redis.Client
}

func NewRedisClient

func NewRedisClient(cfg Config) (*Client, error)

NewRedisClient 简化了 GET SET DEL 操作

func (*Client) Del

func (c *Client) Del(key string) error

func (*Client) DelContext

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

func (*Client) Get

func (c *Client) Get(key string) (interface{}, error)

Get return String value

func (*Client) GetContext

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

func (*Client) Set

func (c *Client) Set(key string, value interface{}) error

func (*Client) SetContext

func (c *Client) SetContext(ctx context.Context, key string, value interface{}, expiration time.Duration) error

func (*Client) SetWithTTL

func (c *Client) SetWithTTL(key string, value interface{}, expiration time.Duration) error

type ClusterClient

type ClusterClient struct {
	*redis.ClusterClient
}

func NewRedisClusterClient

func NewRedisClusterClient(config ClusterConfig) (*ClusterClient, error)

type ClusterConfig

type ClusterConfig struct {
	Addrs []string
	Options
}

type Config

type Config struct {
	Addr string `defval:"127.0.0.1:6379"`
	DB   int    `defval:"0"`
	Options
}

type Options

type Options struct {
	Username string `defval:"root"`
	Password string `defval:"111111" null:""`
	// 最大重试 -1 不重试 默认值 单实例 0 集群 8
	MaxRetries int
	// 超时
	DialTimeout  time.Duration `defval:"60s"`
	ReadTimeout  time.Duration `defval:"300s"`
	WriteTimeout time.Duration `defval:"300s"`
}

Jump to

Keyboard shortcuts

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