redistorage

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

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

Go to latest
Published: Nov 21, 2015 License: MIT Imports: 6 Imported by: 1

README

redis-storage Circle CI GoDoc

Summary

Small helper package around Redigo that extracts some very common functionality that we have on all projects using Redis.

Benefits

  • Easy value fetching by primitive types:
r := NewRedisStorage(*redisHost, *redisConnPoolSize, *redisPrefix)
	err := r.Set("test", 123)
	if err != nil {
		t.Fatalf(err.Error())
	}
	res, err := r.GetInt32("test")
  • Easy pub/sub

License

MIT (see LICENSE file)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNil = redis.ErrNil
View Source
var ErrPoolExhausted = redis.ErrPoolExhausted

Functions

This section is empty.

Types

type Message

type Message struct {
	Type    string
	Channel string
	Data    string
}

type RedisStorage

type RedisStorage struct {
	redis.PubSubConn
	sync.Mutex
	// contains filtered or unexported fields
}

RedisStorage holds a redis pool and a prefix and is used to Set and Get items from Redis

func NewRedisStorage

func NewRedisStorage(redisHost string, redisConnPoolSize int, redisPrefix string) *RedisStorage

Get a new instance of RedisStorage

func (*RedisStorage) Delete

func (rs *RedisStorage) Delete(key string) error

Remove an item from Redis

func (*RedisStorage) Get

func (rs *RedisStorage) Get(key string) ([]uint8, error)

Get an item from Redis

func (*RedisStorage) GetFloat64

func (rs *RedisStorage) GetFloat64(key string) (float64, error)

Get float64 value from cached item

func (*RedisStorage) GetInt

func (rs *RedisStorage) GetInt(key string) (int, error)

Get int value from cached item

func (*RedisStorage) GetInt32

func (rs *RedisStorage) GetInt32(key string) (int32, error)

Get int32 value from cached item

func (*RedisStorage) GetInt64

func (rs *RedisStorage) GetInt64(key string) (int64, error)

Get int64 value from cached item

func (*RedisStorage) GetString

func (rs *RedisStorage) GetString(key string) (string, error)

Get string value from cached item

func (*RedisStorage) NewPubSubConn

func (client *RedisStorage) NewPubSubConn() redis.PubSubConn

func (*RedisStorage) Pool

func (r *RedisStorage) Pool() *redis.Pool

func (*RedisStorage) Publish

func (client *RedisStorage) Publish(channel, data string)

func (*RedisStorage) Receive

func (client *RedisStorage) Receive(psc redis.PubSubConn) *Message

func (*RedisStorage) Set

func (rs *RedisStorage) Set(key string, val interface{}) error

Set an item on Redis

func (*RedisStorage) Setex

func (rs *RedisStorage) Setex(key string, val interface{}, duration time.Duration) error

Set an item on Redis, with an expiration duration

Jump to

Keyboard shortcuts

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