Documentation ¶
Index ¶
- Variables
- type DBProvider
- func (p *DBProvider) Count() int
- func (p *DBProvider) Destroy(sid string) error
- func (p *DBProvider) Exist(sid string) bool
- func (p *DBProvider) GC()
- func (p *DBProvider) Init(maxLifetime int64, connStr string) error
- func (p *DBProvider) Read(sid string) (session.RawStore, error)
- func (p *DBProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)
- type DBStore
- type MockStore
- type RedisProvider
- func (p *RedisProvider) Count() int
- func (p *RedisProvider) Destroy(sid string) error
- func (p *RedisProvider) Exist(sid string) bool
- func (*RedisProvider) GC()
- func (p *RedisProvider) Init(maxlifetime int64, configs string) (err error)
- func (p *RedisProvider) Read(sid string) (session.RawStore, error)
- func (p *RedisProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)
- type RedisStore
- type Store
- type VirtualSessionProvider
- func (o *VirtualSessionProvider) Count() int
- func (o *VirtualSessionProvider) Destroy(sid string) error
- func (o *VirtualSessionProvider) Exist(sid string) bool
- func (o *VirtualSessionProvider) GC()
- func (o *VirtualSessionProvider) Init(gclifetime int64, config string) error
- func (o *VirtualSessionProvider) Read(sid string) (session.RawStore, error)
- func (o *VirtualSessionProvider) Regenerate(oldsid, sid string) (session.RawStore, error)
- type VirtualStore
Constants ¶
This section is empty.
Variables ¶
var BeforeRegenerateSession []func(http.ResponseWriter, *http.Request)
BeforeRegenerateSession is a list of functions that are called before a session is regenerated.
var MockStoreContextKey = mockStoreContextKeyStruct{}
Functions ¶
This section is empty.
Types ¶
type DBProvider ¶
type DBProvider struct {
// contains filtered or unexported fields
}
DBProvider represents a DB session provider implementation.
func (*DBProvider) Count ¶
func (p *DBProvider) Count() int
Count counts and returns number of sessions.
func (*DBProvider) Destroy ¶
func (p *DBProvider) Destroy(sid string) error
Destroy deletes a session by session ID.
func (*DBProvider) Exist ¶
func (p *DBProvider) Exist(sid string) bool
Exist returns true if session with given ID exists.
func (*DBProvider) Init ¶
func (p *DBProvider) Init(maxLifetime int64, connStr string) error
Init initializes DB session provider. connStr: username:password@protocol(address)/dbname?param=value
func (*DBProvider) Read ¶
func (p *DBProvider) Read(sid string) (session.RawStore, error)
Read returns raw session store by session ID.
func (*DBProvider) Regenerate ¶
func (p *DBProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)
Regenerate regenerates a session store from old session ID to new one.
type DBStore ¶
type DBStore struct {
// contains filtered or unexported fields
}
DBStore represents a session store implementation based on the DB.
func NewDBStore ¶
NewDBStore creates and returns a DB session store.
type MockStore ¶
func NewMockStore ¶
type RedisProvider ¶
type RedisProvider struct {
// contains filtered or unexported fields
}
RedisProvider represents a redis session provider implementation.
func (*RedisProvider) Count ¶
func (p *RedisProvider) Count() int
Count counts and returns number of sessions.
func (*RedisProvider) Destroy ¶
func (p *RedisProvider) Destroy(sid string) error
Destroy deletes a session by session ID.
func (*RedisProvider) Exist ¶
func (p *RedisProvider) Exist(sid string) bool
Exist returns true if session with given ID exists.
func (*RedisProvider) Init ¶
func (p *RedisProvider) Init(maxlifetime int64, configs string) (err error)
Init initializes redis session provider. configs: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180,prefix=session;
func (*RedisProvider) Read ¶
func (p *RedisProvider) Read(sid string) (session.RawStore, error)
Read returns raw session store by session ID.
func (*RedisProvider) Regenerate ¶
func (p *RedisProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)
Regenerate regenerates a session store from old session ID to new one.
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore represents a redis session store implementation.
func NewRedisStore ¶
func NewRedisStore(c redis.UniversalClient, prefix, sid string, dur time.Duration, kv map[any]any) *RedisStore
NewRedisStore creates and returns a redis session store.
func (*RedisStore) Delete ¶
func (s *RedisStore) Delete(key any) error
Delete delete a key from session.
func (*RedisStore) Get ¶
func (s *RedisStore) Get(key any) any
Get gets value by given key in session.
func (*RedisStore) Release ¶
func (s *RedisStore) Release() error
Release releases resource and save data to provider.
func (*RedisStore) Set ¶
func (s *RedisStore) Set(key, val any) error
Set sets value to given key in session.
type Store ¶
type Store interface { Get(any) any Set(any, any) error Delete(any) error ID() string Release() error Flush() error Destroy(http.ResponseWriter, *http.Request) error }
Store represents a session store
func GetContextSession ¶
func RegenerateSession ¶
RegenerateSession regenerates the underlying session and returns the new store
type VirtualSessionProvider ¶
type VirtualSessionProvider struct {
// contains filtered or unexported fields
}
VirtualSessionProvider represents a shadowed session provider implementation.
func (*VirtualSessionProvider) Count ¶
func (o *VirtualSessionProvider) Count() int
Count counts and returns number of sessions.
func (*VirtualSessionProvider) Destroy ¶
func (o *VirtualSessionProvider) Destroy(sid string) error
Destroy deletes a session by session ID.
func (*VirtualSessionProvider) Exist ¶
func (o *VirtualSessionProvider) Exist(sid string) bool
Exist returns true if session with given ID exists.
func (*VirtualSessionProvider) GC ¶
func (o *VirtualSessionProvider) GC()
GC calls GC to clean expired sessions.
func (*VirtualSessionProvider) Init ¶
func (o *VirtualSessionProvider) Init(gclifetime int64, config string) error
Init initializes the cookie session provider with given root path.
func (*VirtualSessionProvider) Read ¶
func (o *VirtualSessionProvider) Read(sid string) (session.RawStore, error)
Read returns raw session store by session ID.
func (*VirtualSessionProvider) Regenerate ¶
func (o *VirtualSessionProvider) Regenerate(oldsid, sid string) (session.RawStore, error)
Regenerate regenerates a session store from old session ID to new one.
type VirtualStore ¶
type VirtualStore struct {
// contains filtered or unexported fields
}
VirtualStore represents a virtual session store implementation.
func NewVirtualStore ¶
func NewVirtualStore(p *VirtualSessionProvider, sid string, kv map[any]any) *VirtualStore
NewVirtualStore creates and returns a virtual session store.
func (*VirtualStore) Delete ¶
func (s *VirtualStore) Delete(key any) error
Delete delete a key from session.
func (*VirtualStore) Get ¶
func (s *VirtualStore) Get(key any) any
Get gets value by given key in session.
func (*VirtualStore) Release ¶
func (s *VirtualStore) Release() error
Release releases resource and save data to provider.
func (*VirtualStore) Set ¶
func (s *VirtualStore) Set(key, val any) error
Set sets value to given key in session.