dao

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GinSessionOk = Status(iota)
	GinSessionOld
	GinSessionTimeout
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Keeper

type Keeper interface {
	//首先, 执行expire 刷新key的存活时间如果失败说明该key已经超时失效
	//expire 执行成功后, 再执行Get获取magic进行校验
	Check(key, magic string, expiration time.Duration) (Status, error)
	//Peek不会刷新key的存活时间, 直接执行Get获取magic进行校验, 需要同步返回true, 不需要返回false
	Peek(key, magic string) (bool, error)
	//执行Pull函数时, 肯定校验过, Key的存活时间已经被刷新过了, 不用担心key已经超时的问题, 直接HMGet拉取数据
	Pull(key string) (magic string, dataMap map[string]string, err error)
	//首先,执行HMSet写入数据, redis set后默认key的存活时间为永久
	//然后,expire 设置key的存活时间
	Push(key string, magic string, dataMap map[string]string, expiration time.Duration) error
	//关闭redis-client
	Done() error
}

type Redis

type Redis struct {
	*redis.Client
}

func DefaultRedis

func DefaultRedis(addr, password string, db int) (r Redis, err error)

func (Redis) Check

func (r Redis) Check(key string, magic string, expiration time.Duration) (status Status, err error)

func (Redis) Done

func (r Redis) Done() (err error)

func (Redis) Peek

func (r Redis) Peek(key, magic string) (different bool, err error)

func (Redis) Pull

func (r Redis) Pull(key string) (magic string, dataMap map[string]string, err error)

func (Redis) Push

func (r Redis) Push(key string, magic string, dataMap map[string]string, expiration time.Duration) (err error)

type Status

type Status int

func (Status) String

func (s Status) String() (str string)

Jump to

Keyboard shortcuts

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