Versions in this module Expand all Collapse all v2 v2.7.2 Aug 2, 2024 Changes in this version + const DefaultStorageFileClearExpiredInterval + const DefaultStorageFileCryptoEnabled + const DefaultStorageFileUpdateTTLInterval + const DefaultStorageRedisLoopInterval + var DefaultStorageFileCryptoKey = []byte("Session storage file crypto key!") + var DefaultStorageFilePath = gfile.Temp("gsessions") + var ErrorDisabled = gerror.NewWithOption(gerror.Option{ ... }) + func NewSessionId() string + type Manager struct + func New(ttl time.Duration, storage ...Storage) *Manager + func (m *Manager) GetStorage() Storage + func (m *Manager) GetTTL() time.Duration + func (m *Manager) New(ctx context.Context, sessionId ...string) *Session + func (m *Manager) SetStorage(storage Storage) + func (m *Manager) SetTTL(ttl time.Duration) + type Session struct + func (s *Session) Close() error + func (s *Session) Contains(key string) (ok bool, err error) + func (s *Session) Data() (sessionData map[string]interface{}, err error) + func (s *Session) Get(key string, def ...interface{}) (value *gvar.Var, err error) + func (s *Session) Id() (id string, err error) + func (s *Session) IsDirty() bool + func (s *Session) MustContains(key string) bool + func (s *Session) MustData() map[string]interface{} + func (s *Session) MustGet(key string, def ...interface{}) *gvar.Var + func (s *Session) MustId() string + func (s *Session) MustRemove(keys ...string) + func (s *Session) MustSet(key string, value interface{}) + func (s *Session) MustSetMap(data map[string]interface{}) + func (s *Session) MustSize() int + func (s *Session) Remove(keys ...string) (err error) + func (s *Session) RemoveAll() (err error) + func (s *Session) Set(key string, value interface{}) (err 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{}) (err error) + func (s *Session) Size() (size int, err error) + type Storage interface + Data func(ctx context.Context, sessionId string) (sessionData map[string]interface{}, err error) + Get func(ctx context.Context, sessionId string, key string) (value interface{}, err error) + GetSession func(ctx context.Context, sessionId string, ttl time.Duration) (*gmap.StrAnyMap, error) + GetSize func(ctx context.Context, sessionId string) (size int, err error) + New func(ctx context.Context, ttl time.Duration) (sessionId string, err error) + Remove func(ctx context.Context, sessionId string, key string) error + RemoveAll func(ctx context.Context, sessionId string) error + Set func(ctx context.Context, sessionId string, key string, value interface{}, ...) error + SetMap func(ctx context.Context, sessionId string, mapData map[string]interface{}, ...) error + SetSession func(ctx context.Context, sessionId string, sessionData *gmap.StrAnyMap, ...) error + UpdateTTL func(ctx context.Context, sessionId string, ttl time.Duration) error + type StorageBase struct + func (s *StorageBase) Data(ctx context.Context, sessionId string) (sessionData map[string]interface{}, err error) + func (s *StorageBase) Get(ctx context.Context, sessionId string, key string) (value interface{}, err error) + func (s *StorageBase) GetSession(ctx context.Context, sessionId string, ttl time.Duration) (*gmap.StrAnyMap, error) + func (s *StorageBase) GetSize(ctx context.Context, sessionId string) (size int, err error) + func (s *StorageBase) New(ctx context.Context, ttl time.Duration) (id string, err error) + func (s *StorageBase) Remove(ctx context.Context, sessionId string, key string) error + func (s *StorageBase) RemoveAll(ctx context.Context, sessionId string) error + func (s *StorageBase) Set(ctx context.Context, sessionId string, key string, value interface{}, ...) error + func (s *StorageBase) SetMap(ctx context.Context, sessionId string, mapData map[string]interface{}, ...) error + func (s *StorageBase) SetSession(ctx context.Context, sessionId string, sessionData *gmap.StrAnyMap, ...) error + func (s *StorageBase) UpdateTTL(ctx context.Context, sessionId string, ttl time.Duration) error + type StorageFile struct + func NewStorageFile(path string, ttl time.Duration) *StorageFile + func (s *StorageFile) GetSession(ctx context.Context, sessionId string, ttl time.Duration) (sessionData *gmap.StrAnyMap, err error) + func (s *StorageFile) RemoveAll(ctx context.Context, sessionId string) error + func (s *StorageFile) SetCryptoEnabled(enabled bool) + func (s *StorageFile) SetCryptoKey(key []byte) + func (s *StorageFile) SetSession(ctx context.Context, sessionId string, sessionData *gmap.StrAnyMap, ...) error + func (s *StorageFile) UpdateTTL(ctx context.Context, sessionId string, ttl time.Duration) error + type StorageMemory struct + func NewStorageMemory() *StorageMemory + func (s *StorageMemory) GetSession(ctx context.Context, sessionId string, ttl time.Duration) (*gmap.StrAnyMap, error) + func (s *StorageMemory) RemoveAll(ctx context.Context, sessionId string) error + func (s *StorageMemory) SetSession(ctx context.Context, sessionId string, sessionData *gmap.StrAnyMap, ...) error + func (s *StorageMemory) UpdateTTL(ctx context.Context, sessionId string, ttl time.Duration) error + type StorageRedis struct + func NewStorageRedis(redis *gredis.Redis, prefix ...string) *StorageRedis + func (s *StorageRedis) GetSession(ctx context.Context, sessionId string, ttl time.Duration) (*gmap.StrAnyMap, error) + func (s *StorageRedis) RemoveAll(ctx context.Context, sessionId string) error + func (s *StorageRedis) SetSession(ctx context.Context, sessionId string, sessionData *gmap.StrAnyMap, ...) error + func (s *StorageRedis) UpdateTTL(ctx context.Context, sessionId string, ttl time.Duration) error + type StorageRedisHashTable struct + func NewStorageRedisHashTable(redis *gredis.Redis, prefix ...string) *StorageRedisHashTable + func (s *StorageRedisHashTable) Data(ctx context.Context, sessionId string) (data map[string]interface{}, err error) + func (s *StorageRedisHashTable) Get(ctx context.Context, sessionId string, key string) (value interface{}, err error) + func (s *StorageRedisHashTable) GetSession(ctx context.Context, sessionId string, ttl time.Duration) (*gmap.StrAnyMap, error) + func (s *StorageRedisHashTable) GetSize(ctx context.Context, sessionId string) (size int, err error) + func (s *StorageRedisHashTable) Remove(ctx context.Context, sessionId string, key string) error + func (s *StorageRedisHashTable) RemoveAll(ctx context.Context, sessionId string) error + func (s *StorageRedisHashTable) Set(ctx context.Context, sessionId string, key string, value interface{}, ...) error + func (s *StorageRedisHashTable) SetMap(ctx context.Context, sessionId string, data map[string]interface{}, ...) error + func (s *StorageRedisHashTable) SetSession(ctx context.Context, sessionId string, sessionData *gmap.StrAnyMap, ...) error + func (s *StorageRedisHashTable) UpdateTTL(ctx context.Context, sessionId string, ttl time.Duration) error