redistools

package module
v0.0.0-...-7110956 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2020 License: MIT Imports: 3 Imported by: 0

README

redistools redis tool

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DEFAULT = time.Duration(0)  // 过期时间 不设置
	FOREVER = time.Duration(-1) // 过期时间不设置
)

Functions

This section is empty.

Types

type Cache

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

func NewRedisCache

func NewRedisCache(db int, host string, defaultExpiration time.Duration) Cache

返回cache 对象, 在多个工具之间建立一个 中间初始化的时候使用

func (Cache) Delete

func (c Cache) Delete(keys ...interface{}) (bool, error)

删除指定的键

func (Cache) Exist

func (c Cache) Exist(name string) (bool, error)

判断所在的 key 是否存在

func (Cache) Expire

func (c Cache) Expire(name string, newSecondsLifeTime int64) error

设置过期时间 (单位 秒)

func (Cache) Get

func (c Cache) Get(name string) ([]byte, error)

获取 字符串类型的值

func (Cache) HExists

func (c Cache) HExists(name, field string) (bool, error)

查看hash 中指定是否存在

func (Cache) HGet

func (c Cache) HGet(name, field string) (value []byte, err error)

获取单个hash 中的值

func (Cache) HLen

func (c Cache) HLen(name string) (int, error)

获取hash 的键的个数

func (Cache) HMSet

func (c Cache) HMSet(name string, obj interface{}) (err error)

设置多个值 , obj 可以是指针 slice map struct

func (Cache) HMget

func (c Cache) HMget(name string, fields ...string) ([]interface{}, error)

传入的 字段列表获得对应的值

func (Cache) HSet

func (c Cache) HSet(name string, key string, v []byte) (err error)

设置单个值, value 还可以是一个 map slice 等

func (Cache) Hdel

func (c Cache) Hdel(name, key string) (bool, error)

////////////////// hash /////////// 删除指定的 hash 键

func (Cache) ScardInt64s

func (c Cache) ScardInt64s(name string) (int64, error)

获取集合中元素的个数

func (Cache) Set

func (c Cache) Set(name string, v []byte) error

string 类型 添加, v 可以是任意类型

func (Cache) Smembers

func (c Cache) Smembers(name string) (byt []byte, err error)

获取 set 集合中所有的元素, 想要什么类型的自己指定

func (Cache) StrLen

func (c Cache) StrLen(name string) (int, error)

查看指定的长度

func (Cache) StringIncr

func (c Cache) StringIncr(name string) (int, error)

自增

Jump to

Keyboard shortcuts

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