Documentation ¶
Index ¶
- type NewStoreOptions
- type Session
- type SessionOptions
- type Store
- func (st *Store) AutoMigrate() error
- func (st *Store) Delete(sessionKey string, options SessionOptions) (bool, error)
- func (st *Store) DriverName(db *sql.DB) string
- func (st *Store) EnableDebug(debug bool)
- func (st *Store) ExpireSessionGoroutine() error
- func (st *Store) Extend(sessionKey string, seconds int64, options SessionOptions) error
- func (st *Store) FindByKey(sessionKey string, options SessionOptions) (*Session, error)
- func (st *Store) Get(sessionKey string, valueDefault string, options SessionOptions) (string, error)
- func (st *Store) GetAny(key string, valueDefault interface{}, options SessionOptions) (interface{}, error)
- func (st *Store) GetMap(key string, valueDefault map[string]any, options SessionOptions) (map[string]any, error)
- func (st *Store) Has(sessionKey string, options SessionOptions) (bool, error)
- func (st *Store) MergeMap(key string, mergeMap map[string]any, seconds int64, options SessionOptions) error
- func (st *Store) SQLCreateTable() string
- func (st *Store) Set(sessionKey string, value string, seconds int64, options SessionOptions) error
- func (st *Store) SetAny(key string, value interface{}, seconds int64, options SessionOptions) error
- func (st *Store) SetMap(key string, value map[string]any, seconds int64, options SessionOptions) error
- type StoreInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NewStoreOptions ¶ added in v0.15.0
type NewStoreOptions struct { SessionTableName string DB *sql.DB DbDriverName string TimeoutSeconds int64 AutomigrateEnabled bool DebugEnabled bool }
NewStoreOptions define the options for creating a new session store
type Session ¶
type Session struct { ID string `db:"id"` // varchar(40), primary key Key string `db:"session_key"` // varchar(40) UserID string `db:"user_id"` // varchar(40) IPAddress string `db:"ip_address"` // varchar(50) UserAgent string `db:"user_agent"` // varchar(1024) Value string `db:"session_value"` // long text ExpiresAt *time.Time `db:"expires_at"` // datetime NOT NULL CreatedAt time.Time `db:"created_at"` // datetime NOT NULL UpdatedAt time.Time `db:"updated_at"` // datetime NOT NULL DeletedAt *time.Time `db:"deleted_at"` // datetime DEFAULT NULL }
Session type
type SessionOptions ¶ added in v0.20.0
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store defines a session store
func NewStore ¶
func NewStore(opts NewStoreOptions) (*Store, error)
NewStore creates a new session store
func (*Store) Delete ¶
func (st *Store) Delete(sessionKey string, options SessionOptions) (bool, error)
Delete deletes a session
func (*Store) DriverName ¶
DriverName finds the driver name from database
func (*Store) EnableDebug ¶
EnableDebug - enables the debug option
func (*Store) ExpireSessionGoroutine ¶
ExpireSessionGoroutine - soft deletes expired cache
func (*Store) Extend ¶ added in v0.22.0
func (st *Store) Extend(sessionKey string, seconds int64, options SessionOptions) error
func (*Store) FindByKey ¶
func (st *Store) FindByKey(sessionKey string, options SessionOptions) (*Session, error)
FindByKey finds a session by key
func (*Store) Get ¶
func (st *Store) Get(sessionKey string, valueDefault string, options SessionOptions) (string, error)
Gets the session value as a string
func (*Store) GetAny ¶ added in v0.19.0
func (st *Store) GetAny(key string, valueDefault interface{}, options SessionOptions) (interface{}, error)
GetAny attempts to parse the value as interface, use with SetAny
func (*Store) GetMap ¶ added in v0.19.0
func (st *Store) GetMap(key string, valueDefault map[string]any, options SessionOptions) (map[string]any, error)
GetMap attempts to parse the value as map[string]any, use with SetMap
func (*Store) Has ¶ added in v0.9.0
func (st *Store) Has(sessionKey string, options SessionOptions) (bool, error)
Has finds if a session by key exists
func (*Store) SQLCreateTable ¶
SQLCreateTable returns a SQL string for creating the cache table
type StoreInterface ¶ added in v0.20.0
type StoreInterface interface { EnableDebug(debug bool) AutoMigrate() error Extend(sessionKey string, seconds int64, options SessionOptions) error Get(key string, valueDefault string, options SessionOptions) (string, error) GetAny(key string, valueDefault interface{}, options SessionOptions) (interface{}, error) GetMap(key string, valueDefault map[string]any, options SessionOptions) (map[string]any, error) MergeMap(key string, mergeMap map[string]any, seconds int64, options SessionOptions) error Set(key string, value string, seconds int64, options SessionOptions) error SetAny(key string, value interface{}, seconds int64, options SessionOptions) error SetMap(key string, value map[string]any, seconds int64, options SessionOptions) error Delete(sessionKey string, options SessionOptions) (bool, error) DriverName(db *sql.DB) string }
Click to show internal directories.
Click to hide internal directories.