redis

package
v0.0.0-...-9132bf9 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionPrefix          = "wpmanage." // SessionPrefix 工作手机团队session前缀(所有团队要统一)
	LRUCachePrefix         = "lru."      // LRUCachePrefix lru缓存前缀
	FIFOCachePrefix        = "fifo."     // FIFOCachePrefix fifo缓存前缀
	SessionForMobilePrefix = "wpapp."    // SessionForMobilePrefix 工作手机团队session前缀(所有团队要统一)
)

Prefix 缓存前缀配置(一级命名空间管理,放在底层package中,方式各自维护各自的导致命名空间冲突)

View Source
const (
	MINUTE   = 60          // 分钟
	HOUR     = MINUTE * 60 // 小时
	HALFHOUR = MINUTE * 30 // 半小时
	DAY      = HOUR * 24   // 天

	LRUDuration      = MINUTE * 10 // lru持续时间
	LRUDurationByDay = DAY * 10    // lru持续时间 day

	FIFODuration = MINUTE * 10 // fifo缓存持续时间
)

time 缓存时间配置

Variables

This section is empty.

Functions

func Client

func Client(name ClientName) *redis.Client

Client 根据name获取客户端连接

func ConvertStringToMap

func ConvertStringToMap(base map[string]string) map[string]interface{}

ConvertStringToMap 转换从redis获取的数据

func InitClient

func InitClient(config *Config) (*redis.Client, error)

InitClient 初始化连接

Types

type Cao

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

Cao 缓存访问结构

func NewCao

func NewCao(client *redis.Client) *Cao

NewCao 创建新的缓存访问对象

func (*Cao) Del

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

Del Del

func (*Cao) DelPipeline

func (c *Cao) DelPipeline(keys []string) error

DelPipeline 批量删除

func (*Cao) DelPipelined

func (c *Cao) DelPipelined(keys []string) error

DelPipelined 批量删除

func (*Cao) Expire

func (c *Cao) Expire(key string, extime int64) error

Expire 过期

func (*Cao) ExpireAt

func (c *Cao) ExpireAt(key string, ex time.Time) error

ExpireAt 设置过期时间

func (*Cao) Get

func (c *Cao) Get(key string) (string, error)

Get 获取redis缓存

func (*Cao) HDel

func (c *Cao) HDel(key string, fields string) error

HDel Hdel

func (*Cao) HGet

func (c *Cao) HGet(key string, field string) (string, error)

HGet Hget

func (*Cao) HGetAll

func (c *Cao) HGetAll(key string) map[string]interface{}

HGetAll 获取全部

func (*Cao) HGetJSON

func (c *Cao) HGetJSON(key, field string, T interface{}) error

HGetJSON HGetJSON

func (*Cao) HMSet

func (c *Cao) HMSet(key string, fields map[string]interface{}) error

HMSet HMSet

func (*Cao) HSet

func (c *Cao) HSet(key string, field string, value interface{}) error

HSet Hset

func (*Cao) HSetJSON

func (c *Cao) HSetJSON(key, field string, value interface{}) error

HSetJSON HSet for json

func (*Cao) Keys

func (c *Cao) Keys(pattern string) ([]string, error)

Keys Keys

func (*Cao) Scan

func (c *Cao) Scan(cursor uint64, match string, count int64) ([]string, uint64, error)

Scan Scan

func (*Cao) Set

func (c *Cao) Set(key string, value string) error

Set 设置

func (*Cao) SetByTTL

func (c *Cao) SetByTTL(key string, value string, extime int64) error

SetByTTL 设置 带有有效时间

func (*Cao) SetTTL

func (c *Cao) SetTTL(key string, extime int64) error

SetTTL SetTTL

type ClientName

type ClientName string

ClientName redis连接名称

const (
	MKSession ClientName = "session"
	MKCache   ClientName = "cache"
)

ClientName redis连接名称

type Config

type Config struct {
	ClientName ClientName
	Addr       string // redis addr,例如 127.0.0.1:6379
	Password   string // redis password
	DB         int    // redis db
	PoolSize   int    // redis poolsize
}

Config redis配置结构

Jump to

Keyboard shortcuts

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