redis

package
v0.0.0-...-61829c1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedisDo

func RedisDo(conn redis.Conn) func(cmd string, args ...interface{}) (interface{}, error)

Types

type Redis

type Redis struct {
	Name           string
	Protocol       string
	Host           string `conf:"upstream" validate:"@hostname"`
	Port           int
	Password       presets.Password `conf:"env" validate:"@string(0,)"`
	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
	IdleTimeout    time.Duration
	MaxActive      int
	MaxIdle        int
	Wait           bool
	DB             string
	// contains filtered or unexported fields
}

func (Redis) DockerDefaults

func (r Redis) DockerDefaults() conf.DockerDefaults

func (*Redis) GetCache

func (r *Redis) GetCache() *RedisCache

func (*Redis) Init

func (r *Redis) Init()

func (Redis) MarshalDefaults

func (r Redis) MarshalDefaults(v interface{})

func (*Redis) Prefix

func (r *Redis) Prefix(key string) string

func (*Redis) TopicFor

func (r *Redis) TopicFor(topic string, key string) string

type RedisCache

type RedisCache struct {
	Pool *redis.Pool // redis connection pool
}

Cache is Redis cache adapter.

func NewRedisCache

func NewRedisCache() *RedisCache

NewRedisCache create new redis cache with default collection name.

func (*RedisCache) Del

func (cache *RedisCache) Del(key string) error

func (*RedisCache) Exists

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

func (*RedisCache) Expire

func (cache *RedisCache) Expire(key string, timeout time.Duration) error

func (*RedisCache) Get

func (cache *RedisCache) Get(key string) ([]byte, error)

func (*RedisCache) GetInts

func (cache *RedisCache) GetInts(key string) ([]int, error)

func (*RedisCache) GetString

func (cache *RedisCache) GetString(key string) (string, error)

func (*RedisCache) GetStringMap

func (cache *RedisCache) GetStringMap(key string) (map[string]string, error)

func (*RedisCache) HGet

func (cache *RedisCache) HGet(key, field string) (interface{}, error)

func (*RedisCache) HGetAll

func (cache *RedisCache) HGetAll(key string) (interface{}, error)

func (*RedisCache) HGetInt64

func (cache *RedisCache) HGetInt64(key, field string) (int64, error)

func (*RedisCache) HGetString

func (cache *RedisCache) HGetString(key, field string) (string, error)

func (*RedisCache) HGetUint64

func (cache *RedisCache) HGetUint64(key, field string) (uint64, error)

func (*RedisCache) HIncrBy

func (cache *RedisCache) HIncrBy(key, field string, value interface{}) (int64, error)

func (*RedisCache) HMGet

func (cache *RedisCache) HMGet(key string, fields []string) (interface{}, error)

func (*RedisCache) HMset

func (cache *RedisCache) HMset(value []interface{}) (interface{}, error)

func (*RedisCache) HSet

func (cache *RedisCache) HSet(key, field string, value interface{}) (interface{}, error)

func (*RedisCache) HSetWithExpire

func (cache *RedisCache) HSetWithExpire(key string, timeout time.Duration) (interface{}, error)

func (*RedisCache) Incr

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

func (*RedisCache) LRange

func (cache *RedisCache) LRange(key string, start, end int) ([]interface{}, error)

func (*RedisCache) LRem

func (cache *RedisCache) LRem(key string, value interface{}) error

func (*RedisCache) MGet

func (cache *RedisCache) MGet(key []interface{}) (interface{}, error)

func (*RedisCache) MGetValue

func (cache *RedisCache) MGetValue(keys []interface{}) ([]interface{}, error)

func (*RedisCache) RPush

func (cache *RedisCache) RPush(key string, value interface{}) error

func (*RedisCache) RPushBatch

func (cache *RedisCache) RPushBatch(keys []interface{}) error

func (*RedisCache) SAdd

func (cache *RedisCache) SAdd(key string, items string) (int, error)

func (*RedisCache) SIsMember

func (cache *RedisCache) SIsMember(key string, items string) (int, error)

func (*RedisCache) Set

func (cache *RedisCache) Set(key string, bytes interface{}, timeout time.Duration) error

func (*RedisCache) SetNX

func (cache *RedisCache) SetNX(key string, value interface{}, expiration time.Duration) (bool, error)

Redis `SET key value [expiration] NX` command. Zero expiration means the key has no expiration time.

func (*RedisCache) Start

func (cache *RedisCache) Start(config *Redis) error

Start start redis cache adapter. config is like {"key":"collection key","conn":"connection info","dbNum":"0"} the cache item in redis are stored forever, so no gc operation.

func (*RedisCache) TTL

func (cache *RedisCache) TTL(key string) (int, error)

func (*RedisCache) ZAdd

func (cache *RedisCache) ZAdd(key string, value, member interface{}) (interface{}, error)

func (*RedisCache) ZRange

func (cache *RedisCache) ZRange(key string, start, end int, withscores bool) ([]string, error)

func (*RedisCache) ZRangeByScore

func (cache *RedisCache) ZRangeByScore(key string, min_num, max_num int64, withscores bool, offset, count int) ([]int, error)

func (*RedisCache) ZRangeInts

func (cache *RedisCache) ZRangeInts(key string, start, end int, withscores bool) ([]int, error)

func (*RedisCache) ZRevrange

func (cache *RedisCache) ZRevrange(key string, start, end int, withscores bool) ([]int, error)

func (*RedisCache) ZRevrangeByScore

func (cache *RedisCache) ZRevrangeByScore(key string, max_num, min_num int, withscores bool, offset, count int) ([]int, error)

func (*RedisCache) ZScore

func (cache *RedisCache) ZScore(key, member string) (interface{}, error)

Jump to

Keyboard shortcuts

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