redis

package
v0.0.0-...-7ed19cd Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database the redis back-end session database for the sessions.

func New

func New(cfg ...service.Config) *Database

New returns a new redis database.

func (*Database) Acquire

func (db *Database) Acquire(sid string, expires time.Duration) sessions.LifeTime

Acquire receives a session's lifetime from the database, if the return value is LifeTime{} then the session manager sets the life time based on the expiration duration lives in configuration.

func (*Database) Clear

func (db *Database) Clear(sid string)

Clear removes all session key values but it keeps the session entry.

func (*Database) Close

func (db *Database) Close() error

Close terminates the redis connection.

func (*Database) Config

func (db *Database) Config() *service.Config

Config returns the configuration for the redis server bridge, you can change them.

func (*Database) Delete

func (db *Database) Delete(sid string, key string) (deleted bool)

Delete removes a session key value based on its key.

func (*Database) Get

func (db *Database) Get(sid string, key string) (value interface{})

Get retrieves a session value based on the key.

func (*Database) Len

func (db *Database) Len(sid string) (n int)

Len returns the length of the session's entries (keys).

func (*Database) OnUpdateExpiration

func (db *Database) OnUpdateExpiration(sid string, newExpires time.Duration) error

OnUpdateExpiration will re-set the database's session's entry ttl. https://redis.io/commands/expire#refreshing-expires

func (*Database) Release

func (db *Database) Release(sid string)

Release destroys the session, it clears and removes the session entry, session manager will create a new session ID on the next request after this call.

func (*Database) Set

func (db *Database) Set(sid string, lifetime sessions.LifeTime, key string, value interface{}, immutable bool)

Set sets a key value of a specific session. Ignore the "immutable".

func (*Database) Visit

func (db *Database) Visit(sid string, cb func(key string, value interface{}))

Visit loops through all session keys and values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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