redis

package
v0.0.0-...-8c83dc3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Unlimited = 0

Variables

View Source
var (
	DefaultConfig = Config{
		MaxOpenConnections: Unlimited,
		MaxIdleConnections: 50,
		IdleTimeout:        1 * time.Minute,
		Wait:               true,
	}

	ErrPoolExhausted = errors.New("connection pool exhausted")
)
View Source
var (
	ErrNil = redigo.ErrNil
)

Functions

This section is empty.

Types

type BatchCommands

Commands with no results, to be used in transactions/pipelining.

type Config

type Config struct {
	MaxOpenConnections int
	MaxIdleConnections int
	IdleTimeout        time.Duration
	Wait               bool
}

type Connection

type Connection interface {
	Commands
	Transactions

	Send(command string, args ...interface{}) error
	Do(command string, args ...interface{}) (interface{}, error)

	Transaction(func(Transaction)) ([]interface{}, error)
	Pipelined(func(Pipeline)) ([]interface{}, error)
	PipelinedDiscarding(f func(Pipeline)) error

	Flush() error
	Receive() (interface{}, error)
}

type HashBatchCommands

type HashBatchCommands interface {
	HGet(key string, field string) error
	HGetAll(key string) error
	HIncrBy(key string, field string, value int64) error
	HSet(key string, field string, value string) error
	HMGet(key string, fields ...string) error
	HMSet(key string, args map[string]interface{}) error
	HDel(key string, field string) error
}

type HashCommands

type HashCommands interface {
	HGet(key string, field string) (string, error)

	// HGetAll returns a map containing all the fields and values in the specified key.
	// As specified by the Redis docs, because non-existing keys are treated as empty hashes,
	// calling this on a non-existant key will return an empty map and a nil error.
	HGetAll(key string) (map[string]string, error)

	HIncrBy(key string, field string, value int64) (newValue int64, err error)
	HSet(key string, field string, value string) (isNew bool, err error)

	// HMGet returns a map of the specified fields to their values in the specified key. As is
	// consistent with redigo.Strings, nil values (missing fields) are converted to empty strings.
	// As specified by the Redis docs, because non-existing keys are treated as empty hashes,
	// calling this on a non-existant key will return a map of the specified keys to empty strings.
	HMGet(key string, fields ...string) (map[string]string, error)

	HMSet(key string, args map[string]interface{}) error
	HDel(key string, field string) (bool, error)
}

Hashes - http://redis.io/commands#hash

type HyperLogLogBatchCommands

type HyperLogLogBatchCommands interface {
	PFAdd(key string, values ...string) error
	PFCount(key string) error
	PFMerge(mergedKey string, keysToMerge ...string) error
}

type HyperLogLogCommands

type HyperLogLogCommands interface {
	PFAdd(key string, values ...string) (int, error)
	PFCount(key string) (int, error)
	PFMerge(mergedKey string, keysToMerge ...string) (bool, error)
}

HyperLogLog

type KeyBatchCommands

type KeyBatchCommands interface {
	Del(keys ...string) error
	Exists(key string) error
	Expire(key string, seconds int) error
	Rename(key, newKey string) error
	RenameNX(key, newKey string) error
	TTL(key string) error
}

type KeyCommands

type KeyCommands interface {
	Del(keys ...string) (int, error)
	Exists(key string) (bool, error)
	Expire(key string, seconds int) (bool, error)
	Rename(key, newKey string) error
	RenameNX(key, newKey string) (bool, error)
	TTL(key string) (int, error)
}

Keys - http://redis.io/commands#generic

type ListBatchCommands

type ListBatchCommands interface {
	LPop(key string) error
	LPush(key string, values ...string) error
	LTrim(key string, startIndex int, endIndex int) error
	LRange(key string, startIndex int, endIndex int) error
	RPop(key string) error
	RPush(key string, values ...string) error
}

type ListCommands

type ListCommands interface {
	BLPop(timeout int, keys ...string) (listName string, value string, err error)
	BRPop(timeout int, keys ...string) (listName string, value string, err error)
	LIndex(key string, index int) (string, error)
	LLen(key string) (int, error)
	LPop(key string) (string, error)
	LPush(key string, values ...string) (int, error)
	LTrim(key string, startIndex int, endIndex int) error
	LRange(key string, startIndex int, endIndex int) ([]string, error)
	LRem(key string, count int, value string) (int, error)
	RPop(key string) (string, error)
	RPush(key string, values ...string) (int, error)
}

Lists - http://redis.io/commands#list

type Pipeline

type Pipeline interface {
	BatchCommands
	// contains filtered or unexported methods
}

type Pool

type Pool interface {
	Commands

	GetConnection() (PooledConnection, error)
	Return(PooledConnection)

	Do(f func(Connection)) error
	Transaction(func(Transaction)) ([]interface{}, error)
	Pipelined(func(Pipeline)) ([]interface{}, error)
	PipelinedDiscarding(f func(Pipeline)) error

	Shutdown()
}

func NewPool

func NewPool(url string, config Config) (Pool, error)

func NewPoolWithURL

func NewPoolWithURL(url *netURL.URL, config Config) Pool

type PooledConnection

type PooledConnection interface {
	Connection

	Release()
}

type PubSub

type PubSub interface {
}

type ScanCommands

type ScanCommands interface {
	Scan(cursor int, match string, count int) (nextCursor int, matches []string, err error)
	SScan(key string, cursor int, match string, count int) (nextCursor int, matches []string, err error)
	ZScan(key string, cursor int, match string, count int) (nextCursor int, matches []string, scores []float64, err error)
}

type SetBatchCommands

type SetBatchCommands interface {
	SAdd(key string, member string, members ...string) error
	SRem(key string, member string, members ...string) error
	SPop(key string) error
	SMembers(key string) error
	SRandMember(key string, count int) error
	SDiff(key string, keys ...string) error
	SMove(source, destination, member string) error
}

type SetCommands

type SetCommands interface {
	SAdd(key string, member string, members ...string) (int, error)
	SCard(key string) (int, error)
	SRem(key, member string, members ...string) (int, error)
	SPop(key string) (string, error)
	SMembers(key string) ([]string, error)
	SRandMember(key string, count int) ([]string, error)
	SDiff(key string, keys ...string) ([]string, error)
	SIsMember(key string, member string) (bool, error)
	SMove(source, destination, member string) (bool, error)
}

Sets - http://redis.io/commands#set

type SortedSetBatchCommands

type SortedSetBatchCommands interface {
	ZAdd(key string, args ...interface{}) error
	ZCard(key string) error
	ZRange(key string, start, stop int) error
	ZRangeWithScores(key string, start, stop int) error
	ZRangeByScore(key, min, max string) error
	ZRangeByScoreWithScores(key, min, max string) error
	ZRangeByScoreWithLimit(key, min, max string, offset, count int) error
	ZRangeByScoreWithScoresWithLimit(key, min, max string, offset, count int) error
	ZRevRange(key string, start, stop int) error
	ZRevRangeWithScores(key string, start, stop int) error
	ZRevRangeByScore(key, min, max string) error
	ZRevRangeByScoreWithScores(key, min, max string) error
	ZRevRangeByScoreWithLimit(key, min, max string, offset, count int) error
	ZRevRangeByScoreWithScoresWithLimit(key, min, max string, offset, count int) error
	ZRank(key, member string) error
	ZRem(key string, members ...string) error
	ZRemRangeByRank(key string, start, stop int) error
	ZScore(key string, member string) error
	ZIncrBy(key string, score float64, value string) error
}

type SortedSetCommands

type SortedSetCommands interface {
	ZAdd(key string, args ...interface{}) (int, error)
	ZCard(key string) (int, error)
	ZRange(key string, start, stop int) ([]string, error)
	ZRangeWithScores(key string, start, stop int) ([]Z, error)
	ZRangeByScore(key, min, max string) ([]string, error)
	ZRangeByScoreWithScores(key, min, max string) ([]Z, error)
	ZRangeByScoreWithLimit(key, min, max string, offset, count int) ([]string, error)
	ZRangeByScoreWithScoresWithLimit(key, min, max string, offset, count int) ([]Z, error)
	ZRevRange(key string, start, stop int) ([]string, error)
	ZRevRangeWithScores(key string, start, stop int) ([]Z, error)
	ZRevRangeByScore(key, min, max string) ([]string, error)
	ZRevRangeByScoreWithScores(key, min, max string) ([]Z, error)
	ZRevRangeByScoreWithLimit(key, min, max string, offset, count int) ([]string, error)
	ZRevRangeByScoreWithScoresWithLimit(key, min, max string, offset, count int) ([]Z, error)
	ZRank(key, member string) (int, error)
	ZRem(key string, members ...string) (removed int, err error)
	ZRemRangeByRank(key string, start, stop int) (int, error)
	ZScore(key string, member string) (score float64, err error)
	ZIncrBy(key string, score float64, value string) (int, error)
}

Sorted Sets - http://redis.io/commands#sorted_set

type StringBatchCommands

type StringBatchCommands interface {
	Get(key string) error
	Set(key, value string) error
	SetEx(key, value string, expire int) error
	SetNX(key, value string) error
	Incr(key string) error
}

type StringCommands

type StringCommands interface {
	Get(key string) (string, error)
	Set(key, value string) error
	SetEx(key, value string, expire int) error
	SetNX(key, value string) (bool, error)
	Incr(key string) (int, error)
}

Strings - http://redis.io/commands#string

type Transaction

type Transaction interface {
	Pipeline
}

type Transactions

type Transactions interface {
	Multi() error
	Exec() ([]interface{}, error)
}

type UnpooledConnection

type UnpooledConnection interface {
	Connection

	Close()
}

func NewConnection

func NewConnection(url *netURL.URL) (UnpooledConnection, error)

type Z

type Z struct {
	Value string
	Score float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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