session

package
v1.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStore

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

MemoryStore implements in-memory session storage

func NewMemoryStore

func NewMemoryStore(ttl time.Duration) *MemoryStore

NewMemoryStore creates a new memory-only session store

func (*MemoryStore) Cleanup

func (s *MemoryStore) Cleanup()

Cleanup removes expired sessions

func (*MemoryStore) Count

func (s *MemoryStore) Count() int

Count returns number of active sessions (for metrics)

func (*MemoryStore) Create

func (s *MemoryStore) Create(username, role string) (string, error)

Create creates a new session and returns a token

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(token string)

Delete removes a session

func (*MemoryStore) Get

func (s *MemoryStore) Get(token string) (*Session, error)

Get retrieves a session by token

type Session

type Session struct {
	Username  string
	Role      string
	CreatedAt time.Time
	ExpiresAt time.Time
}

Session represents a user session

type Store

type Store interface {
	Create(username, role string) (string, error)
	Get(token string) (*Session, error)
	Delete(token string)
	Cleanup()
}

Store interface for session storage

Jump to

Keyboard shortcuts

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