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

redis

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: MIT Imports: 10 Imported by: 0

README

redis

base go-redis connection library

Documentation

Index

Constants

View Source
const (
	CACHE_WEEK_TTL = 604800 * time.Second //7天
	CACHE_DAY_TTL  = 86400 * time.Second  //1天
	CACHE_HOUR_TTL = 3600 * time.Second   //1小时
	CACHE_MIN_TTL  = 60 * time.Second     //1分钟
)

Variables

View Source
var (
	ErrScanStructEmptySrc = errors.New("ScanStruct:src must not be empty")
)
View Source
var (
	ScanTagName = "json"
)

Functions

func Client

func Client(name ...string) *redis.Client

func Connect

func Connect(configs map[string]Config)

func ScanStruct

func ScanStruct(src map[string]string, dest interface{}) error

func StructToMapInterface added in v1.1.1

func StructToMapInterface(m interface{}) map[string]interface{}

Types

type BaseRedis

type BaseRedis struct {
	Client func() *redis.Client
}

func NewBaseRedis added in v1.0.7

func NewBaseRedis(name string) *BaseRedis

func (*BaseRedis) Decr

func (b *BaseRedis) Decr(key string) (int64, error)

func (*BaseRedis) DecrBy

func (b *BaseRedis) DecrBy(key string, value int64) (int64, error)

func (*BaseRedis) Del

func (b *BaseRedis) Del(key string) error

func (*BaseRedis) Exists

func (b *BaseRedis) Exists(key string) bool

func (*BaseRedis) Expire

func (b *BaseRedis) Expire(key string, expiration time.Duration) (bool, error)

func (*BaseRedis) Get

func (b *BaseRedis) Get(key string) (string, error)

func (*BaseRedis) HDel

func (b *BaseRedis) HDel(key string, field string) error

func (*BaseRedis) HExists

func (b *BaseRedis) HExists(key string, field string) (bool, error)

func (*BaseRedis) HGet

func (b *BaseRedis) HGet(key string, field string) (string, error)

func (*BaseRedis) HGetAll

func (b *BaseRedis) HGetAll(key string, m interface{}) error

func (*BaseRedis) HGetAllMap

func (b *BaseRedis) HGetAllMap(key string) (map[string]string, error)

func (*BaseRedis) HIncrBy added in v1.0.6

func (b *BaseRedis) HIncrBy(key string, field string, incr int64) (int64, error)

func (*BaseRedis) HMSet

func (b *BaseRedis) HMSet(key string, m interface{}) error

HMSet support gosql.Model and map[string]interface{}

func (*BaseRedis) HMSetMap

func (b *BaseRedis) HMSetMap(key string, m map[string]interface{}) error

Deprecated

func (*BaseRedis) HSet

func (b *BaseRedis) HSet(key string, field string, value interface{}) error

func (*BaseRedis) Incr

func (b *BaseRedis) Incr(key string) (int64, error)

func (*BaseRedis) IncrBy

func (b *BaseRedis) IncrBy(key string, value int64) (int64, error)

func (*BaseRedis) LPop

func (b *BaseRedis) LPop(key string) (string, error)

func (*BaseRedis) LPush

func (b *BaseRedis) LPush(key string, values ...interface{}) (int64, error)

func (*BaseRedis) RPop

func (b *BaseRedis) RPop(key string) (string, error)

func (*BaseRedis) RPush

func (b *BaseRedis) RPush(key string, values ...interface{}) (int64, error)

func (*BaseRedis) SAdd

func (b *BaseRedis) SAdd(key string, members ...interface{}) (int64, error)

func (*BaseRedis) Set

func (b *BaseRedis) Set(key, val string) error

func (*BaseRedis) SetEX added in v1.0.9

func (b *BaseRedis) SetEX(key, val string, expiration time.Duration) error

func (*BaseRedis) TTL added in v1.0.8

func (b *BaseRedis) TTL(key string) time.Duration

type Config

type Config struct {
	Server       string
	Password     string
	DB           int
	MaxRetries   int
	DialTimeout  int `json:"dial_timeout" toml:"dial_timeout"`
	ReadTimeout  int `json:"read_timeout" toml:"read_timeout"`
	WriteTimeout int `json:"write_timeout" toml:"write_timeout"`
}

Jump to

Keyboard shortcuts

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