fix lint errors about use of console and new() cache
This commit is contained in:
parent
6c2206ab72
commit
deff0c0f49
5 changed files with 34 additions and 16 deletions
|
|
@ -75,6 +75,8 @@ export class QuantumKVCache<T> implements Iterable<readonly [key: string, value:
|
|||
services: QuantumCacheServices,
|
||||
opts: QuantumKVOpts<T>,
|
||||
) {
|
||||
// OK: we forward all management calls to the inner cache.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
this.memoryCache = new MemoryKVCache(opts.lifetime, services);
|
||||
this.fetcher = opts.fetcher;
|
||||
this.bulkFetcher = opts.bulkFetcher;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ export class RedisKVCache<T> {
|
|||
) {
|
||||
this.redisClient = services.redisClient;
|
||||
this.lifetime = opts.lifetime;
|
||||
// OK: we forward all management calls to the inner cache.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
this.memoryCache = new MemoryKVCache(opts.memoryCacheLifetime, services);
|
||||
this.fetcher = opts.fetcher ?? (() => { throw new Error('fetch not supported - use get/set directly'); });
|
||||
this.toRedisConverter = opts.toRedisConverter ?? ((value) => JSON.stringify(value));
|
||||
|
|
@ -150,6 +152,8 @@ export class RedisSingleCache<T> {
|
|||
) {
|
||||
this.redisClient = services.redisClient;
|
||||
this.lifetime = opts.lifetime;
|
||||
// OK: we forward all management calls to the inner cache.
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
this.memoryCache = new MemorySingleCache(opts.memoryCacheLifetime, services);
|
||||
|
||||
this.fetcher = opts.fetcher ?? (() => { throw new Error('fetch not supported - use get/set directly'); });
|
||||
|
|
@ -198,7 +202,7 @@ export class RedisSingleCache<T> {
|
|||
|
||||
@bindThis
|
||||
public clear(): void {
|
||||
this.memoryCache.delete();
|
||||
this.memoryCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -233,6 +237,7 @@ export class RedisSingleCache<T> {
|
|||
@bindThis
|
||||
public dispose(): void {
|
||||
this.clear();
|
||||
this.memoryCache.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,18 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import type Logger from '@/logger.js';
|
||||
|
||||
export class I18n<T extends Record<string, any>> {
|
||||
private readonly logger: Logger;
|
||||
public locale: T;
|
||||
|
||||
constructor(locale: T) {
|
||||
constructor(
|
||||
loggerService: LoggerService,
|
||||
locale: T,
|
||||
) {
|
||||
this.logger = loggerService.getLogger('i18n');
|
||||
this.locale = locale;
|
||||
|
||||
//#region BIND
|
||||
|
|
@ -26,8 +34,8 @@ export class I18n<T extends Record<string, any>> {
|
|||
}
|
||||
}
|
||||
return str;
|
||||
} catch (e) {
|
||||
console.warn(`missing localization '${key}'`);
|
||||
} catch {
|
||||
this.logger.warn(`missing localization '${key}'`);
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue