diff --git a/src/internal/base.ts b/src/internal/base.ts index 5da411a..77c7a25 100644 --- a/src/internal/base.ts +++ b/src/internal/base.ts @@ -17,12 +17,13 @@ import { MAINNET_CANISTER_ID_GROUP, TICP_CANISTER_ID_GROUP, } from "./config"; -import { NameRecordsCacheStore } from "./cache"; +import { InMemoryNameRecordsCacheStore, NameRecordsCacheStore } from "./cache"; export interface IcNamingClientInitOptions { net: "MAINNET" | "TICP"; mode: "production" | "local"; httpAgentOptions?: HttpAgentOptions; + enableTTL?: boolean; nameRecordsCacheStore?: NameRecordsCacheStore; } @@ -34,6 +35,9 @@ export class IcNamingClientBase { private _options: IcNamingClientInitOptions; private _httpAgent: HttpAgent; + protected enableTTL: boolean; + protected nameRecordsCacheStore?: NameRecordsCacheStore; + protected favorites; protected registrar; protected registry; @@ -44,6 +48,12 @@ export class IcNamingClientBase { this._httpAgent = this._initHttpAgent(); + this.enableTTL = options.enableTTL ?? false; + + this.nameRecordsCacheStore = this.enableTTL + ? options.nameRecordsCacheStore ?? new InMemoryNameRecordsCacheStore() + : undefined; + this._init_actors_before(); const canisterIdMapping =