Versions in this module Expand all Collapse all v0 v0.1.1 Mar 1, 2021 v0.1.0 Mar 1, 2021 Changes in this version + var DefaultStorageFileCryptoEnabled = false + var DefaultStorageFileCryptoKey = []byte("Session storage file crypto key!") + var DefaultStorageFileLoopInterval = 10 * time.Second + var DefaultStorageFilePath = gfile.TempDir("gsessions") + var DefaultStorageRedisLoopInterval = 10 * time.Second + var ErrorDisabled = errors.New("this feature is disabled in this storage") + func NewSessionId() string + type Manager struct + func New(ttl time.Duration, storage ...Storage) *Manager + func (m *Manager) New(sessionId ...string) *Session + func (m *Manager) SetStorage(storage Storage) + func (m *Manager) SetTTL(ttl time.Duration) + func (m *Manager) TTL() time.Duration + func (m *Manager) UpdateSessionTTL(sessionId string, data *gmap.StrAnyMap) + type Session struct + func (s *Session) Clear() error + func (s *Session) Close() + func (s *Session) Contains(key string) bool + func (s *Session) Get(key string, def ...interface{}) interface{} + func (s *Session) GetBool(key string, def ...interface{}) bool + func (s *Session) GetBytes(key string, def ...interface{}) []byte + func (s *Session) GetDuration(key string, def ...interface{}) time.Duration + func (s *Session) GetFloat32(key string, def ...interface{}) float32 + func (s *Session) GetFloat64(key string, def ...interface{}) float64 + func (s *Session) GetFloats(key string, def ...interface{}) []float64 + func (s *Session) GetGTime(key string, format ...string) *gtime.Time + func (s *Session) GetInt(key string, def ...interface{}) int + func (s *Session) GetInt16(key string, def ...interface{}) int16 + func (s *Session) GetInt32(key string, def ...interface{}) int32 + func (s *Session) GetInt64(key string, def ...interface{}) int64 + func (s *Session) GetInt8(key string, def ...interface{}) int8 + func (s *Session) GetInterfaces(key string, def ...interface{}) []interface{} + func (s *Session) GetInts(key string, def ...interface{}) []int + func (s *Session) GetMap(key string, tags ...string) map[string]interface{} + func (s *Session) GetMapDeep(key string, tags ...string) map[string]interface{} + func (s *Session) GetMaps(key string, tags ...string) []map[string]interface{} + func (s *Session) GetMapsDeep(key string, tags ...string) []map[string]interface{} + func (s *Session) GetString(key string, def ...interface{}) string + func (s *Session) GetStrings(key string, def ...interface{}) []string + func (s *Session) GetStruct(key string, pointer interface{}, mapping ...map[string]string) error + func (s *Session) GetStructDeep(key string, pointer interface{}, mapping ...map[string]string) error + func (s *Session) GetStructs(key string, pointer interface{}, mapping ...map[string]string) error + func (s *Session) GetStructsDeep(key string, pointer interface{}, mapping ...map[string]string) error + func (s *Session) GetTime(key string, format ...string) time.Time + func (s *Session) GetUint(key string, def ...interface{}) uint + func (s *Session) GetUint16(key string, def ...interface{}) uint16 + func (s *Session) GetUint32(key string, def ...interface{}) uint32 + func (s *Session) GetUint64(key string, def ...interface{}) uint64 + func (s *Session) GetUint8(key string, def ...interface{}) uint8 + func (s *Session) GetVar(key string, def ...interface{}) *gvar.Var + func (s *Session) Id() string + func (s *Session) IsDirty() bool + func (s *Session) Map() map[string]interface{} + func (s *Session) Remove(keys ...string) error + func (s *Session) RemoveAll() error + func (s *Session) Set(key string, value interface{}) error + func (s *Session) SetId(id string) error + func (s *Session) SetIdFunc(f func(ttl time.Duration) string) error + func (s *Session) SetMap(data map[string]interface{}) error + func (s *Session) Sets(data map[string]interface{}) error + func (s *Session) Size() int + type Storage interface + Get func(id string, key string) interface{} + GetMap func(id string) map[string]interface{} + GetSession func(id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + GetSize func(id string) int + New func(ttl time.Duration) (id string) + Remove func(id string, key string) error + RemoveAll func(id string) error + Set func(id string, key string, value interface{}, ttl time.Duration) error + SetMap func(id string, data map[string]interface{}, ttl time.Duration) error + SetSession func(id string, data *gmap.StrAnyMap, ttl time.Duration) error + UpdateTTL func(id string, ttl time.Duration) error + type StorageFile struct + func NewStorageFile(path ...string) *StorageFile + func (s *StorageFile) Get(id string, key string) interface{} + func (s *StorageFile) GetMap(id string) map[string]interface{} + func (s *StorageFile) GetSession(id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + func (s *StorageFile) GetSize(id string) int + func (s *StorageFile) New(ttl time.Duration) (id string) + func (s *StorageFile) Remove(id string, key string) error + func (s *StorageFile) RemoveAll(id string) error + func (s *StorageFile) Set(id string, key string, value interface{}, ttl time.Duration) error + func (s *StorageFile) SetCryptoEnabled(enabled bool) + func (s *StorageFile) SetCryptoKey(key []byte) + func (s *StorageFile) SetMap(id string, data map[string]interface{}, ttl time.Duration) error + func (s *StorageFile) SetSession(id string, data *gmap.StrAnyMap, ttl time.Duration) error + func (s *StorageFile) UpdateTTL(id string, ttl time.Duration) error + type StorageMemory struct + func NewStorageMemory() *StorageMemory + func (s *StorageMemory) Get(id string, key string) interface{} + func (s *StorageMemory) GetMap(id string) map[string]interface{} + func (s *StorageMemory) GetSession(id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + func (s *StorageMemory) GetSize(id string) int + func (s *StorageMemory) New(ttl time.Duration) (id string) + func (s *StorageMemory) Remove(id string, key string) error + func (s *StorageMemory) RemoveAll(id string) error + func (s *StorageMemory) Set(id string, key string, value interface{}, ttl time.Duration) error + func (s *StorageMemory) SetMap(id string, data map[string]interface{}, ttl time.Duration) error + func (s *StorageMemory) SetSession(id string, data *gmap.StrAnyMap, ttl time.Duration) error + func (s *StorageMemory) UpdateTTL(id string, ttl time.Duration) error + type StorageRedis struct + func NewStorageRedis(redis *gredis.Redis, prefix ...string) *StorageRedis + func (s *StorageRedis) Get(id string, key string) interface{} + func (s *StorageRedis) GetMap(id string) map[string]interface{} + func (s *StorageRedis) GetSession(id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + func (s *StorageRedis) GetSize(id string) int + func (s *StorageRedis) New(ttl time.Duration) (id string) + func (s *StorageRedis) Remove(id string, key string) error + func (s *StorageRedis) RemoveAll(id string) error + func (s *StorageRedis) Set(id string, key string, value interface{}, ttl time.Duration) error + func (s *StorageRedis) SetMap(id string, data map[string]interface{}, ttl time.Duration) error + func (s *StorageRedis) SetSession(id string, data *gmap.StrAnyMap, ttl time.Duration) error + func (s *StorageRedis) UpdateTTL(id string, ttl time.Duration) error + type StorageRedisHashTable struct + func NewStorageRedisHashTable(redis *gredis.Redis, prefix ...string) *StorageRedisHashTable + func (s *StorageRedisHashTable) Get(id string, key string) interface{} + func (s *StorageRedisHashTable) GetMap(id string) map[string]interface{} + func (s *StorageRedisHashTable) GetSession(id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + func (s *StorageRedisHashTable) GetSize(id string) int + func (s *StorageRedisHashTable) New(ttl time.Duration) (id string) + func (s *StorageRedisHashTable) Remove(id string, key string) error + func (s *StorageRedisHashTable) RemoveAll(id string) error + func (s *StorageRedisHashTable) Set(id string, key string, value interface{}, ttl time.Duration) error + func (s *StorageRedisHashTable) SetMap(id string, data map[string]interface{}, ttl time.Duration) error + func (s *StorageRedisHashTable) SetSession(id string, data *gmap.StrAnyMap, ttl time.Duration) error + func (s *StorageRedisHashTable) UpdateTTL(id string, ttl time.Duration) error