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

redisutil

package
v1.7.21 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: MIT Imports: 2 Imported by: 8

Documentation

Overview

Package redisutil, for detailed usage, reference http:// doc.redisfans.com/index.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisClient

type RedisClient struct {
	Address string
	// contains filtered or unexported fields
}

func GetDefaultRedisClient added in v1.7.14

func GetDefaultRedisClient(address string) *RedisClient

GetDefaultRedisClient returns the RedisClient of specified address use default maxIdle & maxActive

func GetRedisClient

func GetRedisClient(address string, maxIdle, maxActive int) *RedisClient

GetRedisClient returns the RedisClient of specified address & maxIdle & maxActive

func (*RedisClient) Append

func (rc *RedisClient) Append(key string, val interface{}) (interface{}, error)

Append appends the string to original value specivied by key. if key does not exists, it behaves like Set

func (*RedisClient) BLPop

func (rc *RedisClient) BLPop(key ...interface{}) (map[string]string, error)

func (*RedisClient) BRPop

func (rc *RedisClient) BRPop(key ...interface{}) (map[string]string, error)

BRPop returns the last element in the list and delete it. It blocks if the list is empty

func (*RedisClient) BRPopLPush

func (rc *RedisClient) BRPopLPush(source string, destination string) (string, error)

func (*RedisClient) DBSize

func (rc *RedisClient) DBSize() (int64, error)

DBSize returns count of keys in the database

func (*RedisClient) DECR

func (rc *RedisClient) DECR(key string) (int, error)

DECR atomically decrement the value by 1 specified by key

func (*RedisClient) Del

func (rc *RedisClient) Del(key string) (int64, error)

Del deletes specified key

func (*RedisClient) Exists

func (rc *RedisClient) Exists(key string) (bool, error)

Exists whether key exists

func (*RedisClient) Expire

func (rc *RedisClient) Expire(key string, timeOutSeconds int64) (int64, error)

Expire specifies the expire duration for key

func (*RedisClient) FlushDB

func (rc *RedisClient) FlushDB()

FlushDB remove all data in the database this command never fails

func (*RedisClient) Get

func (rc *RedisClient) Get(key string) (string, error)

Get returns the content as string specified by key

func (*RedisClient) GetConn

func (rc *RedisClient) GetConn() redis.Conn

GetConn returns a connection from the pool, user is responsible for closing this connection

func (*RedisClient) GetObj

func (rc *RedisClient) GetObj(key string) (interface{}, error)

GetObj returns the content specified by key

func (*RedisClient) HDel

func (rc *RedisClient) HDel(args ...interface{}) (int64, error)

HDel delete content in hashset, if the field does not exists, this operation returns 0 and have no effect

func (*RedisClient) HExist

func (rc *RedisClient) HExist(hashID string, field string) (int, error)

HExist returns if the field exists in specified hashID

func (*RedisClient) HGet

func (rc *RedisClient) HGet(hashID string, field string) (string, error)

HGet returns content specified by hashID and field

func (*RedisClient) HGetAll

func (rc *RedisClient) HGetAll(hashID string) (map[string]string, error)

HGetAll returns all content specified by hashID

func (*RedisClient) HIncrBy

func (rc *RedisClient) HIncrBy(hashID string, field string, increment int) (int, error)

HIncrBy increment the value specified by hashID and field

func (*RedisClient) HLen

func (rc *RedisClient) HLen(hashID string) (int64, error)

HLen returns count of fileds in hashID, returns 0 if hashID does not exists

func (*RedisClient) HSet

func (rc *RedisClient) HSet(hashID string, field string, val string) error

HSet set content with hashID and field

func (*RedisClient) HSetNX

func (rc *RedisClient) HSetNX(hashID, field, value string) (interface{}, error)

HSetNX set content with hashID and field, if the field does not exists, this operation has no effect

func (*RedisClient) HVals

func (rc *RedisClient) HVals(hashID string) (interface{}, error)

HVals return all the values in all fields specified by hashID, returns empty if hashID does not exists

func (*RedisClient) INCR

func (rc *RedisClient) INCR(key string) (int, error)

INCR atomically increment the value by 1 specified by key

func (*RedisClient) LIndex

func (rc *RedisClient) LIndex(key string, index int) (string, error)

func (*RedisClient) LInsertAfter

func (rc *RedisClient) LInsertAfter(key string, pivot string, value string) (int, error)

func (*RedisClient) LInsertBefore

func (rc *RedisClient) LInsertBefore(key string, pivot string, value string) (int, error)

func (*RedisClient) LLen

func (rc *RedisClient) LLen(key string) (int, error)

func (*RedisClient) LPop

func (rc *RedisClient) LPop(key string) (string, error)

func (*RedisClient) LPush

func (rc *RedisClient) LPush(key string, value ...interface{}) (int, error)

LPush insert the values into front of the list

func (*RedisClient) LPushX

func (rc *RedisClient) LPushX(key string, value string) (int, error)

func (*RedisClient) LRange

func (rc *RedisClient) LRange(key string, start int, stop int) ([]string, error)

func (*RedisClient) LRem

func (rc *RedisClient) LRem(key string, count int, value string) (int, error)

func (*RedisClient) LSet

func (rc *RedisClient) LSet(key string, index int, value string) (string, error)

func (*RedisClient) LTrim

func (rc *RedisClient) LTrim(key string, start int, stop int) (string, error)

func (*RedisClient) Ping

func (rc *RedisClient) Ping() (string, error)

Ping tests the client is ready for use

func (*RedisClient) RPop

func (rc *RedisClient) RPop(key string) (string, error)

func (*RedisClient) RPopLPush

func (rc *RedisClient) RPopLPush(source string, destination string) (string, error)

func (*RedisClient) RPush

func (rc *RedisClient) RPush(key string, value ...interface{}) (int, error)

func (*RedisClient) RPushX

func (rc *RedisClient) RPushX(key string, value ...interface{}) (int, error)

func (*RedisClient) SAdd

func (rc *RedisClient) SAdd(key string, member ...interface{}) (int, error)

SAdd add one or multiple members in to the set, creates a new set with key if it does not exists

func (*RedisClient) SCard

func (rc *RedisClient) SCard(key string) (int, error)

SCard returns cardinality of the set(count of elements). returns 0 when set does not exist

func (*RedisClient) SDiff

func (rc *RedisClient) SDiff(key ...interface{}) ([]string, error)

func (*RedisClient) SDiffStore

func (rc *RedisClient) SDiffStore(destination string, key ...interface{}) (int, error)

func (*RedisClient) SInter

func (rc *RedisClient) SInter(key ...interface{}) ([]string, error)

func (*RedisClient) SInterStore

func (rc *RedisClient) SInterStore(destination string, key ...interface{}) (int, error)

func (*RedisClient) SIsMember

func (rc *RedisClient) SIsMember(key string, member string) (bool, error)

func (*RedisClient) SMembers

func (rc *RedisClient) SMembers(key string) ([]string, error)

func (*RedisClient) SMove

func (rc *RedisClient) SMove(source string, destination string, member string) (bool, error)

smove is a atomic operate

func (*RedisClient) SPop

func (rc *RedisClient) SPop(key string) (string, error)

SPop return and remove a random element from the set, use SRandMember if the element should not be removed

func (*RedisClient) SRandMember

func (rc *RedisClient) SRandMember(key string, count int) ([]string, error)

SRandMember returns random count elements from set

func (*RedisClient) SRem

func (rc *RedisClient) SRem(key string, member ...interface{}) (int, error)

SRem remove multiple elements from set

func (*RedisClient) SUnion

func (rc *RedisClient) SUnion(key ...interface{}) ([]string, error)

func (*RedisClient) SUnionStore

func (rc *RedisClient) SUnionStore(destination string, key ...interface{}) (int, error)

func (*RedisClient) Set

func (rc *RedisClient) Set(key string, val interface{}) (interface{}, error)

Set put key/value into redis

func (*RedisClient) SetNX

func (rc *RedisClient) SetNX(key, value string) (interface{}, error)

SetNX sets key/value only if key does not exists, it does nothing if key already exists. returns 1 on success, 0 on failure

func (*RedisClient) SetWithExpire

func (rc *RedisClient) SetWithExpire(key string, val interface{}, timeOutSeconds int64) (interface{}, error)

SetWithExpire set the key/value with specified duration

Jump to

Keyboard shortcuts

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