redis

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package redis is a simple redis cache implement. base on the package: github.com/gomodule/redigo

Example
// init  driver
c := Connect("127.0.0.1:6379", "", 0)

// set
_ = c.Set("name", "cache value", 60)

// get
val := c.Get("name")

// del
_ = c.Del("name")

// get: "cache value"
fmt.Print(val)
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisCache

type RedisCache struct {
	Debug bool
	// key prefix
	Prefix string
	Logger *log.Logger
	// contains filtered or unexported fields
}

RedisCache definition. redigo doc link: https://godoc.org/github.com/gomodule/redigo/redis

func Connect

func Connect(url, pwd string, dbNum int) *RedisCache

Connect create and connect to redis server

func New

func New(url, pwd string, dbNum int) *RedisCache

New redis cache

func (*RedisCache) Clear

func (c *RedisCache) Clear() error

Clear all caches

func (*RedisCache) Close

func (c *RedisCache) Close() error

Close connections

func (*RedisCache) Connect

func (c *RedisCache) Connect() *RedisCache

Connect to redis server

func (*RedisCache) Del

func (c *RedisCache) Del(key string) (err error)

Del value by key

func (*RedisCache) DelMulti

func (c *RedisCache) DelMulti(keys []string) (err error)

DelMulti values by keys

func (*RedisCache) Get

func (c *RedisCache) Get(key string) interface{}

Get value by key

func (*RedisCache) GetMulti

func (c *RedisCache) GetMulti(keys []string) map[string]interface{}

GetMulti values by keys

func (*RedisCache) Has

func (c *RedisCache) Has(key string) bool

Has cache key

func (*RedisCache) Key

func (c *RedisCache) Key(key string) string

Key build

func (*RedisCache) LastErr

func (c *RedisCache) LastErr() error

LastErr get

func (*RedisCache) Pool

func (c *RedisCache) Pool() *redis.Pool

Pool get

func (*RedisCache) Set

func (c *RedisCache) Set(key string, val interface{}, ttl time.Duration) (err error)

Set value by key

func (*RedisCache) SetMulti

func (c *RedisCache) SetMulti(values map[string]interface{}, ttl time.Duration) (err error)

SetMulti values

func (*RedisCache) String

func (c *RedisCache) String() string

String get

Jump to

Keyboard shortcuts

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