cache

package
v0.0.0-...-f856108 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const RedisHost = "192.168.10.27:6379"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(key string) interface{}
	Set(key string, val interface{}, timeout time.Duration) error
	IsExist(key string) bool
	Delete(key string) error
}

TheCache interface

type Redis

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

Redis redis

func NewRedis

func NewRedis(opts *RedisOpts) *Redis

NewRedis 实例化

func (*Redis) Delete

func (r *Redis) Delete(key string) error

Delete 删除

func (*Redis) Get

func (r *Redis) Get(key string) interface{}

Get 获取一个值

func (*Redis) IsExist

func (r *Redis) IsExist(key string) bool

IsExist 判断key是否存在

func (*Redis) ListIndex

func (r *Redis) ListIndex(key string, index int) (item string, err error)

func (*Redis) ListLRange

func (r *Redis) ListLRange(key string, start, end int) (strArray []string, err error)

func (*Redis) ListLen

func (r *Redis) ListLen(key string) (length int, err error)

func (*Redis) ListMaxLenRPush

func (r *Redis) ListMaxLenRPush(key string, val interface{}, maxLen int) (err error)

func (*Redis) ListRPush

func (r *Redis) ListRPush(key string, val interface{}) (err error)

/////////////////////////////////////////////////////////////////////////////////////////////////

func (*Redis) Set

func (r *Redis) Set(key string, val interface{}, timeout time.Duration) (err error)

func (*Redis) SetEX

func (r *Redis) SetEX(key string, val interface{}, timeout time.Duration) (err error)

Set 设置一个值

type RedisOpts

type RedisOpts struct {
	Host        string `yml:"host" json:"host"`
	Password    string `yml:"password" json:"password"`
	Database    int    `yml:"database" json:"database"`
	MaxIdle     int    `yml:"max_idle" json:"max_idle"`
	MaxActive   int    `yml:"max_active" json:"max_active"`
	IdleTimeout int32  `yml:"idle_timeout" json:"idle_timeout"` //second
}

RedisOpts redis 连接属性

Jump to

Keyboard shortcuts

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