redix

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EXPIRE 过期时间
	EXPIRE = "expire"
	// NX 如果不存在,则 SET
	NX = "nx"
	// XX 如果存在,则 SET
	XX = "xx"
)

Variables

This section is empty.

Functions

func Init

func Init()

Init 初始化Redis

func RegisterRedis

func RegisterRedis()

RegisterRedis 注册

Types

type Config

type Config struct {
	Name     string `mapstructure:"name"`
	Conn     string `mapstructure:"conn"`
	Password string `mapstructure:"password"`
	Timeout  int    `mapstructure:"timeout"`
	DB       int    `mapstructure:"db"`
}

Config Redis配置信息

type Iterator

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

Iterator 迭代器

func NewIterator

func NewIterator(data []interface{}) *Iterator

NewIterator 创建新的迭代器

func (*Iterator) HasNext

func (i *Iterator) HasNext() bool

HasNext 是否有下一个值

func (*Iterator) Next

func (i *Iterator) Next() (res interface{})

Next 返回下一个值

type MResult

type MResult struct {
	Value []interface{}
	Error error
}

MResult 列表查询结果

func NewMResult

func NewMResult(value []interface{}, error error) *MResult

NewMResult 新建列表查询结果

func (*MResult) Iterator

func (m *MResult) Iterator() *Iterator

Iterator 列表迭代器

func (*MResult) Result

func (m *MResult) Result(v []interface{}) []interface{}

Result 返回列表查询结果的值

type Operation

type Operation struct {
	Name  string
	Value interface{}
}

Operation 操作配置

func WithExpire

func WithExpire(t int) *Operation

WithExpire 具备超时

func WithNX

func WithNX() *Operation

WithNX 具备不存在写入

func WithXX

func WithXX() *Operation

WithXX 具备存在写入

type Operations

type Operations []*Operation

Operations 操作数组

func (Operations) Find

func (c Operations) Find(name string) *Result

Find 根据名称返回结果

type RedisClient

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

RedisClient Redis客户端

func DB

func DB(name string) *RedisClient

DB 根据名称获取数据库连接

func (*RedisClient) Del added in v0.2.0

func (c *RedisClient) Del(key string) *Result

Del 删除key

func (*RedisClient) Get

func (c *RedisClient) Get(key string) *Result

Get 返回与键 key 相关联的字符串值

func (*RedisClient) Inrc added in v0.2.7

func (c *RedisClient) Inrc(key string) *Result

Inrc 数字加一

func (*RedisClient) Lock added in v0.2.1

func (c *RedisClient) Lock(key string, acquire, timeout time.Duration) (string, error)

Lock 分布式锁

func (*RedisClient) MGet

func (c *RedisClient) MGet(key string) *MResult

MGet 返回包含了所有给定键的值的列表

func (*RedisClient) Set

func (c *RedisClient) Set(key string, value interface{}, ops ...*Operation) *Result

Set 将字符串值 value 关联到 key

func (*RedisClient) UnLock added in v0.2.1

func (c *RedisClient) UnLock(key, code string) bool

UnLock 释放分布式锁

type Result

type Result struct {
	Value interface{}
	Error error
}

Result 查询结果

func NewResult

func NewResult(value interface{}, error error) *Result

NewResult 新建查询结果

func (*Result) Result

func (c *Result) Result(v ...interface{}) interface{}

Result 返回查询结果的值

Jump to

Keyboard shortcuts

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