session

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data map[string]any

type Manager

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

Manager manages session state with SQLite + in-memory cache.

func NewManager

func NewManager(dbPath string) (*Manager, error)

NewManager creates a new session manager backed by SQLite.

func (*Manager) Close

func (m *Manager) Close() error

Close closes the session manager.

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, userID, chatID int64) error

Delete removes a session record.

func (*Manager) GetDB

func (m *Manager) GetDB() *sql.DB

GetDB returns the underlying database connection for advanced use.

func (*Manager) GetOrCreate

func (m *Manager) GetOrCreate(ctx context.Context, userID, chatID int64) (*Record, error)

GetOrCreate retrieves a session or creates a new one.

func (*Manager) Save

func (m *Manager) Save(ctx context.Context, record *Record) error

Save persists a session record.

type Record

type Record struct {
	UserID    int64
	ChatID    int64
	State     string
	Data      Data
	CreatedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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