Skip to content

Commit

Permalink
feat: option enableTTL
Browse files Browse the repository at this point in the history
  • Loading branch information
Aysnine committed Mar 24, 2022
1 parent 7e9e329 commit 45b71c5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/internal/base.ts
Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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 =
Expand Down

0 comments on commit 45b71c5

Please sign in to comment.