Versions in this module Expand all Collapse all v1 v1.16.9 Mar 28, 2022 v1.16.8 Mar 28, 2022 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 = gerror.NewOption(gerror.Option{ ... }) + func NewSessionId() string + type Manager struct + func New(ttl time.Duration, storage ...Storage) *Manager + func (m *Manager) New(ctx context.Context, 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) GetStructs(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(ctx context.Context, id string, key string) (value interface{}, err error) + GetMap func(ctx context.Context, id string) (data map[string]interface{}, err error) + GetSession func(ctx context.Context, id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + GetSize func(ctx context.Context, id string) (size int, err error) + New func(ctx context.Context, ttl time.Duration) (id string, err error) + Remove func(ctx context.Context, id string, key string) error + RemoveAll func(ctx context.Context, id string) error + Set func(ctx context.Context, id string, key string, value interface{}, ...) error + SetMap func(ctx context.Context, id string, data map[string]interface{}, ttl time.Duration) error + SetSession func(ctx context.Context, id string, data *gmap.StrAnyMap, ttl time.Duration) error + UpdateTTL func(ctx context.Context, id string, ttl time.Duration) error + type StorageFile struct + func NewStorageFile(path ...string) *StorageFile + func (s *StorageFile) Get(ctx context.Context, id string, key string) (value interface{}, err error) + func (s *StorageFile) GetMap(ctx context.Context, id string) (data map[string]interface{}, err error) + func (s *StorageFile) GetSession(ctx context.Context, id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + func (s *StorageFile) GetSize(ctx context.Context, id string) (size int, err error) + func (s *StorageFile) New(ctx context.Context, ttl time.Duration) (id string, err error) + func (s *StorageFile) Remove(ctx context.Context, id string, key string) error + func (s *StorageFile) RemoveAll(ctx context.Context, id string) error + func (s *StorageFile) Set(ctx context.Context, id string, key string, value interface{}, ...) error + func (s *StorageFile) SetCryptoEnabled(enabled bool) + func (s *StorageFile) SetCryptoKey(key []byte) + func (s *StorageFile) SetMap(ctx context.Context, id string, data map[string]interface{}, ttl time.Duration) error + func (s *StorageFile) SetSession(ctx context.Context, id string, data *gmap.StrAnyMap, ttl time.Duration) error + func (s *StorageFile) UpdateTTL(ctx context.Context, id string, ttl time.Duration) error + type StorageMemory struct + func NewStorageMemory() *StorageMemory + func (s *StorageMemory) Get(ctx context.Context, id string, key string) (value interface{}, err error) + func (s *StorageMemory) GetMap(ctx context.Context, id string) (data map[string]interface{}, err error) + func (s *StorageMemory) GetSession(ctx context.Context, id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + func (s *StorageMemory) GetSize(ctx context.Context, id string) (size int, err error) + func (s *StorageMemory) New(ctx context.Context, ttl time.Duration) (id string, err error) + func (s *StorageMemory) Remove(ctx context.Context, id string, key string) error + func (s *StorageMemory) RemoveAll(ctx context.Context, id string) error + func (s *StorageMemory) Set(ctx context.Context, id string, key string, value interface{}, ...) error + func (s *StorageMemory) SetMap(ctx context.Context, id string, data map[string]interface{}, ttl time.Duration) error + func (s *StorageMemory) SetSession(ctx context.Context, id string, data *gmap.StrAnyMap, ttl time.Duration) error + func (s *StorageMemory) UpdateTTL(ctx context.Context, id string, ttl time.Duration) error + type StorageRedis struct + func NewStorageRedis(redis *gredis.Redis, prefix ...string) *StorageRedis + func (s *StorageRedis) Get(ctx context.Context, id string, key string) (value interface{}, err error) + func (s *StorageRedis) GetMap(ctx context.Context, id string) (data map[string]interface{}, err error) + func (s *StorageRedis) GetSession(ctx context.Context, id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + func (s *StorageRedis) GetSize(ctx context.Context, id string) (size int, err error) + func (s *StorageRedis) New(ctx context.Context, ttl time.Duration) (id string, err error) + func (s *StorageRedis) Remove(ctx context.Context, id string, key string) error + func (s *StorageRedis) RemoveAll(ctx context.Context, id string) error + func (s *StorageRedis) Set(ctx context.Context, id string, key string, value interface{}, ...) error + func (s *StorageRedis) SetMap(ctx context.Context, id string, data map[string]interface{}, ttl time.Duration) error + func (s *StorageRedis) SetSession(ctx context.Context, id string, data *gmap.StrAnyMap, ttl time.Duration) error + func (s *StorageRedis) UpdateTTL(ctx context.Context, id string, ttl time.Duration) error + type StorageRedisHashTable struct + func NewStorageRedisHashTable(redis *gredis.Redis, prefix ...string) *StorageRedisHashTable + func (s *StorageRedisHashTable) Get(ctx context.Context, id string, key string) (value interface{}, err error) + func (s *StorageRedisHashTable) GetMap(ctx context.Context, id string) (data map[string]interface{}, err error) + func (s *StorageRedisHashTable) GetSession(ctx context.Context, id string, ttl time.Duration, data *gmap.StrAnyMap) (*gmap.StrAnyMap, error) + func (s *StorageRedisHashTable) GetSize(ctx context.Context, id string) (size int, err error) + func (s *StorageRedisHashTable) New(ctx context.Context, ttl time.Duration) (id string, err error) + func (s *StorageRedisHashTable) Remove(ctx context.Context, id string, key string) error + func (s *StorageRedisHashTable) RemoveAll(ctx context.Context, id string) error + func (s *StorageRedisHashTable) Set(ctx context.Context, id string, key string, value interface{}, ...) error + func (s *StorageRedisHashTable) SetMap(ctx context.Context, id string, data map[string]interface{}, ttl time.Duration) error + func (s *StorageRedisHashTable) SetSession(ctx context.Context, id string, data *gmap.StrAnyMap, ttl time.Duration) error + func (s *StorageRedisHashTable) UpdateTTL(ctx context.Context, id string, ttl time.Duration) error