redis

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

读取redis.yaml配置文件

可直接使用基本调用 复杂调用需自定义

可自定义连接返回实例

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

func Del

func Del(key string) error

Del 删除

func Expire

func Expire(key string, second int)

func Get

func Get(key string) (string, bool, error)

func HDel

func HDel(key string, field string) (int64, error)

func HGetAll

func HGetAll(key string) (map[string]string, error)

func HGetFieldValue

func HGetFieldValue(key string, field string) (string, error)

func HIncrBy

func HIncrBy(key string, field string, incr int64) (int64, error)

func HSet

func HSet(key string, value any, second int) error

func HSetNX

func HSetNX(key string, field string, value any) error

func IsExists

func IsExists(key string) bool

func KeyPrefix

func KeyPrefix() string

KeyPrefix 前缀配置

func Set

func Set(key string, value string, second int) error

func TTL

func TTL(key string) (float64, error)

Types

type Client

type Client struct {
	*redis.Client
}

func NewClient

func NewClient(host, port, name, pass string, db int) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Del

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

func (*Client) Expire

func (c *Client) Expire(key string, second int)

func (*Client) Get

func (c *Client) Get(key string) (string, bool, error)

Get bool表示是否存在该key

func (*Client) HDel

func (c *Client) HDel(key string, field string) (int64, error)

func (*Client) HGetAll

func (c *Client) HGetAll(key string) (map[string]string, error)

HGetAll 获取hash列表中的所有键值对

func (*Client) HGetFieldValue

func (c *Client) HGetFieldValue(key string, field string) (string, error)

func (*Client) HIncrBy

func (c *Client) HIncrBy(key string, field string, incr int64) (int64, error)

HIncrBy hash表字段值 增减

func (*Client) HSet

func (c *Client) HSet(key string, value any, second int) error

HSet hash表 any可为slice[成对] map等类型 当second=0时无过期时间

func (*Client) HSetNX

func (c *Client) HSetNX(key string, field string, value any) error

HSetNX hash表增加一个键值对

func (*Client) IsExists

func (c *Client) IsExists(key string) bool

func (*Client) Set

func (c *Client) Set(key string, value string, second int) error

Set 0-second表示为没有过期时间

func (*Client) TTL

func (c *Client) TTL(key string) (float64, error)

TTL 获取剩余时间

type Config

type Config struct {
	Host   string `yaml:"host"`
	Port   string `yaml:"port"`
	User   string `yaml:"user"`
	Pass   string `yaml:"pass"`
	DB     int    `yaml:"db"`
	Prefix string `yaml:"prefix"`
}

Config redis配置文件结构

var Conf *Config //redis配置信息

Jump to

Keyboard shortcuts

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