session

package
v1.18.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 16 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBProvider added in v1.14.0

type DBProvider struct {
	// contains filtered or unexported fields
}

DBProvider represents a DB session provider implementation.

func (*DBProvider) Count added in v1.14.0

func (p *DBProvider) Count() int

Count counts and returns number of sessions.

func (*DBProvider) Destroy added in v1.14.0

func (p *DBProvider) Destroy(sid string) error

Destroy deletes a session by session ID.

func (*DBProvider) Exist added in v1.14.0

func (p *DBProvider) Exist(sid string) bool

Exist returns true if session with given ID exists.

func (*DBProvider) GC added in v1.14.0

func (p *DBProvider) GC()

GC calls GC to clean expired sessions.

func (*DBProvider) Init added in v1.14.0

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 added in v1.14.0

func (p *DBProvider) Read(sid string) (session.RawStore, error)

Read returns raw session store by session ID.

func (*DBProvider) Regenerate added in v1.14.0

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 added in v1.14.0

type DBStore struct {
	// contains filtered or unexported fields
}

DBStore represents a session store implementation based on the DB.

func NewDBStore added in v1.14.0

func NewDBStore(sid string, kv map[interface{}]interface{}) *DBStore

NewDBStore creates and returns a DB session store.

func (*DBStore) Delete added in v1.14.0

func (s *DBStore) Delete(key interface{}) error

Delete delete a key from session.

func (*DBStore) Flush added in v1.14.0

func (s *DBStore) Flush() error

Flush deletes all session data.

func (*DBStore) Get added in v1.14.0

func (s *DBStore) Get(key interface{}) interface{}

Get gets value by given key in session.

func (*DBStore) ID added in v1.14.0

func (s *DBStore) ID() string

ID returns current session ID.

func (*DBStore) Release added in v1.14.0

func (s *DBStore) Release() error

Release releases resource and save data to provider.

func (*DBStore) Set added in v1.14.0

func (s *DBStore) Set(key, val interface{}) error

Set sets value to given key in session.

type RedisProvider added in v1.13.0

type RedisProvider struct {
	// contains filtered or unexported fields
}

RedisProvider represents a redis session provider implementation.

func (*RedisProvider) Count added in v1.13.0

func (p *RedisProvider) Count() int

Count counts and returns number of sessions.

func (*RedisProvider) Destroy added in v1.13.0

func (p *RedisProvider) Destroy(sid string) error

Destroy deletes a session by session ID.

func (*RedisProvider) Exist added in v1.13.0

func (p *RedisProvider) Exist(sid string) bool

Exist returns true if session with given ID exists.

func (*RedisProvider) GC added in v1.13.0

func (*RedisProvider) GC()

GC calls GC to clean expired sessions.

func (*RedisProvider) Init added in v1.13.0

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 added in v1.13.0

func (p *RedisProvider) Read(sid string) (session.RawStore, error)

Read returns raw session store by session ID.

func (*RedisProvider) Regenerate added in v1.13.0

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 added in v1.13.0

type RedisStore struct {
	// contains filtered or unexported fields
}

RedisStore represents a redis session store implementation.

func NewRedisStore added in v1.13.0

func NewRedisStore(c redis.UniversalClient, prefix, sid string, dur time.Duration, kv map[interface{}]interface{}) *RedisStore

NewRedisStore creates and returns a redis session store.

func (*RedisStore) Delete added in v1.13.0

func (s *RedisStore) Delete(key interface{}) error

Delete delete a key from session.

func (*RedisStore) Flush added in v1.13.0

func (s *RedisStore) Flush() error

Flush deletes all session data.

func (*RedisStore) Get added in v1.13.0

func (s *RedisStore) Get(key interface{}) interface{}

Get gets value by given key in session.

func (*RedisStore) ID added in v1.13.0

func (s *RedisStore) ID() string

ID returns current session ID.

func (*RedisStore) Release added in v1.13.0

func (s *RedisStore) Release() error

Release releases resource and save data to provider.

func (*RedisStore) Set added in v1.13.0

func (s *RedisStore) Set(key, val interface{}) error

Set sets value to given key in session.

type Store added in v1.14.0

type Store interface {
	Get(interface{}) interface{}
	Set(interface{}, interface{}) error
	Delete(interface{}) error
}

Store represents a session store

func RegenerateSession added in v1.15.8

func RegenerateSession(resp http.ResponseWriter, req *http.Request) (Store, error)

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 added in v1.10.0

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

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[interface{}]interface{}) *VirtualStore

NewVirtualStore creates and returns a virtual session store.

func (*VirtualStore) Delete

func (s *VirtualStore) Delete(key interface{}) error

Delete delete a key from session.

func (*VirtualStore) Flush

func (s *VirtualStore) Flush() error

Flush deletes all session data.

func (*VirtualStore) Get

func (s *VirtualStore) Get(key interface{}) interface{}

Get gets value by given key in session.

func (*VirtualStore) ID

func (s *VirtualStore) ID() string

ID returns current session ID.

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 interface{}) error

Set sets value to given key in session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL