package simpleredis

import "k8s.io/kubernetes/Godeps/_workspace/src/github.com/xyproto/simpleredis"

Easy way to use Redis from Go.

Index

Constants

const (
	// Version number. Stable API within major version numbers.
	Version = 1.0
)

Functions

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 TestConnection

func TestConnection() (err error)

Test if the local Redis server is up and running

func TestConnectionHost

func TestConnectionHost(hostColonPort string) (err error)

Test if a given Redis server at host:port is up and running. Does not try to PING or AUTH.

Types

type ConnectionPool

type ConnectionPool redis.Pool

A pool of readily available Redis connections

func NewConnectionPool

func NewConnectionPool() *ConnectionPool

Create a new connection pool

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) Close

func (pool *ConnectionPool) Close()

Close down the connection pool

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() (pong bool)

Ping the server by sending a PING command

type HashMap

type HashMap redisDatastructure

func NewHashMap

func NewHashMap(pool *ConnectionPool, id string) *HashMap

Create a new hashmap

func (*HashMap) Del

func (rh *HashMap) Del(elementid string) error

Remove an element (for instance a user)

func (*HashMap) DelKey

func (rh *HashMap) DelKey(elementid, key string) error

Remove a key for an entry in a hashmap (for instance the email field for a user)

func (*HashMap) Exists

func (rh *HashMap) Exists(elementid string) (bool, error)

Check if a given elementid exists as a hash map at all

func (*HashMap) Get

func (rh *HashMap) Get(elementid, key string) (string, error)

Get a value from a hashmap given the element id (for instance a user id) and the key (for instance "password")

func (*HashMap) GetAll

func (rh *HashMap) GetAll() ([]string, error)

Get all elementid's for all hash elements

func (*HashMap) Has

func (rh *HashMap) Has(elementid, key string) (bool, error)

Check if a given elementid + key is in the hash map

func (*HashMap) Remove

func (rh *HashMap) Remove() error

Remove this hashmap

func (*HashMap) SelectDatabase

func (rh *HashMap) SelectDatabase(dbindex int)

Select a different database

func (*HashMap) Set

func (rh *HashMap) Set(elementid, key, value string) error

Set a value in a hashmap given the element id (for instance a user id) and the key (for instance "password")

type KeyValue

type KeyValue redisDatastructure

func NewKeyValue

func NewKeyValue(pool *ConnectionPool, id string) *KeyValue

Create a new key/value

func (*KeyValue) Del

func (rkv *KeyValue) Del(key string) error

Remove a key

func (*KeyValue) Get

func (rkv *KeyValue) Get(key string) (string, error)

Get a value given a key

func (*KeyValue) Remove

func (rkv *KeyValue) Remove() error

Remove this key/value

func (*KeyValue) SelectDatabase

func (rkv *KeyValue) SelectDatabase(dbindex int)

Select a different database

func (*KeyValue) Set

func (rkv *KeyValue) Set(key, value string) error

Set a key and value

type List

type List redisDatastructure

func NewList

func NewList(pool *ConnectionPool, id string) *List

Create a new list

func (*List) Add

func (rl *List) Add(value string) error

Add an element to the list

func (*List) GetAll

func (rl *List) GetAll() ([]string, error)

Get all elements of a list

func (*List) GetLast

func (rl *List) GetLast() (string, error)

Get the last element of a list

func (*List) GetLastN

func (rl *List) GetLastN(n int) ([]string, error)

Get the last N elements of a list

func (*List) Remove

func (rl *List) Remove() error

Remove this list

func (*List) SelectDatabase

func (rl *List) SelectDatabase(dbindex int)

Select a different database

type Set

type Set redisDatastructure

func NewSet

func NewSet(pool *ConnectionPool, id string) *Set

Create a new set

func (*Set) Add

func (rs *Set) Add(value string) error

Add an element to the set

func (*Set) Del

func (rs *Set) Del(value string) error

Remove an element from the set

func (*Set) GetAll

func (rs *Set) GetAll() ([]string, error)

Get all elements of the set

func (*Set) Has

func (rs *Set) Has(value string) (bool, error)

Check if a given value is in the set

func (*Set) Remove

func (rs *Set) Remove() error

Remove this set

func (*Set) SelectDatabase

func (rs *Set) SelectDatabase(dbindex int)

Select a different database

Source Files

simpleredis.go

Directories

PathSynopsis
Godeps/_workspace/src/github.com/xyproto/simpleredis/example
Version
v0.19.3
Published
Jun 22, 2015
Platform
windows/amd64
Imports
4 packages
Last checked
39 seconds ago

Tools for package owners.