Documentation ¶
Index ¶
- type Client
- func (this *Client) Append(k string, v string) *RedisReply
- func (this *Client) BLPop(args ...interface{}) *RedisReply
- func (this *Client) BRPop(args ...interface{}) *RedisReply
- func (this *Client) BRPopLPush(source, dest string, args ...interface{}) *RedisReply
- func (this *Client) Decr(k string) *RedisReply
- func (this *Client) DecrBy(k string, decr int) *RedisReply
- func (this *Client) DecrByFloat(k string, decr float64) *RedisReply
- func (this *Client) Del(k ...interface{}) *RedisReply
- func (this *Client) Execute(cmd string, args ...interface{}) *RedisReply
- func (this *Client) Exists(k string) *RedisReply
- func (this *Client) Get(k string) *RedisReply
- func (this *Client) GetBit(k string, offset int) *RedisReply
- func (this *Client) GetRange(k string, start, end int) *RedisReply
- func (this *Client) GetSet(k string, v interface{}) *RedisReply
- func (this *Client) HDel(k string, f ...interface{}) *RedisReply
- func (this *Client) HExists(k string, f string) *RedisReply
- func (this *Client) HGet(k string, f string) *RedisReply
- func (this *Client) HGetAll(k string) *RedisReply
- func (this *Client) HIncrBy(k string, f string, incre int) *RedisReply
- func (this *Client) HIncrByFloat(k string, f string, incre float64) *RedisReply
- func (this *Client) HKeys(k string) *RedisReply
- func (this *Client) HLen(k string) *RedisReply
- func (this *Client) HMGet(args ...interface{}) *RedisReply
- func (this *Client) HMSet(k string, args ...interface{}) *RedisReply
- func (this *Client) HSet(k string, f string, v interface{}) *RedisReply
- func (this *Client) HSetNx(k string, f string, v interface{}) *RedisReply
- func (this *Client) HVals(k string) *RedisReply
- func (this *Client) Incr(k string) *RedisReply
- func (this *Client) IncrBy(k string, incr int) *RedisReply
- func (this *Client) IncrByFloat(k string, incr float64) *RedisReply
- func (this *Client) LIndex(k string, index int) *RedisReply
- func (this *Client) LInsert(k string, before bool, pivot int, v interface{}) *RedisReply
- func (this *Client) LLen(k string) *RedisReply
- func (this *Client) LPop(k string) *RedisReply
- func (this *Client) LPush(k string, v ...interface{}) *RedisReply
- func (this *Client) LPushX(k string, v interface{}) *RedisReply
- func (this *Client) LRange(k string, start, end int) *RedisReply
- func (this *Client) LRem(k string, count int, v interface{}) *RedisReply
- func (this *Client) LSet(k string, index int, v interface{}) *RedisReply
- func (this *Client) LTrim(k string, start, end int) *RedisReply
- func (this *Client) MGet(keys ...interface{}) *RedisReply
- func (this *Client) MSet(args ...interface{}) *RedisReply
- func (this *Client) MSetNx(args ...interface{}) *RedisReply
- func (this *Client) PSetEx(k string, milliseconds float64) *RedisReply
- func (this *Client) RPop(k string) *RedisReply
- func (this *Client) RPopLPush(source, dest string) *RedisReply
- func (this *Client) RPush(k string, v ...interface{}) *RedisReply
- func (this *Client) RPushX(k string, v interface{}) *RedisReply
- func (this *Client) SAdd(k string, m ...string) *RedisReply
- func (this *Client) SCard(k string) *RedisReply
- func (this *Client) SDiff(s ...string) *RedisReply
- func (this *Client) SDiffStore(dest string, s ...string) *RedisReply
- func (this *Client) SInter(s ...string) *RedisReply
- func (this *Client) SInterStore(dest string, s ...string) *RedisReply
- func (this *Client) SIsMember(k string, m string) *RedisReply
- func (this *Client) SMembers(k string) *RedisReply
- func (this *Client) SMove(source string, dest string, m string) *RedisReply
- func (this *Client) SPop(k string) *RedisReply
- func (this *Client) SRandMember(k string, count ...int) *RedisReply
- func (this *Client) SRem(k string, m ...string) *RedisReply
- func (this *Client) SUnion(s ...string) *RedisReply
- func (this *Client) SUnionStore(dest string, s ...string) *RedisReply
- func (this *Client) Set(k string, v interface{}) *RedisReply
- func (this *Client) SetBit(k string, offset int, v int) *RedisReply
- func (this *Client) SetEx(k string, seconds float64) *RedisReply
- func (this *Client) SetNx(k string, v interface{}) *RedisReply
- func (this *Client) SetRange(k string, offset int, v interface{}) *RedisReply
- func (this *Client) StrLen(k string) *RedisReply
- func (this *Client) ZAdd(k string, args ...interface{}) *RedisReply
- func (this *Client) ZCard(k string) *RedisReply
- func (this *Client) ZCount(k string, min, max float64) *RedisReply
- func (this *Client) ZIncrBy(k string, incr float64, m string) *RedisReply
- func (this *Client) ZInterStore(dest string, numkeys int, s ...string) *RedisReply
- func (this *Client) ZLexCount(args ...interface{}) *RedisReply
- func (this *Client) ZREVRank(k string, m string) *RedisReply
- func (this *Client) ZRange(k string, start, end int, withScore bool) *RedisReply
- func (this *Client) ZRangeByLex(args ...interface{}) *RedisReply
- func (this *Client) ZRangeByScore(k string, min, max float64, withScore bool, limit ...string) *RedisReply
- func (this *Client) ZRank(k string, m string) *RedisReply
- func (this *Client) ZRem(k string, m ...string) *RedisReply
- func (this *Client) ZRemRangeByLex(args ...interface{}) *RedisReply
- func (this *Client) ZRemRangeByRank(k string, start, end int) *RedisReply
- func (this *Client) ZRemRangeByScore(k string, min, max float64) *RedisReply
- func (this *Client) ZRevRange(k string, start, end int, withScore bool) *RedisReply
- func (this *Client) ZRevRangeByScore(k string, min, max float64, withScore bool) *RedisReply
- func (this *Client) ZScore(k string, m string) *RedisReply
- func (this *Client) ZUnionStore(dest string, numkeys int, s ...string) *RedisReply
- type GobSerializer
- type JSONSerializer
- type Pair
- type RediStore
- func (s *RediStore) Close() error
- func (s *RediStore) Delete(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *RediStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *RediStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *RediStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *RediStore) SetKeyPrefix(p string)
- func (s *RediStore) SetMaxAge(v int)
- func (s *RediStore) SetMaxLength(l int)
- func (s *RediStore) SetSerializer(ss SessionSerializer)
- type RedisReply
- func (this *RedisReply) Bool() (bool, error)
- func (this *RedisReply) ByteSlices() ([][]byte, error)
- func (this *RedisReply) Bytes() ([]byte, error)
- func (this *RedisReply) Float64() (float64, error)
- func (this *RedisReply) Float64s() ([]float64, error)
- func (this *RedisReply) Int() (int, error)
- func (this *RedisReply) Int64() (int64, error)
- func (this *RedisReply) Int64Map() (map[string]int64, error)
- func (this *RedisReply) Int64s() ([]int64, error)
- func (this *RedisReply) IntMap() (map[string]int, error)
- func (this *RedisReply) Interface() (interface{}, error)
- func (this *RedisReply) Ints() ([]int, error)
- func (this *RedisReply) MultiBulk() ([]interface{}, error)
- func (this *RedisReply) Positions() ([]*[2]float64, error)
- func (this *RedisReply) SlowLogs() ([]redis.SlowLog, error)
- func (this *RedisReply) String() (string, error)
- func (this *RedisReply) StringMap() (map[string]string, error)
- func (this *RedisReply) Strings() ([]string, error)
- func (this *RedisReply) Uint64() (uint64, error)
- func (this *RedisReply) Uint64Map() (map[string]uint64, error)
- func (this *RedisReply) Uint64s() ([]uint64, error)
- func (this *RedisReply) Values() ([]interface{}, error)
- type SessionSerializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (*Client) Append ¶
func (this *Client) Append(k string, v string) *RedisReply
如果 key 已经存在并且是一个字符串, APPEND 命令将指定的 value 追加到该 key 原来值(value)的末尾。
func (*Client) BLPop ¶
func (this *Client) BLPop(args ...interface{}) *RedisReply
List 移出并获取列表的第一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。
func (*Client) BRPop ¶
func (this *Client) BRPop(args ...interface{}) *RedisReply
移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。
func (*Client) BRPopLPush ¶
func (this *Client) BRPopLPush(source, dest string, args ...interface{}) *RedisReply
从列表中弹出一个值,将弹出的元素插入到另外一个列表中并返回它; 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。
func (*Client) DecrBy ¶
func (this *Client) DecrBy(k string, decr int) *RedisReply
key 所储存的值减去给定的减量值(decrement) 。
func (*Client) DecrByFloat ¶
func (this *Client) DecrByFloat(k string, decr float64) *RedisReply
key 所储存的值减去给定的浮点减量值(decrement) 。
func (*Client) Del ¶
func (this *Client) Del(k ...interface{}) *RedisReply
func (*Client) Execute ¶
func (this *Client) Execute(cmd string, args ...interface{}) *RedisReply
func (*Client) GetBit ¶
func (this *Client) GetBit(k string, offset int) *RedisReply
对 key 所储存的字符串值,获取指定偏移量上的位(bit)。
func (*Client) GetRange ¶
func (this *Client) GetRange(k string, start, end int) *RedisReply
返回 key 中字符串值的子字符
func (*Client) GetSet ¶
func (this *Client) GetSet(k string, v interface{}) *RedisReply
将给定 key 的值设为 value ,并返回 key 的旧值(old value)。
func (*Client) HDel ¶
func (this *Client) HDel(k string, f ...interface{}) *RedisReply
Hash 删除一个或多个哈希表字段
func (*Client) HExists ¶
func (this *Client) HExists(k string, f string) *RedisReply
查看哈希表 key 中,指定的字段是否存在。
func (*Client) HIncrBy ¶
func (this *Client) HIncrBy(k string, f string, incre int) *RedisReply
为哈希表 key 中的指定字段的整数值加上增量 increment 。
func (*Client) HIncrByFloat ¶
func (this *Client) HIncrByFloat(k string, f string, incre float64) *RedisReply
为哈希表 key 中的指定字段的浮点数值加上增量 increment 。
func (*Client) HMSet ¶
func (this *Client) HMSet(k string, args ...interface{}) *RedisReply
同时将多个 field-value (域-值)对设置到哈希表 key 中。
func (*Client) HSet ¶
func (this *Client) HSet(k string, f string, v interface{}) *RedisReply
将哈希表 key 中的字段 field 的值设为 value 。
func (*Client) HSetNx ¶
func (this *Client) HSetNx(k string, f string, v interface{}) *RedisReply
只有在字段 field 不存在时,设置哈希表字段的值。
func (*Client) IncrBy ¶
func (this *Client) IncrBy(k string, incr int) *RedisReply
将 key 所储存的值加上给定的增量值(increment) 。
func (*Client) IncrByFloat ¶
func (this *Client) IncrByFloat(k string, incr float64) *RedisReply
将 key 所储存的值加上给定的浮点增量值(increment) 。
func (*Client) LInsert ¶
func (this *Client) LInsert(k string, before bool, pivot int, v interface{}) *RedisReply
在列表的元素前或者后插入元素
func (*Client) LPush ¶
func (this *Client) LPush(k string, v ...interface{}) *RedisReply
将一个或多个值插入到列表头部
func (*Client) LPushX ¶
func (this *Client) LPushX(k string, v interface{}) *RedisReply
将一个值插入到已存在的列表头部
func (*Client) LRange ¶
func (this *Client) LRange(k string, start, end int) *RedisReply
获取列表指定范围内的元素
func (*Client) LRem ¶
func (this *Client) LRem(k string, count int, v interface{}) *RedisReply
移除列表元素
func (*Client) LSet ¶
func (this *Client) LSet(k string, index int, v interface{}) *RedisReply
通过索引设置列表元素的值
func (*Client) LTrim ¶
func (this *Client) LTrim(k string, start, end int) *RedisReply
对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。
func (*Client) MGet ¶
func (this *Client) MGet(keys ...interface{}) *RedisReply
获取所有(一个或多个)给定 key 的值。
func (*Client) MSet ¶
func (this *Client) MSet(args ...interface{}) *RedisReply
同时设置一个或多个 key-value 对。
func (*Client) MSetNx ¶
func (this *Client) MSetNx(args ...interface{}) *RedisReply
同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在。
func (*Client) PSetEx ¶
func (this *Client) PSetEx(k string, milliseconds float64) *RedisReply
这个命令和 SETEX 命令相似,但它以毫秒为单位设置 key 的生存时间,而不是像 SETEX 命令那样,以秒为单位。
func (*Client) RPopLPush ¶
func (this *Client) RPopLPush(source, dest string) *RedisReply
移除列表的最后一个元素,并将该元素添加到另一个列表并返回
func (*Client) RPush ¶
func (this *Client) RPush(k string, v ...interface{}) *RedisReply
在列表中添加一个或多个值
func (*Client) SDiffStore ¶
func (this *Client) SDiffStore(dest string, s ...string) *RedisReply
返回给定所有集合的差集并存储在 destination 中
func (*Client) SInterStore ¶
func (this *Client) SInterStore(dest string, s ...string) *RedisReply
返回给定所有集合的交集并存储在 destination 中
func (*Client) SIsMember ¶
func (this *Client) SIsMember(k string, m string) *RedisReply
判断 member 元素是否是集合 key 的成员
func (*Client) SMove ¶
func (this *Client) SMove(source string, dest string, m string) *RedisReply
将 member 元素从 source 集合移动到 destination 集合
func (*Client) SRandMember ¶
func (this *Client) SRandMember(k string, count ...int) *RedisReply
返回集合中一个或多个随机数
func (*Client) SUnionStore ¶
func (this *Client) SUnionStore(dest string, s ...string) *RedisReply
所有给定集合的并集存储在 destination 集合中
func (*Client) SetBit ¶
func (this *Client) SetBit(k string, offset int, v int) *RedisReply
对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit)。
func (*Client) SetEx ¶
func (this *Client) SetEx(k string, seconds float64) *RedisReply
将值 value 关联到 key ,并将 key 的过期时间设为 seconds (以秒为单位)。
func (*Client) SetNx ¶
func (this *Client) SetNx(k string, v interface{}) *RedisReply
只有在 key 不存在时设置 key 的值。
func (*Client) SetRange ¶
func (this *Client) SetRange(k string, offset int, v interface{}) *RedisReply
用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始。
func (*Client) ZAdd ¶
func (this *Client) ZAdd(k string, args ...interface{}) *RedisReply
向有序集合添加一个或多个成员,或者更新已存在成员的分数
func (*Client) ZCount ¶
func (this *Client) ZCount(k string, min, max float64) *RedisReply
计算在有序集合中指定区间分数的成员数
func (*Client) ZIncrBy ¶
func (this *Client) ZIncrBy(k string, incr float64, m string) *RedisReply
有序集合中对指定成员的分数加上增量 increment
func (*Client) ZInterStore ¶
func (this *Client) ZInterStore(dest string, numkeys int, s ...string) *RedisReply
计算给定的一个或多个有序集的交集并将结果集存储在新的有序集合 destination 中,numKeys指定结果的数量
func (*Client) ZLexCount ¶
func (this *Client) ZLexCount(args ...interface{}) *RedisReply
在有序集合中计算指定字典区间内成员数量
func (*Client) ZREVRank ¶
func (this *Client) ZREVRank(k string, m string) *RedisReply
返回有序集合中指定成员的排名,有序集成员按分数值递减(从大到小)排序
func (*Client) ZRange ¶
func (this *Client) ZRange(k string, start, end int, withScore bool) *RedisReply
通过索引区间返回有序集合指定区间内的成员
func (*Client) ZRangeByLex ¶
func (this *Client) ZRangeByLex(args ...interface{}) *RedisReply
通过字典区间返回有序集合的成员
func (*Client) ZRangeByScore ¶
func (this *Client) ZRangeByScore(k string, min, max float64, withScore bool, limit ...string) *RedisReply
通过分数返回有序集合指定区间内的成员
func (*Client) ZRemRangeByLex ¶
func (this *Client) ZRemRangeByLex(args ...interface{}) *RedisReply
移除有序集合中给定的字典区间的所有成员
func (*Client) ZRemRangeByRank ¶
func (this *Client) ZRemRangeByRank(k string, start, end int) *RedisReply
移除有序集合中给定的排名区间的所有成员
func (*Client) ZRemRangeByScore ¶
func (this *Client) ZRemRangeByScore(k string, min, max float64) *RedisReply
移除有序集合中给定的分数区间的所有成员
func (*Client) ZRevRange ¶
func (this *Client) ZRevRange(k string, start, end int, withScore bool) *RedisReply
返回有序集中指定区间内的成员,通过索引,分数从高到低
func (*Client) ZRevRangeByScore ¶
func (this *Client) ZRevRangeByScore(k string, min, max float64, withScore bool) *RedisReply
返回有序集中指定分数区间内的成员,分数从高到低排序
func (*Client) ZUnionStore ¶
func (this *Client) ZUnionStore(dest string, numkeys int, s ...string) *RedisReply
计算给定的一个或多个有序集的并集,并存储在新的 key 中
type GobSerializer ¶
type GobSerializer struct{}
GobSerializer uses gob package to encode the session map
func (GobSerializer) Deserialize ¶
func (s GobSerializer) Deserialize(d []byte, ss *sessions.Session) error
Deserialize back to map[interface{}]interface{}
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer encode the session map to JSON.
func (JSONSerializer) Deserialize ¶
func (s JSONSerializer) Deserialize(d []byte, ss *sessions.Session) error
Deserialize back to map[string]interface{}
type RediStore ¶
type RediStore struct { Pool *redis.Pool Codecs []securecookie.Codec Options *sessions.Options // default configuration DefaultMaxAge int // default Redis TTL for a MaxAge == 0 session // contains filtered or unexported fields }
RediStore stores sessions in a redis backend.
func NewRediStore ¶
func NewRediStore(size int, network, address, password string, keyPairs ...[]byte) (*RediStore, error)
NewRediStore returns a new RediStore. size: maximum number of idle connections.
func NewRediStoreWithDB ¶
func NewRediStoreWithDB(size int, network, address, password, DB string, keyPairs ...[]byte) (*RediStore, error)
NewRediStoreWithDB - like NewRedisStore but accepts `DB` parameter to select redis DB instead of using the default one ("0")
func NewRediStoreWithPool ¶
NewRediStoreWithPool instantiates a RediStore with a *redis.Pool passed in.
func (*RediStore) Delete ¶
Delete removes the session from redis, and sets the cookie to expire.
WARNING: This method should be considered deprecated since it is not exposed via the gorilla/sessions interface. Set session.Options.MaxAge = -1 and call Save instead. - July 18th, 2013
func (*RediStore) Get ¶
Get returns a session for the given name after adding it to the registry.
See gorilla/sessions FilesystemStore.Get().
func (*RediStore) New ¶
New returns a session for the given name without adding it to the registry.
See gorilla/sessions FilesystemStore.New().
func (*RediStore) SetKeyPrefix ¶
SetKeyPrefix set the prefix
func (*RediStore) SetMaxAge ¶
SetMaxAge restricts the maximum age, in seconds, of the session record both in database and a browser. This is to change session storage configuration. If you want just to remove session use your session `s` object and change it's `Options.MaxAge` to -1, as specified in
http://godoc.org/github.com/gorilla/sessions#Options
Default is the one provided by this package value - `sessionExpire`. Set it to 0 for no restriction. Because we use `MaxAge` also in SecureCookie crypting algorithm you should use this function to change `MaxAge` value.
func (*RediStore) SetMaxLength ¶
SetMaxLength sets RediStore.maxLength if the `l` argument is greater or equal 0 maxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default for a new RediStore is 4096. Redis allows for max. value sizes of up to 512MB (http://redis.io/topics/data-types) Default: 4096,
func (*RediStore) SetSerializer ¶
func (s *RediStore) SetSerializer(ss SessionSerializer)
SetSerializer sets the serializer
type RedisReply ¶
type RedisReply struct { Value interface{} Error error }
func NewReply ¶
func NewReply(v interface{}, e error) *RedisReply
func (*RedisReply) Bool ¶
func (this *RedisReply) Bool() (bool, error)
func (*RedisReply) ByteSlices ¶
func (this *RedisReply) ByteSlices() ([][]byte, error)
func (*RedisReply) Bytes ¶
func (this *RedisReply) Bytes() ([]byte, error)
func (*RedisReply) Float64 ¶
func (this *RedisReply) Float64() (float64, error)
func (*RedisReply) Float64s ¶
func (this *RedisReply) Float64s() ([]float64, error)
func (*RedisReply) Int ¶
func (this *RedisReply) Int() (int, error)
func (*RedisReply) Int64 ¶
func (this *RedisReply) Int64() (int64, error)
func (*RedisReply) Int64s ¶
func (this *RedisReply) Int64s() ([]int64, error)
func (*RedisReply) Interface ¶
func (this *RedisReply) Interface() (interface{}, error)
func (*RedisReply) Ints ¶
func (this *RedisReply) Ints() ([]int, error)
func (*RedisReply) MultiBulk ¶
func (this *RedisReply) MultiBulk() ([]interface{}, error)
func (*RedisReply) Positions ¶
func (this *RedisReply) Positions() ([]*[2]float64, error)
func (*RedisReply) String ¶
func (this *RedisReply) String() (string, error)
func (*RedisReply) Strings ¶
func (this *RedisReply) Strings() ([]string, error)
func (*RedisReply) Uint64 ¶
func (this *RedisReply) Uint64() (uint64, error)
func (*RedisReply) Uint64s ¶
func (this *RedisReply) Uint64s() ([]uint64, error)
func (*RedisReply) Values ¶
func (this *RedisReply) Values() ([]interface{}, error)