diff --git a/src/backend/lib/cache/AbstractCacheService.ts b/src/backend/lib/cache/AbstractCacheService.ts index e70b95e11..3e2f8cafb 100644 --- a/src/backend/lib/cache/AbstractCacheService.ts +++ b/src/backend/lib/cache/AbstractCacheService.ts @@ -13,11 +13,15 @@ export abstract class AbstractCacheService { return `__dp__:${key}`; } - abstract pullItem(key: string): Promise; + protected abstract pullItem(key: string): Promise; - abstract persistData(key: string, data: unknown): Promise; + protected abstract persistData(key: string, data: unknown): Promise; - abstract clearItem(key: string): Promise; + protected abstract _clearItem(key: string): Promise; + + async clearItem(rawKey: string) { + await this._clearItem(this.prefixKey(rawKey)); + } abstract purge(): Promise; diff --git a/src/backend/lib/cache/MemoryCacheAdaptor.ts b/src/backend/lib/cache/MemoryCacheAdaptor.ts index 1f9a75cf6..91c173966 100644 --- a/src/backend/lib/cache/MemoryCacheAdaptor.ts +++ b/src/backend/lib/cache/MemoryCacheAdaptor.ts @@ -10,24 +10,20 @@ export class MemoryCacheAdaptor extends AbstractCacheService { MemoryCacheAdaptor.data = {}; } - private getData(): Record { - return MemoryCacheAdaptor.data; - } - async setup() { noop(); } async pullItem(key: string): Promise { - return this.getData()[key] as T; + return MemoryCacheAdaptor.data[key] as T; } async persistData(key: string, data: unknown): Promise { MemoryCacheAdaptor.data[key] = data; } - async clearItem(key: string) { - delete this.getData()[key]; + async _clearItem(key: string) { + delete MemoryCacheAdaptor.data[key]; } async purge() { diff --git a/src/backend/lib/cache/RedisCacheAdaptor.ts b/src/backend/lib/cache/RedisCacheAdaptor.ts index 39f00d1e5..64e4c141e 100644 --- a/src/backend/lib/cache/RedisCacheAdaptor.ts +++ b/src/backend/lib/cache/RedisCacheAdaptor.ts @@ -40,7 +40,7 @@ export class RedisCacheAdaptor extends AbstractCacheService { ).set(key, JSON.stringify(data), { EX: 60 * 60 }); // I hour } - async clearItem(key: string) { + async _clearItem(key: string) { await (await this.getRedisInstance()).del(key); } diff --git a/src/backend/lib/config-persistence/DatabaseConfigDataPersistenceAdaptor.ts b/src/backend/lib/config-persistence/DatabaseConfigDataPersistenceAdaptor.ts index 19ab1b968..ee66ba91d 100644 --- a/src/backend/lib/config-persistence/DatabaseConfigDataPersistenceAdaptor.ts +++ b/src/backend/lib/config-persistence/DatabaseConfigDataPersistenceAdaptor.ts @@ -4,9 +4,9 @@ import { getDbConnection } from "../connection/db"; import { AbstractConfigDataPersistenceService } from "./AbstractConfigDataPersistenceService"; import { ConfigDomain } from "./types"; import { CONFIG_TABLE_PREFIX } from "./constants"; +import { createMetaData, updateMetaData } from "./portal"; const CONFIG_TABLE_NAME = CONFIG_TABLE_PREFIX("config"); - export class DatabaseConfigDataPersistenceAdaptor< T > extends AbstractConfigDataPersistenceService { @@ -140,7 +140,7 @@ export class DatabaseConfigDataPersistenceAdaptor< .update({ value: JSON.stringify(value), updated_at: new Date(), - // TODO updated_by + ...updateMetaData(), }); if (affectedRowsCount === 0) { await ( @@ -151,8 +151,7 @@ export class DatabaseConfigDataPersistenceAdaptor< value: JSON.stringify(value), created_at: new Date(), updated_at: new Date(), - // TODO updated_by - // TODO created_by + ...createMetaData(), }); } } diff --git a/src/backend/lib/config-persistence/portal/index.ts b/src/backend/lib/config-persistence/portal/index.ts index 757180e49..e6aedf252 100644 --- a/src/backend/lib/config-persistence/portal/index.ts +++ b/src/backend/lib/config-persistence/portal/index.ts @@ -1,3 +1,5 @@ export type { PortalConfigDomain } from "./main/types"; export const FOR_CODE_COV = 1; + +export { updateMetaData, createMetaData } from "./main"; diff --git a/src/backend/lib/config-persistence/portal/main/index.ts b/src/backend/lib/config-persistence/portal/main/index.ts new file mode 100644 index 000000000..432a214a8 --- /dev/null +++ b/src/backend/lib/config-persistence/portal/main/index.ts @@ -0,0 +1,7 @@ +export const createMetaData = () => { + return {}; +}; + +export const updateMetaData = () => { + return {}; +};