Documentation
ΒΆ
Index ΒΆ
Constants ΒΆ
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_EXPIRES_AT = "expires_at"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_IP_ADDRESS = "ip_address"
View Source
const COLUMN_SESSION_KEY = "session_key"
View Source
const COLUMN_SESSION_VALUE = "session_value"
View Source
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const COLUMN_USER_AGENT = "user_agent"
View Source
const COLUMN_USER_ID = "user_id"
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type NewStoreOptions ΒΆ
type NewStoreOptions struct {
SessionTableName string
DB *sql.DB
DbDriverName string
TimeoutSeconds int64
AutomigrateEnabled bool
DebugEnabled bool
SqlLogger *slog.Logger
EncryptionEnabled bool
EncryptionKey []byte
}
NewStoreOptions define the options for creating a new session store
type SessionInterface ΒΆ
type SessionInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
IsExpired() bool
IsSoftDeleted() bool
GetID() string
SetID(id string) SessionInterface
GetKey() string
SetKey(key string) SessionInterface
GetUserID() string
SetUserID(userID string) SessionInterface
GetIPAddress() string
SetIPAddress(ipAddress string) SessionInterface
GetUserAgent() string
SetUserAgent(userAgent string) SessionInterface
GetValue() string
SetValue(value string) SessionInterface
GetExpiresAt() string
GetExpiresAtCarbon() *carbon.Carbon
SetExpiresAt(expiresAt string) SessionInterface
GetCreatedAt() string
GetCreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) SessionInterface
GetUpdatedAt() string
GetUpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string) SessionInterface
GetSoftDeletedAt() string
GetSoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(deletedAt string) SessionInterface
}
func NewSessionFromExistingData ΒΆ
func NewSessionFromExistingData(data map[string]string) SessionInterface
NewSessionFromExistingData creates a new session from existing data.
type SessionOptionsInterface ΒΆ
type SessionOptionsInterface interface {
HasUserID() bool
GetUserID() string
SetUserID(userID string)
HasIPAddress() bool
GetIPAddress() string
SetIPAddress(ipAddress string)
HasUserAgent() bool
GetUserAgent() string
SetUserAgent(userAgent string)
}
SessionOptionsInterface is an interface for session options
func NewSessionOptions ΒΆ
func NewSessionOptions() SessionOptionsInterface
NewSessionOptions creates a new session options
func SessionOptions ΒΆ
func SessionOptions() SessionOptionsInterface
SessionOptions shortcut for NewSessionOptions
type SessionQueryInterface ΒΆ
type SessionQueryInterface interface {
Validate() error
IsCountOnly() bool
Columns() []string
SetColumns(columns []string) SessionQueryInterface
HasCreatedAtGte() bool
CreatedAtGte() string
SetCreatedAtGte(createdAtGte string) SessionQueryInterface
HasCreatedAtLte() bool
CreatedAtLte() string
SetCreatedAtLte(createdAtLte string) SessionQueryInterface
HasExpiresAtGte() bool
ExpiresAtGte() string
SetExpiresAtGte(expiresAtGte string) SessionQueryInterface
HasExpiresAtLte() bool
ExpiresAtLte() string
SetExpiresAtLte(expiresAtLte string) SessionQueryInterface
HasID() bool
ID() string
SetID(id string) SessionQueryInterface
HasIDIn() bool
IDIn() []string
SetIDIn(idIn []string) SessionQueryInterface
HasKey() bool
Key() string
SetKey(key string) SessionQueryInterface
HasUserID() bool
UserID() string
SetUserID(userID string) SessionQueryInterface
HasUserIpAddress() bool
UserIpAddress() string
SetUserIpAddress(userIpAddress string) SessionQueryInterface
HasUserAgent() bool
UserAgent() string
SetUserAgent(userAgent string) SessionQueryInterface
HasOffset() bool
Offset() int
SetOffset(offset int) SessionQueryInterface
HasLimit() bool
Limit() int
SetLimit(limit int) SessionQueryInterface
HasSortOrder() bool
SortOrder() string
SetSortOrder(sortOrder string) SessionQueryInterface
HasOrderBy() bool
OrderBy() string
SetOrderBy(orderBy string) SessionQueryInterface
HasCountOnly() bool
SetCountOnly(countOnly bool) SessionQueryInterface
HasSoftDeletedIncluded() bool
SoftDeletedIncluded() bool
SetSoftDeletedIncluded(withSoftDeleted bool) SessionQueryInterface
}
func NewSessionQuery ΒΆ
func NewSessionQuery() SessionQueryInterface
NewSessionQuery creates a new session query
func SessionQuery ΒΆ
func SessionQuery() SessionQueryInterface
SessionQuery is a shortcut version of NewSessionQuery to create a new query
type StoreInterface ΒΆ
type StoreInterface interface {
AutoMigrate(ctx context.Context) error
EnableDebug(debug bool)
SessionExpiryGoroutine(ctx context.Context) error
GetDB() *sql.DB
// Old API
Set(ctx context.Context, key string, value string, seconds int64, options SessionOptionsInterface) error
Get(ctx context.Context, key string, defaultValue string, options SessionOptionsInterface) (string, error)
GetMap(ctx context.Context, key string, defaultValue map[string]any, options SessionOptionsInterface) (map[string]any, error)
GetAny(ctx context.Context, key string, defaultValue any, options SessionOptionsInterface) (any, error)
Delete(ctx context.Context, key string, options SessionOptionsInterface) error
Extend(ctx context.Context, key string, seconds int64, options SessionOptionsInterface) error
Has(ctx context.Context, key string, options SessionOptionsInterface) (bool, error)
MergeMap(ctx context.Context, key string, value map[string]any, seconds int64, options SessionOptionsInterface) error
SetAny(ctx context.Context, key string, value any, seconds int64, options SessionOptionsInterface) error
SetMap(ctx context.Context, key string, value map[string]any, seconds int64, options SessionOptionsInterface) error
// New API
SessionCount(ctx context.Context, query SessionQueryInterface) (int64, error)
SessionCreate(ctx context.Context, session SessionInterface) error
SessionDelete(ctx context.Context, session SessionInterface) error
SessionDeleteByID(ctx context.Context, sessionID string) error
SessionExtend(ctx context.Context, session SessionInterface, seconds int64) error
SessionFindByID(ctx context.Context, sessionID string, options ...SessionOptionsInterface) (SessionInterface, error)
SessionFindByKey(ctx context.Context, sessionKey string, options ...SessionOptionsInterface) (SessionInterface, error)
SessionList(ctx context.Context, query SessionQueryInterface) ([]SessionInterface, error)
SessionSoftDelete(ctx context.Context, session SessionInterface) error
SessionSoftDeleteByID(ctx context.Context, sessionID string) error
SessionUpdate(ctx context.Context, session SessionInterface) error
}
func NewStore ΒΆ
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new session store
Click to show internal directories.
Click to hide internal directories.