feat(cache,build,docs): switch cache storage to SmartMongo and align build configuration with updated dependencies
This commit is contained in:
18
ts/cache/classes.cachedb.ts
vendored
18
ts/cache/classes.cachedb.ts
vendored
@@ -14,7 +14,7 @@ export interface ICacheDbOptions {
|
||||
export class CacheDb {
|
||||
private static instance: CacheDb | null = null;
|
||||
|
||||
private localTsmDb: InstanceType<typeof plugins.smartmongo.LocalTsmDb> | null = null;
|
||||
private smartMongo: InstanceType<typeof plugins.smartmongo.SmartMongo> | null = null;
|
||||
private smartdataDb: InstanceType<typeof plugins.smartdata.SmartdataDb> | null = null;
|
||||
private options: Required<ICacheDbOptions>;
|
||||
|
||||
@@ -39,13 +39,11 @@ export class CacheDb {
|
||||
|
||||
async start(): Promise<void> {
|
||||
logger.info('Starting CacheDb...');
|
||||
this.localTsmDb = new plugins.smartmongo.LocalTsmDb({
|
||||
folderPath: this.options.storagePath,
|
||||
});
|
||||
const { connectionUri } = await this.localTsmDb.start();
|
||||
this.smartMongo = await plugins.smartmongo.SmartMongo.createAndStart();
|
||||
const mongoDescriptor = await this.smartMongo.getMongoDescriptor();
|
||||
|
||||
this.smartdataDb = new plugins.smartdata.SmartdataDb({
|
||||
mongoDbUrl: connectionUri,
|
||||
mongoDbUrl: mongoDescriptor.mongoDbUrl,
|
||||
mongoDbName: this.options.dbName,
|
||||
});
|
||||
await this.smartdataDb.init();
|
||||
@@ -58,9 +56,9 @@ export class CacheDb {
|
||||
await this.smartdataDb.close();
|
||||
this.smartdataDb = null;
|
||||
}
|
||||
if (this.localTsmDb) {
|
||||
// localDb.stop() may hang under Deno — fire-and-forget with timeout
|
||||
const stopPromise = this.localTsmDb.stop().catch(() => {});
|
||||
if (this.smartMongo) {
|
||||
// smartMongo.stop() may hang under Deno — fire-and-forget with timeout
|
||||
const stopPromise = this.smartMongo.stop().catch(() => {});
|
||||
await Promise.race([
|
||||
stopPromise,
|
||||
new Promise<void>((resolve) => {
|
||||
@@ -68,7 +66,7 @@ export class CacheDb {
|
||||
Deno.unrefTimer(id);
|
||||
}),
|
||||
]);
|
||||
this.localTsmDb = null;
|
||||
this.smartMongo = null;
|
||||
}
|
||||
logger.success('CacheDb stopped');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user