session

package
v0.0.0-...-c9c189d Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrSessionExpired        = "session expired"
	ErrSessionAlreadyExists  = "session already exists"
	ErrSessionNotFound       = "session not found"
	ErrKeyNotFound           = "key not found"
	ErrWhileConnectingMysql  = "unable to connect to MySQL"
	ErrUnableSerializeJson   = "unable to serialize in json format"
	ErrSqlInsertQuery        = "error in SQL insert query"
	ErrSqlSelectQuery        = "error in SQL select query"
	ErrSqlUpdateQuery        = "error in SQL update query"
	ErrSqlDeleteQuery        = "error in SQL delete query"
	ErrParsingExpiresAt      = "error while parsing expires_at"
	ErrUnableUnserializeJson = "unable to unserialize json data"
	ErrInvTableName          = "invalid table name"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MysqlStore

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

func (*MysqlStore) Check

func (st *MysqlStore) Check(sid string) bool

Controlla se una sessione esiste (dato il sid).

func (*MysqlStore) CreateStore

func (st *MysqlStore) CreateStore() string

func (*MysqlStore) Delete

func (st *MysqlStore) Delete(sid string) error

Cancella un'intera sessione (dato il sid).

func (*MysqlStore) Get

func (st *MysqlStore) Get(sid string, key string) (interface{}, error)

Ottiene il valore di una chiave di una sessione (dati sid e key).

func (*MysqlStore) Init

func (st *MysqlStore) Init(tm time.Time) (string, error)

Inizializza una sessione, restituendo il sid.

func (*MysqlStore) InitStore

func (st *MysqlStore) InitStore(db interface{}, tableName string) error

Inizializza lo store.

func (*MysqlStore) Refresh

func (st *MysqlStore) Refresh(sid string) (string, error)

Duplica la sessione con il sid dato (che viene eliminata).

func (*MysqlStore) RemoveKey

func (st *MysqlStore) RemoveKey(sid string, key string) error

Cancella il valore collegato a una chiave di una sessione (dati sid e key).

func (*MysqlStore) Set

func (st *MysqlStore) Set(sid string, key string, value interface{}) error

Setta il valore di una chiave di una sessione (dati sid, key e value).

type RedisStore

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

func (*RedisStore) Check

func (st *RedisStore) Check(sid string) bool

func (*RedisStore) CreateStore

func (st *RedisStore) CreateStore() string

func (*RedisStore) Delete

func (st *RedisStore) Delete(sid string) error

func (*RedisStore) Get

func (st *RedisStore) Get(sid string, key string) (interface{}, error)

func (*RedisStore) Init

func (st *RedisStore) Init(tm time.Time) (string, error)

func (*RedisStore) InitStore

func (st *RedisStore) InitStore(client interface{}, prefix string) error

func (*RedisStore) Refresh

func (st *RedisStore) Refresh(sid string) (string, error)

func (*RedisStore) RemoveKey

func (st *RedisStore) RemoveKey(sid string, key string) error

func (*RedisStore) Set

func (st *RedisStore) Set(sid string, key string, value interface{}) error

type SessionData

type SessionData map[string]interface{}

type Store

type Store interface {
	CreateStore() string
	InitStore(interface{}, string) error
	Init(time.Time) (string, error)
	Check(string) bool
	Get(sid string, key string) (interface{}, error)
	Set(sid string, key string, value interface{}) error
	RemoveKey(sid string, key string) error
	Delete(sid string) error
	Refresh(sid string) (string, error)
}

Jump to

Keyboard shortcuts

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