Documentation
¶
Index ¶
- Constants
- func BindUserInfo(sess *RedisBackend, info map[string]string) error
- func BindUserRoles(sess *RedisBackend, uid string, roles []string) (string, error)
- func ConnectRedisPool(params schema.ConnParams) *rdspool.RedisPool
- func DelRedisHash(key string) bool
- func DelSession(token string) bool
- func SessListJoin(data []string) string
- func SessListSplit(data string) []string
- func SetRedisBackend(rdsConn rdspool.Redis)
- type ICacheBackend
- type RedisBackend
- func (b *RedisBackend) AddFlash(messages ...string) (int, error)
- func (b *RedisBackend) ClearAll() error
- func (b *RedisBackend) Close() error
- func (b *RedisBackend) Connect(params schema.ConnParams) error
- func (b *RedisBackend) GetFlashes(n int) ([]string, error)
- func (b *RedisBackend) GetName() string
- func (b *RedisBackend) SetRedisInst(pool rdspool.Redis) error
Constants ¶
View Source
const ( MAX_TIMEOUT = 86400 * 30 // 接近无限时间 SESS_ONLINE_KEY = "onlines" // 在线用户 SESS_PREFIX = "sess" // 会话缓存前缀 SESS_TIMEOUT = 7200 // 会话缓存时间 SESS_LIST_SEP = ";" // 角色名之间的分隔符 )
Variables ¶
This section is empty.
Functions ¶
func BindUserRoles ¶ added in v0.5.8
func BindUserRoles(sess *RedisBackend, uid string, roles []string) (string, error)
绑定用户角色,返回旧的sid
func DelRedisHash ¶
func DelSession ¶
func SessListJoin ¶
func SessListSplit ¶
func SetRedisBackend ¶
Types ¶
type ICacheBackend ¶
type ICacheBackend interface { Connect(params schema.ConnParams) error Close() error ClearAll() error GetName() string GetTimeout() int Set(key string, value interface{}) (int, error) Get(key string) (interface{}, error) GetInt(key string) (int, error) GetString(key string) (string, error) GetAll() (interface{}, error) AddFlash(messages ...string) (int, error) GetFlashes(n int) ([]string, error) }
缓存接口
type RedisBackend ¶
Redis哈希表缓存
func GetRedisHash ¶
func GetRedisHash(key string, timeout int) *RedisBackend
func GetSession ¶
func GetSession(token string) *RedisBackend
func (*RedisBackend) ClearAll ¶
func (b *RedisBackend) ClearAll() error
func (*RedisBackend) Close ¶
func (b *RedisBackend) Close() error
func (*RedisBackend) Connect ¶
func (b *RedisBackend) Connect(params schema.ConnParams) error
func (*RedisBackend) GetFlashes ¶
func (b *RedisBackend) GetFlashes(n int) ([]string, error)
数量n为最大取出多少条消息,-1表示所有消息
func (*RedisBackend) GetName ¶
func (b *RedisBackend) GetName() string
func (*RedisBackend) SetRedisInst ¶
func (b *RedisBackend) SetRedisInst(pool rdspool.Redis) error
Click to show internal directories.
Click to hide internal directories.