Documentation
¶
Index ¶
- type Handler
- type Memory
- type Redis
- type Session
- type StorableSession
- type StorableSessionGenerater
- type XinSession
- func (s *XinSession) Delete(key string) error
- func (s *XinSession) Get(key string) (interface{}, bool)
- func (s *XinSession) GetTTL() int
- func (s *XinSession) HasNewContent() bool
- func (s *XinSession) Marshal() (result []byte, err error)
- func (s *XinSession) Set(key string, value interface{}) error
- func (s *XinSession) SetTTL(ttl int) error
- func (s *XinSession) Unmarshal(raw []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface { //Load a Session by sessionID Load(sessionID string) (session Session, found bool, err error) //Save a Session with given sessionID Save(sessionID string, session Session) (ttl int, err error) }
Handler session Handler
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory memor Session implement for test perpose
type Redis ¶
type Redis struct { TTL int // contains filtered or unexported fields }
Redis redis session handler
func NewRedisHandler ¶
func NewRedisHandler(store *redis.Client, ttl int, generater StorableSessionGenerater) *Redis
NewRedisHandler NewRedisHandler
func NewXinRedisHandler ¶
NewXinRedisHandler return a redis handler use xinSession as generater
type Session ¶
type Session interface { // Get session content by key Get(key string) (value interface{}, exists bool) // Set session content by key Set(key string, value interface{}) error // Delete session content by key Delete(key string) error // SetTTL set session ttl second SetTTL(ttl int) error // GetTTL get session ttl second GetTTL() int }
Session session interface
type StorableSession ¶
type StorableSession interface { Session // whether Session struct has new content after last generate HasNewContent() bool // marshal session into byte Marshal() (result []byte, err error) // unmarshal session from byte Unmarshal(raw []byte) (err error) }
StorableSession storable session interface
type StorableSessionGenerater ¶
type StorableSessionGenerater func() StorableSession
StorableSessionGenerater StorableSessionGenerater
type XinSession ¶
type XinSession struct { Values map[string]interface{} // contains filtered or unexported fields }
XinSession a simple implementation of Session interface
func (*XinSession) Get ¶
func (s *XinSession) Get(key string) (interface{}, bool)
Get implement Session
func (*XinSession) HasNewContent ¶
func (s *XinSession) HasNewContent() bool
HasNewContent implement StorableSession
func (*XinSession) Marshal ¶
func (s *XinSession) Marshal() (result []byte, err error)
Marshal implement StorableSession
func (*XinSession) Set ¶
func (s *XinSession) Set(key string, value interface{}) error
Set implement Session
func (*XinSession) Unmarshal ¶
func (s *XinSession) Unmarshal(raw []byte) (err error)
Unmarshal implement StorableSession
Click to show internal directories.
Click to hide internal directories.