Documentation ¶
Overview ¶
Package simpleredis provides an easy way to use Redis.
Index ¶
- Constants
- func ConnectTimeout() time.Duration
- func IdleTimeout() time.Duration
- func ReadTimeout() time.Duration
- func SetConnectTimeout(t time.Duration)
- func SetIdleTimeout(t time.Duration)
- func SetMaxIdleConnections(maximum int)
- func SetReadTimeout(t time.Duration)
- func SetWriteTimeout(t time.Duration)
- func TestConnection() (err error)
- func TestConnectionHost(hostColonPort string) (err error)
- func WriteTimeout() time.Duration
- type ConnectionPool
- type HashMap
- func (rh *HashMap) All() ([]string, error)
- func (rh *HashMap) Clear() error
- func (rh *HashMap) Del(elementid string) error
- func (rh *HashMap) DelKey(elementid, key string) error
- func (rh *HashMap) Exists(elementid string) (bool, error)
- func (rh *HashMap) Get(elementid, key string) (string, error)
- func (rh *HashMap) GetAll() ([]string, error)
- func (rh *HashMap) Has(elementid, key string) (bool, error)
- func (rh *HashMap) Keys(elementid string) ([]string, error)
- func (rh *HashMap) Remove() error
- func (rh *HashMap) SelectDatabase(dbindex int)
- func (rh *HashMap) Set(elementid, key, value string) error
- func (rh *HashMap) SetExpire(elementid, key, value string, expire time.Duration) error
- type KeyValue
- func (rkv *KeyValue) Clear() error
- func (rkv *KeyValue) Del(key string) error
- func (rkv *KeyValue) Get(key string) (string, error)
- func (rkv *KeyValue) Inc(key string) (string, error)
- func (rkv *KeyValue) Remove() error
- func (rkv *KeyValue) SelectDatabase(dbindex int)
- func (rkv *KeyValue) Set(key, value string) error
- func (rkv *KeyValue) SetExpire(key, value string, expire time.Duration) error
- func (rkv *KeyValue) TimeToLive(key string) (time.Duration, error)
- type List
- func (rl *List) Add(value string) error
- func (rl *List) AddEnd(value string) error
- func (rl *List) AddStart(value string) error
- func (rl *List) All() ([]string, error)
- func (rl *List) Clear() error
- func (rl *List) Get(index int64) (string, error)
- func (rl *List) GetAll() ([]string, error)
- func (rl *List) GetLast() (string, error)
- func (rl *List) GetLastN(n int) ([]string, error)
- func (rl *List) Last() (string, error)
- func (rl *List) LastN(n int) ([]string, error)
- func (rl *List) PopFirst() (string, error)
- func (rl *List) PopLast() (string, error)
- func (rl *List) Remove() error
- func (rl *List) RemoveElement(value string) error
- func (rl *List) SelectDatabase(dbindex int)
- func (rl *List) Set(index int64, value string) error
- func (rl *List) Size() (int64, error)
- func (rl *List) Trim(start, stop int64) error
- type RedisCreator
- func (c *RedisCreator) NewHashMap(id string) (pinterface.IHashMap, error)
- func (c *RedisCreator) NewKeyValue(id string) (pinterface.IKeyValue, error)
- func (c *RedisCreator) NewList(id string) (pinterface.IList, error)
- func (c *RedisCreator) NewSet(id string) (pinterface.ISet, error)
- func (c *RedisCreator) SelectDatabase(dbindex int)
- type Set
- func (rs *Set) Add(value string) error
- func (rs *Set) All() ([]string, error)
- func (rs *Set) Clear() error
- func (rs *Set) Del(value string) error
- func (rs *Set) GetAll() ([]string, error)
- func (rs *Set) Has(value string) (bool, error)
- func (rs *Set) Pop() (string, error)
- func (rs *Set) Random() (string, error)
- func (rs *Set) Remove() error
- func (rs *Set) SelectDatabase(dbindex int)
- func (rs *Set) Size() (int64, error)
Constants ¶
const (
// Version number. Stable API within major version numbers.
Version = 2.6
)
Variables ¶
This section is empty.
Functions ¶
func ConnectTimeout ¶
ConnectTimeout returns the current connect timeout for new connections
func IdleTimeout ¶
IdleTimeout returns the current idle timeout for new connections
func ReadTimeout ¶
ReadTimeout returns the current read timeout for new connections
func SetConnectTimeout ¶
SetConnectTimeout sets the connect timeout for new connections
func SetIdleTimeout ¶
SetIdleTimeout sets the idle timeout for new connections
func SetMaxIdleConnections ¶
func SetMaxIdleConnections(maximum int)
Set the number of maximum *idle* connections standing ready when creating new connection pools. When an idle connection is used, a new idle connection is created. The default is 3 and should be fine for most cases.
func SetReadTimeout ¶
SetReadTimeout sets the read timeout for new connections
func SetWriteTimeout ¶
SetWriteTimeout sets the write timeout for new connections
func TestConnection ¶
func TestConnection() (err error)
Test if the local Redis server is up and running
func TestConnectionHost ¶
Test if a given Redis server at host:port is up and running. Does not try to PING or AUTH.
func WriteTimeout ¶
WriteTimeout returns the current write timeout for new connections
Types ¶
type ConnectionPool ¶
A pool of readily available Redis connections
func NewConnectionPoolHost ¶
func NewConnectionPoolHost(hostColonPort string) *ConnectionPool
Create a new connection pool given a host:port string. A password may be supplied as well, on the form "password@host:port".
func (*ConnectionPool) Get ¶
func (pool *ConnectionPool) Get(dbindex int) redis.Conn
Get one of the available connections from the connection pool, given a database index
func (*ConnectionPool) Ping ¶
func (pool *ConnectionPool) Ping() error
Ping the server by sending a PING command
type HashMap ¶
type HashMap redisDatastructure
func (*HashMap) DelKey ¶
Remove a key for an entry in a hashmap (for instance the email field for a user)
func (*HashMap) Get ¶
Get a value from a hashmap given the element id (for instance a user id) and the key (for instance "password")
func (*HashMap) Remove ¶
Remove this hashmap (all keys that starts with this hashmap id and a colon)
func (*HashMap) SelectDatabase ¶
Select a different database
type KeyValue ¶
type KeyValue redisDatastructure
func NewKeyValue ¶
func NewKeyValue(pool *ConnectionPool, id string) *KeyValue
Create a new key/value
func (*KeyValue) Inc ¶
Increase the value of a key, returns the new value Returns an empty string if there were errors, or "0" if the key does not already exist.
func (*KeyValue) SelectDatabase ¶
Select a different database
type List ¶
type List redisDatastructure
func (*List) RemoveElement ¶
Remove the first occurrence of an element from the list
func (*List) SelectDatabase ¶
Select a different database
type RedisCreator ¶
type RedisCreator struct {
// contains filtered or unexported fields
}
func NewCreator ¶
func NewCreator(pool *ConnectionPool, dbindex int) *RedisCreator
func (*RedisCreator) NewHashMap ¶
func (c *RedisCreator) NewHashMap(id string) (pinterface.IHashMap, error)
func (*RedisCreator) NewKeyValue ¶
func (c *RedisCreator) NewKeyValue(id string) (pinterface.IKeyValue, error)
func (*RedisCreator) NewList ¶
func (c *RedisCreator) NewList(id string) (pinterface.IList, error)
func (*RedisCreator) NewSet ¶
func (c *RedisCreator) NewSet(id string) (pinterface.ISet, error)
func (*RedisCreator) SelectDatabase ¶
func (c *RedisCreator) SelectDatabase(dbindex int)