/** * @adonisjs/session * * (c) AdonisJS * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import type { SessionData, SessionStoreWithTaggingContract, TaggedSession } from '../types.ts'; /** * Memory store is meant to be used for writing tests. * All session data is stored in memory and will be lost when the process restarts. * * @example * const memoryStore = new MemoryStore() * memoryStore.write('sess_abc123', { userId: 123 }) */ export declare class MemoryStore implements SessionStoreWithTaggingContract { /** * Static map to store all session data in memory */ static sessions: Map; /** * Static map to store session tags (sessionId -> userId) */ static tags: Map; /** * Reads session value from memory * * @param sessionId - Session identifier * * @example * const data = store.read('sess_abc123') */ read(sessionId: string): SessionData | null; /** * Saves session value in memory for a given session id * * @param sessionId - Session identifier * @param values - Session data to store * * @example * store.write('sess_abc123', { userId: 123, theme: 'dark' }) */ write(sessionId: string, values: SessionData): void; /** * Removes a single session from memory * * @param sessionId - Session identifier to remove * * @example * store.destroy('sess_abc123') */ destroy(sessionId: string): void; /** * No-op for memory store as there's no expiry mechanism * * @param sessionId - Session identifier (unused) */ touch(_?: string): void; /** * Tag a session with a user ID * * @param sessionId - Session identifier * @param userId - User identifier to tag the session with */ tag(sessionId: string, userId: string | number): void; /** * Untag a session from a user ID * * @param sessionId - Session identifier * @param userId - User identifier (unused in memory store, as sessionId uniquely identifies the tag) */ untag(sessionId: string, _userId: string | number): void; /** * Get all sessions for a given user ID (tag) * * @param userId - User identifier to get sessions for */ tagged(userId: string): TaggedSession[]; }