memory

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package memory provides an in-memory session storage backend.

This backend is suitable for development and testing. Data is not persisted across restarts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWithControls

func NewWithControls(cfg session.Config, opts ...session.ControlOption) session.Store

NewWithControls creates a new in-memory session store with controls. This is a convenience function that wraps New() with WithControls().

Types

type Store

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

Store implements session.Store with in-memory storage.

func New

func New(cfg session.Config) *Store

New creates a new in-memory session store.

func (*Store) Close

func (s *Store) Close() error

Close stops the cleanup goroutine and releases resources.

func (*Store) Create

func (s *Store) Create(ctx context.Context, sess *session.Session) error

Create stores a new session.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

Delete removes a session by ID.

func (*Store) DeleteByUserID

func (s *Store) DeleteByUserID(ctx context.Context, userID string) (int, error)

DeleteByUserID removes all sessions for a user.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*session.Session, error)

Get retrieves a session by ID.

func (*Store) Len

func (s *Store) Len() int

Len returns the number of sessions (for testing).

func (*Store) ListByUserID

func (s *Store) ListByUserID(ctx context.Context, userID string) ([]*session.Session, error)

ListByUserID returns all sessions for a user, sorted by CreatedAt ascending (oldest first).

func (*Store) Touch

func (s *Store) Touch(ctx context.Context, id string) error

Touch updates the LastAccessedAt timestamp.

func (*Store) Update

func (s *Store) Update(ctx context.Context, sess *session.Session) error

Update updates an existing session.

Jump to

Keyboard shortcuts

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