redisc

package
v0.0.0-...-a2093d6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: LGPL-2.1 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNil = errors.New("redisc returned nil")

Functions

This section is empty.

Types

type Base

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

func NewBaseModel

func NewBaseModel(client Client, name string) *Base

func (*Base) Client

func (db *Base) Client() Client

func (*Base) DecrBy

func (db *Base) DecrBy(key string, num int) Result

func (*Base) Delete

func (db *Base) Delete(key string) Result

func (*Base) Do

func (db *Base) Do(cmd string, args ...interface{}) Result

func (*Base) Exists

func (db *Base) Exists(key string) Result

func (*Base) Expire

func (db *Base) Expire(key string, seconds interface{}) Result

func (*Base) Get

func (db *Base) Get(key string) Result

func (*Base) HGet

func (db *Base) HGet(key string, hKey string) Result

func (*Base) HSet

func (db *Base) HSet(key string, hKey string, value interface{}) Result

func (*Base) IncrBy

func (db *Base) IncrBy(key string, num int) Result

func (*Base) Key

func (db *Base) Key(key string) string

func (*Base) LPop

func (db *Base) LPop(key string) Result

func (*Base) LPush

func (db *Base) LPush(key string, val interface{}) Result

func (*Base) LRange

func (db *Base) LRange(key string, start int, end int) Result

func (*Base) Name

func (db *Base) Name() string

func (*Base) Pipe

func (db *Base) Pipe(method func(c Conn) error) (result Result)

func (*Base) RPop

func (db *Base) RPop(key string) Result

func (*Base) RPush

func (db *Base) RPush(key string, val interface{}) Result

func (*Base) SMembers

func (db *Base) SMembers(key string) Result

func (*Base) Set

func (db *Base) Set(key string, val interface{}) Result

func (*Base) SetIfNotExists

func (db *Base) SetIfNotExists(key string, val interface{}) Result

func (*Base) SetWithExpire

func (db *Base) SetWithExpire(key string, val interface{}, seconds interface{}) Result

type Client

type Client interface {
	GetConn() (conn redis.Conn)
	Close()
	Do(cmd string, args ...interface{}) Result
}

func NewClient

func NewClient(options ...Option) (Client, error)

func NewClientWithConfig

func NewClientWithConfig(config Config) (Client, error)

type Config

type Config struct {
	Addr     string `mapstructure:"addr" json:"addr"`
	Username string `mapstructure:"username" json:"username"`
	Password string `mapstructure:"password" json:"password"`
	// Maximum number of idle connections in the pool.
	MaxIdle int `mapstructure:"max_idle" json:"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" json:"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:"idle_timeout" json:"idle_timeout"`
	// 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" json:"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_lifetime" json:"max_conn_lifetime"`

	// ClientName specifies a client name to be used by the Redis server connection.
	ClientName string `mapstructure:"client_name" json:"client_name"`
	Database   int    `mapstructure:"db" json:"db"`
}

type Conn

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

func (Conn) Send

func (conn Conn) Send(command string, args ...interface{}) error

type Model

type Model interface {
	Name() string
}

type Option

type Option func(config *Config)

func WithAddr

func WithAddr(addr string) Option

func WithClientName

func WithClientName(clientName string) Option

func WithDatabase

func WithDatabase(database int) Option

func WithIdleTimeout

func WithIdleTimeout(idleTimeout time.Duration) Option

func WithMaxActive

func WithMaxActive(maxActive int) Option

func WithMaxConnLifetime

func WithMaxConnLifetime(maxConnLifetime time.Duration) Option

func WithMaxIdle

func WithMaxIdle(maxIdle int) Option

func WithPassword

func WithPassword(password string) Option

func WithUsername

func WithUsername(username string) Option

func WithWait

func WithWait(wait bool) Option

type Result

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

func (Result) Bool

func (result Result) Bool() bool

func (Result) ByteSlices

func (result Result) ByteSlices() [][]byte

func (Result) Bytes

func (result Result) Bytes() []byte

func (Result) Error

func (result Result) Error() error

func (Result) Float64

func (result Result) Float64() float64

func (Result) Float64s

func (result Result) Float64s() []float64

func (Result) Int

func (result Result) Int() int

func (Result) Int64

func (result Result) Int64() int64

func (Result) Int64Map

func (result Result) Int64Map() map[string]int64

func (Result) Int64s

func (result Result) Int64s() []int64

func (Result) IntMap

func (result Result) IntMap() map[string]int

func (Result) Ints

func (result Result) Ints() []int

func (Result) Positions

func (result Result) Positions() []*[2]float64

func (Result) Reply

func (result Result) Reply() interface{}

func (Result) SlowLogs

func (result Result) SlowLogs() []redis.SlowLog

func (Result) String

func (result Result) String() string

func (Result) StringMap

func (result Result) StringMap() map[string]string

func (Result) Strings

func (result Result) Strings() []string

func (Result) Uint64

func (result Result) Uint64() uint64

func (Result) Uint64Map

func (result Result) Uint64Map() map[string]uint64

func (Result) Uint64s

func (result Result) Uint64s() []uint64

func (Result) Value

func (result Result) Value() interface{}

func (Result) Values

func (result Result) Values() []interface{}

Jump to

Keyboard shortcuts

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