redis

package
v0.0.0-...-5e9c0d7 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Do `FLUSHALL` redis command at the beginning
	FlushAll bool `mapstructure:"flush"`

	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Password string `mapstructure:"password"`
	DB       int    `mapstructure:"db"`

	// Redigo param's
	// Maximum number of idle connections in the pool.
	MaxIdle int `mapstructure:"max_idle"`

	// Maximum number of connections allocated by the pool at a given time.
	// When zero, there is no limit on the number of connections in the pool.
	MaxActive int `mapstructure:"max_Active"`

	// Close connections after remaining idle for this duration. If the value
	// is zero, then idle connections are not closed. Applications should set
	// the timeout to a value less than the server's timeout.
	IdleTimeout time.Duration `mapstructure:"IdleTimeout"`

	// If Wait is true and the pool is at the MaxActive limit, then Get() waits
	// for a connection to be returned to the pool before returning.
	Wait bool `mapstructure:"wait"`

	// Close connections older than this duration. If the value is zero, then
	// the pool does not close connections based on age.
	MaxConnLifetime time.Duration `mapstructure:"max_conn_life_time"`

	// TestOnBorrow() is an optional application supplied function for checking
	// the health of an idle connection before the connection is used again by
	// the application. Argument t is the time that the connection was returned
	// to the pool. If the function returns an error, then the connection is
	// closed.
	TestOnBorrowTime time.Duration `mapstructure:"test_on_borrow_time"`
}

type ConfigParams

type ConfigParams = map[string]interface{}

type Redis

type Redis struct {
	Name string // Name DB (better uniq id in program)
	// contains filtered or unexported fields
}

func NewRedisDB

func NewRedisDB(config ConfigParams, lg log.FieldLogger) (*Redis, error)

func (*Redis) Do

func (r *Redis) Do(lg log.FieldLogger, command string, args ...interface{}) (interface{}, error)

func (*Redis) FlushAll

func (r *Redis) FlushAll() error

func (*Redis) GetName

func (r *Redis) GetName() string

func (*Redis) GetPool

func (r *Redis) GetPool() *redis.Pool

func (*Redis) HDel

func (r *Redis) HDel(key string, fields ...string) error

func (*Redis) HGet

func (r *Redis) HGet(key, field string) ([]byte, error)

func (*Redis) HSet

func (r *Redis) HSet(name, field, value string) error

func (*Redis) LIndex

func (r *Redis) LIndex(key string, index int64) (string, error)

func (*Redis) LPop

func (r *Redis) LPop(key string) ([]byte, error)

func (*Redis) LRem

func (r *Redis) LRem(key string, count int64, val string) error

func (*Redis) PingPongTest

func (r *Redis) PingPongTest() error

func (*Redis) RPush

func (r *Redis) RPush(key string, args ...string) error

func (*Redis) SAdd

func (r *Redis) SAdd(key string, members ...string) error

func (*Redis) Shutdown

func (r *Redis) Shutdown()

func (*Redis) ZAdd

func (r *Redis) ZAdd(key string, member string, score int64) error

func (*Redis) ZRange

func (r *Redis) ZRange(key string, start int64, stop int64) ([]string, error)

func (*Redis) ZRem

func (r *Redis) ZRem(key string, member string) error

func (*Redis) ZRemByScore

func (r *Redis) ZRemByScore(key string, score string) error

Jump to

Keyboard shortcuts

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