session

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(model SessionModel)

Init sets the package-level SessionModel used by @call Func wrappers.

Types

type DeleteRequest

type DeleteRequest struct {
	Key string
}

type DeleteResponse

type DeleteResponse struct{}

func Delete

func Delete(req DeleteRequest) (DeleteResponse, error)

type GetRequest

type GetRequest struct {
	Key string
}

type GetResponse

type GetResponse struct {
	Value string
}

func Get

func Get(req GetRequest) (GetResponse, error)

type SessionModel

type SessionModel interface {
	Set(ctx context.Context, key string, value any, ttl time.Duration) error
	Get(ctx context.Context, key string) (string, error)
	Delete(ctx context.Context, key string) error
}

SessionModel provides key-value + TTL storage for user-bound state (login, cart, etc.).

func NewMemorySession

func NewMemorySession() SessionModel

NewMemorySession creates an in-memory SessionModel. Data is lost on restart.

func NewPostgresSession

func NewPostgresSession(ctx context.Context, db *sql.DB) (SessionModel, error)

NewPostgresSession creates a SessionModel backed by PostgreSQL. It auto-creates the fullend_sessions table if not exists.

type SetRequest

type SetRequest struct {
	Key   string
	Value string
	TTL   int64
}

type SetResponse

type SetResponse struct{}

func Set

func Set(req SetRequest) (SetResponse, error)

Jump to

Keyboard shortcuts

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