redis

package module
v0.0.0-...-fdb6f41 Latest Latest
Warning

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

Go to latest
Published: May 1, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

README

redigo-wrapper

redigo-wrapper is a written on top of redigo to help you manage key structure in redis and provides a short hand access to read data from redis in basic datatypes taking care of conversion implicity.

Features

  • Key templating
  • Hash key templating
  • Key prefix
  • Basic datatype conversions

Installation

Install redigo-wrapper using the "go get" command:

go get github.com/yadvendar/redigo-wrapper

The Go distribution and redigo are the dependencies for redigo-wrapper.

Example

Check main.go file

License

Redigo is available under the Apache License, Version 2.0.

Documentation

Index

Constants

View Source
const (
	REDIS_KEYWORD_SADD            = "SADD"
	REDIS_KEYWORD_SCARD           = "SCARD"
	REDIS_KEYWORD_SISMEMBER       = "SISMEMBER"
	REDIS_KEYWORD_SMEMBERS        = "SMEMBERS"
	REDIS_KEYWORD_SREM            = "SREM"
	REDIS_KEYWORD_HSET            = "HSET"
	REDIS_KEYWORD_HGET            = "HGET"
	REDIS_KEYWORD_HMSET           = "HMSET"
	REDIS_KEYWORD_HMGET           = "HMGET"
	REDIS_KEYWORD_HDEL            = "HDEL"
	REDIS_KEYWORD_HGETALL         = "HGETALL"
	REDIS_KEYWORD_SET             = "SET"
	REDIS_KEYWORD_SETNX           = "SETNX"
	REDIS_KEYWORD_SETEX           = "SETEX"
	REDIS_KEYWORD_GET             = "GET"
	REDIS_KEYWORD_TTL             = "TTL"
	REDIS_KEYWORD_STRLEN          = "STRLEN"
	REDIS_KEYWORD_EXPIRE          = "EXPIRE"
	REDIS_KEYWORD_DELETE          = "DEL"
	REDIS_KEYWORD_KEYS            = "KEYS"
	REDIS_KEYWORD_HKEYS           = "HKEYS"
	REDIS_KEYWORD_EXISTS          = "EXISTS"
	REDIS_KEYWORD_PERSIST         = "PERSIST"
	REDIS_KEYWORD_ZADD            = "ZADD"
	REDIS_KEYWORD_ZREM            = "ZREM"
	REDIS_KEYWORD_ZRANGE          = "ZRANGE"
	REDIS_KEYWORD_ZRANGE_BY_SCORE = "ZRANGEBYSCORE"
	REDIS_KEYWORD_WITHSCORES      = "WITHSCORES"
	REDIS_KEYWORD_INCR            = "INCR"
	REDIS_KEYWORD_DECR            = "DECR"
	REDIS_KEYWORD_INCRBY          = "INCRBY"
	REDIS_KEYWORD_DECRBY          = "DECRBY"
	REDIS_KEYWORD_INCRBYFLOAT     = "INCRBYFLOAT"
	REDIS_KEYWORD_DECRBYFLOAT     = "DECRBYFLOAT"
)

Variables

This section is empty.

Functions

func Decr

func Decr(RConn *redigo.Conn, key string) (int64, error)

func DecrBy

func DecrBy(RConn *redigo.Conn, key string, decrBy int64) (int64, error)

func DecrByFloat

func DecrByFloat(RConn *redigo.Conn, key string, decrBy float64) (float64, error)

func Delete

func Delete(RConn *redigo.Conn, key string) (interface{}, error)

func Exists

func Exists(RConn *redigo.Conn, key string) (bool, error)

func Expire

func Expire(RConn *redigo.Conn, key string, ttl int) (interface{}, error)

func Get

func Get(RConn *redigo.Conn, key string) (interface{}, error)

func GetInt

func GetInt(RConn *redigo.Conn, key string) (int, error)

func GetString

func GetString(RConn *redigo.Conn, key string) (string, error)

func GetStringLength

func GetStringLength(RConn *redigo.Conn, key string) (int, error)

func GetTTL

func GetTTL(RConn *redigo.Conn, key string) (time.Duration, error)

func HDel

func HDel(RConn *redigo.Conn, key string, HKey string) (interface{}, error)

func HGet

func HGet(RConn *redigo.Conn, key string, HKey string) (interface{}, error)

func HGetAll

func HGetAll(RConn *redigo.Conn, key string) (interface{}, error)

func HGetAllString

func HGetAllString(RConn *redigo.Conn, key string) ([]string, error)

func HGetAllValues

func HGetAllValues(RConn *redigo.Conn, key string) ([]interface{}, error)

func HGetBool

func HGetBool(RConn *redigo.Conn, key string, HKey string) (bool, error)

func HGetFloat

func HGetFloat(RConn *redigo.Conn, key string, HKey string) (float64, error)

func HGetInt

func HGetInt(RConn *redigo.Conn, key string, HKey string) (int, error)

func HGetInt64

func HGetInt64(RConn *redigo.Conn, key string, HKey string) (int64, error)

func HGetString

func HGetString(RConn *redigo.Conn, key string, HKey string) (string, error)

func HKeys

func HKeys(RConn *redigo.Conn, key string) ([]string, error)

func HMGet

func HMGet(RConn *redigo.Conn, key string, hashKeys ...string) ([]interface{}, error)

func HMSet

func HMSet(RConn *redigo.Conn, key string, hashKeys []string, vals []interface{}) (interface{}, error)

func HSet

func HSet(RConn *redigo.Conn, key string, HKey string, data interface{}) (interface{}, error)

func Incr

func Incr(RConn *redigo.Conn, key string) (int64, error)

func IncrBy

func IncrBy(RConn *redigo.Conn, key string, incBy int64) (int64, error)

func IncrByFloat

func IncrByFloat(RConn *redigo.Conn, key string, incBy float64) (float64, error)

func Keys

func Keys(RConn *redigo.Conn, pattern string) ([]string, error)

NOTE: Use this in production environment with extreme care. Read more here:https://redis.io/commands/keys

func NewRConnectionPool

func NewRConnectionPool(c Config) *redigo.Pool

func ParseKey

func ParseKey(key string, vars []string) (string, error)

func Persist

func Persist(RConn *redigo.Conn, key string) (interface{}, error)

func SAdd

func SAdd(RConn *redigo.Conn, setName string, data interface{}) (interface{}, error)

func SCard

func SCard(RConn *redigo.Conn, setName string) (int64, error)

func SIsMember

func SIsMember(RConn *redigo.Conn, setName string, data interface{}) (bool, error)

func SMembers

func SMembers(RConn *redigo.Conn, setName string) ([]string, error)

func SRem

func SRem(RConn *redigo.Conn, setName string, data interface{}) (interface{}, error)

func Scan

func Scan(RConn *redigo.Conn, cursor int64, pattern string, count int64) (int64, []string, error)

func Set

func Set(RConn *redigo.Conn, key string, data interface{}) (interface{}, error)

func SetEx

func SetEx(RConn *redigo.Conn, key string, ttl int, data interface{}) (interface{}, error)

func SetNX

func SetNX(RConn *redigo.Conn, key string, data interface{}) (interface{}, error)

func SplitKey

func SplitKey(key string) []string

func StripEnvKey

func StripEnvKey(key string) string

func ZAdd

func ZAdd(RConn *redigo.Conn, key string, score float64, data interface{}) (interface{}, error)

func ZRange

func ZRange(RConn *redigo.Conn, key string, start int, end int, withScores bool) ([]interface{}, error)

func ZRem

func ZRem(RConn *redigo.Conn, key string, data interface{}) (interface{}, error)

Types

type Config

type Config struct {
	Server   string
	Password string
	MaxIdle  int // Maximum number of idle connections in the pool.

	// 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

	// 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

	// 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
	KEY_PREFIX          string // prefix to all keys; example is "dev environment name"
	KEY_DELIMITER       string // delimiter to be used while appending keys; example is ":"
	KEY_VAR_PLACEHOLDER string // placeholder to be parsed using given arguments to obtain a final key; example is "?"
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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