mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-07 19:19:53 +08:00
Use MikroORM's official Node SQLite dialect with bounded database isolation, preserve legacy schema and data for rollback, and require Node 22.17 or newer. Update Debian runtimes and retain ARMv6 musl compatibility without a SQLite addon. Complete short archive writes, stop orphaned SQL workers after owner death, preserve buffered startup requests, and prestart the archived backend on every platform. Cover real package installation, migration, failure recovery, and legacy database compatibility. Keep authentication storage failures distinct from expired sessions with a pinned Keyv runtime, propagated cache errors, and retryable HTTP 503 responses. Preserve genuine 401 failures and verify legacy cache bytes, initialization safety, and session recovery.
29 lines
1023 B
TypeScript
29 lines
1023 B
TypeScript
import { EventEmitter } from 'events';
|
|
import { database } from '.';
|
|
import { DatabaseClient } from './databaseClient';
|
|
|
|
// Keep the existing Keyv serialization and namespace. Only its SQLite transport
|
|
// changes; old cached authentication records remain readable in either version.
|
|
export class CacheStore extends EventEmitter {
|
|
readonly opts = { dialect: 'sqlite' };
|
|
namespace?: string;
|
|
constructor(private client: () => DatabaseClient = () => database) {
|
|
super();
|
|
}
|
|
get(key: string): Promise<string | undefined> {
|
|
return this.client().request('cache', 'get', key);
|
|
}
|
|
async set(key: string, value: string) {
|
|
return this.client().request('cache', 'set', key, value);
|
|
}
|
|
async delete(key: string): Promise<boolean> {
|
|
return this.client().request('cache', 'delete', key);
|
|
}
|
|
async clear(): Promise<void> {
|
|
throw new Error('Clearing all authentication namespaces is not supported');
|
|
}
|
|
async disconnect(): Promise<void> {
|
|
/* The shared database client owns the worker. */
|
|
}
|
|
}
|