NAME

PAGI::Middleware::Session::Store::Memory - In-memory session store

SYNOPSIS

use PAGI::Middleware::Session::Store::Memory;

my $store = PAGI::Middleware::Session::Store::Memory->new();

# All methods return Futures
await $store->set('session_id', { user_id => 123 });
my $data = await $store->get('session_id');
await $store->delete('session_id');

# For testing
PAGI::Middleware::Session::Store::Memory->clear_all();

DESCRIPTION

Implements the PAGI::Middleware::Session::Store interface using a package-level hash. Sessions are shared across all instances within the same process but are not shared between workers and are lost on restart.

Warning: This store is suitable for development and single-process deployments only. For production multi-worker deployments, use a store backed by Redis, a database, or another shared storage.

METHODS

get

my $future = $store->get($id);

Returns a Future resolving to the session hashref, or undef if no session exists for the given ID.

set

my $future = $store->set($id, $data);

Stores the session data hashref under the given ID. Returns a Future resolving to the transport value (the session ID for server-side stores, or encoded data for cookie stores).

delete

my $future = $store->delete($id);

Removes the session for the given ID. Returns a Future resolving to 1.

clear_all

PAGI::Middleware::Session::Store::Memory->clear_all();

Class method that removes all sessions from the in-memory store. Useful for test cleanup.

SEE ALSO

PAGI::Middleware::Session::Store - Base store interface

PAGI::Middleware::Session - Session management middleware