Help us shape the future of Go! Take the 2026 Go Developer Survey

redis

package
v1.7.12 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ZeroInt64 int64 = 0
)

Functions

This section is empty.

Types

type RedisCache

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

RedisCache is redis cache adapter. it contains serverIp for redis conn.

func NewRedisCache

func NewRedisCache(serverURL string) *RedisCache

NewRedisCache returns a new *RedisCache.

func (*RedisCache) ClearAll

func (ca *RedisCache) ClearAll() error

ClearAll will delete all item in redis cache. never error

func (*RedisCache) Decr

func (ca *RedisCache) Decr(key string) (int64, error)

Decr decrease counter in redis cache.

func (*RedisCache) Delete

func (ca *RedisCache) Delete(key string) error

Delete item in redis cacha. if not exists, we think it's success

func (*RedisCache) Exists

func (ca *RedisCache) Exists(key string) (bool, error)

Exists check item exist in redis cache.

func (*RedisCache) Get

func (ca *RedisCache) Get(key string) (interface{}, error)

Get cache from redis cache. if non-existed or expired, return nil.

func (*RedisCache) GetInt

func (ca *RedisCache) GetInt(key string) (int, error)
returns value int format by given key

if non-existed or expired, return nil.

func (*RedisCache) GetInt64

func (ca *RedisCache) GetInt64(key string) (int64, error)
returns value int64 format by given key

if non-existed or expired, return nil.

func (*RedisCache) GetString

func (ca *RedisCache) GetString(key string) (string, error)
returns value string format by given key

if non-existed or expired, return "".

func (*RedisCache) Incr

func (ca *RedisCache) Incr(key string) (int64, error)

Incr increase int64 counter in redis cache.

func (*RedisCache) Set

func (ca *RedisCache) Set(key string, value interface{}, ttl int64) error

Set cache to redis. ttl is second, if ttl is 0, it will be forever.

Jump to

Keyboard shortcuts

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