@sentinel-atl/store
v0.2.1
Published
Persistent storage adapters for Sentinel — Redis, PostgreSQL, SQLite, and in-memory backends
Maintainers
Readme
@sentinel-atl/store
Persistent storage adapters for the Sentinel Agent Trust Layer — Redis, PostgreSQL, SQLite, and in-memory backends.
Install
npm install @sentinel-atl/storeOptional peer dependencies (install only the adapter you need):
npm install ioredis # Redis / Valkey
npm install pg # PostgreSQL
npm install better-sqlite3 # SQLiteQuick Start
import { MemoryStore } from '@sentinel-atl/store';
const store = new MemoryStore();
await store.set('key', 'value');
await store.set('temp', 'value', 60); // TTL: 60 seconds
const val = await store.get('key'); // 'value'Adapters
MemoryStore
Zero-dependency, in-process Map storage. Ideal for development and testing.
const store = new MemoryStore();RedisStore
Production-ready adapter using ioredis.
import { RedisStore } from '@sentinel-atl/store';
const store = new RedisStore({
url: 'redis://localhost:6379',
prefix: 'sentinel:',
});Options: url, host, port, password, db, prefix, client (existing ioredis instance).
PostgresStore
Stores data in a PostgreSQL table with automatic schema creation.
import { PostgresStore } from '@sentinel-atl/store';
const store = new PostgresStore({
connectionString: 'postgresql://user:pass@localhost:5432/sentinel',
tableName: 'sentinel_kv', // default
});Options: connectionString, pool, tableName, schema.
SQLiteStore
Local file-based storage using better-sqlite3.
import { SQLiteStore } from '@sentinel-atl/store';
const store = new SQLiteStore('./sentinel.db');SentinelStore Interface
All adapters implement the SentinelStore interface:
interface SentinelStore {
get(key: string): Promise<string | undefined>;
set(key: string, value: string, ttlSeconds?: number): Promise<void>;
delete(key: string): Promise<boolean>;
has(key: string): Promise<boolean>;
keys(prefix?: string): Promise<string[]>;
getMany(keys: string[]): Promise<(string | undefined)[]>;
setMany(entries: [string, string][]): Promise<void>;
increment(key: string, by?: number): Promise<number>;
listAppend(key: string, value: string): Promise<void>;
listRange(key: string, start: number, end: number): Promise<string[]>;
listLength(key: string): Promise<number>;
close(): Promise<void>;
}License
MIT
