Documentation ¶
Index ¶
- Constants
- Variables
- type JSON
- type M
- type MemoryStore
- type MemoryStoreInfo
- type Options
- type RedisStore
- type Session
- func (sess *Session) Commit() (err error)
- func (sess *Session) Destroy() (err error)
- func (sess *Session) Fetch() (m M, err error)
- func (sess *Session) Get(key string) interface{}
- func (sess *Session) GetBool(key string) bool
- func (sess *Session) GetCreatedAt() string
- func (sess *Session) GetData() M
- func (sess *Session) GetFloat64(key string) float64
- func (sess *Session) GetInt(key string) int
- func (sess *Session) GetString(key string) string
- func (sess *Session) GetStringSlice(key string) []string
- func (sess *Session) GetUpdatedAt() string
- func (sess *Session) Refresh() (err error)
- func (sess *Session) RegenerateCookie()
- func (sess *Session) Set(key string, value interface{}) (err error)
- func (sess *Session) SetMap(value map[string]interface{}) (err error)
- type Store
Constants ¶
View Source
const ( // CreatedAt the created time for session CreatedAt = "_createdAt" // UpdatedAt the updated time for session UpdatedAt = "_updatedAt" )
Variables ¶
View Source
var ( // ErrNotFetched not fetch error ErrNotFetched = errors.New("Not fetch session") )
View Source
var ( // ErrNotInit error not init ErrNotInit = errors.New("client not init") )
Functions ¶
This section is empty.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore memory store for session
func NewMemoryStore ¶
func NewMemoryStore(size int) (store *MemoryStore, err error)
NewMemoryStore create new memory store instance
func (*MemoryStore) Destroy ¶
func (ms *MemoryStore) Destroy(key string) (err error)
Destroy remove the session from memory
type MemoryStoreInfo ¶
MemoryStoreInfo memory store info
type Options ¶
type Options struct { // cookie key, default is sess Key string // the max age for session data MaxAge int // the session store Store Store // function to generate session id GenID func() string CookieOptions *cookies.Options // JSON json Unmarshal/Marshal interface JSON JSON }
Options new session options
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore redis store for session
func NewRedisStore ¶
func NewRedisStore(client *redis.Client, opts *redis.Options) *RedisStore
NewRedisStore create new redis store instance
func (*RedisStore) Destroy ¶
func (rs *RedisStore) Destroy(key string) error
Destroy remove the session from redis
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session session struct
func (*Session) GetCreatedAt ¶
GetCreatedAt get the created at of session
func (*Session) GetFloat64 ¶
GetFloat64 get float64 data from session's data
func (*Session) GetStringSlice ¶
GetStringSlice get string slice data from session's data
func (*Session) GetUpdatedAt ¶
GetUpdatedAt get the updated at of session
func (*Session) RegenerateCookie ¶
func (sess *Session) RegenerateCookie()
RegenerateCookie regenerate the session's cookie
Click to show internal directories.
Click to hide internal directories.