Skip to content

Commit

Permalink
update max ttl to 21 days
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Aug 27, 2024
1 parent d0bdeef commit 9ed3f53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
7 changes: 4 additions & 3 deletions packages/agent/src/store-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,18 @@ export class DwnDataStore<TStoreObject extends Record<string, any> = Jwk> implem
* Index for mappings from Store Identifier to DWN record ID.
* Since these values don't change, we can use a long TTL.
*
* Up to 1,000 entries are retained for 30 days.
* Up to 1,000 entries are retained for 21 days.
* NOTE: The maximum number for the ttl is 2^31 - 1 milliseconds (24.8 days), setting to 21 days to be safe.
*/
protected _index = new TtlCache<string, string>({ ttl: ms('30 days'), max: 1000 });
protected _index = new TtlCache<string, string>({ ttl: ms('21 days'), max: 1000 });

/**
* Cache of tenant DIDs that have been initialized with the protocol.
* This is used to avoid redundant protocol initialization requests.
*
* Since these are default protocols and unlikely to change, we can use a long TTL.
*/
protected _protocolInitializedCache: TtlCache<string, boolean> = new TtlCache({ ttl: ms('30 days'), max: 1000 });
protected _protocolInitializedCache: TtlCache<string, boolean> = new TtlCache({ ttl: ms('21 days'), max: 1000 });

/**
* The protocol assigned to this storage instance.
Expand Down
11 changes: 2 additions & 9 deletions packages/user-agent/src/user-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,9 @@ export class Web5UserAgent<TKeyManager extends AgentKeyManager = LocalKeyManager

cryptoApi ??= new AgentCryptoApi();

const didResolverCache = new AgentDidResolverCache({ location: `${dataPath}/DID_RESOLVERCACHE` });

didApi ??= new AgentDidApi({
didMethods : [DidDht, DidJwk],
resolverCache : didResolverCache,
resolverCache : new AgentDidResolverCache({ location: `${dataPath}/DID_RESOLVERCACHE` }),
store : new DwnDidStore()
});

Expand All @@ -174,7 +172,7 @@ export class Web5UserAgent<TKeyManager extends AgentKeyManager = LocalKeyManager
syncApi ??= new AgentSyncApi({ syncEngine: new SyncEngineLevel({ dataPath }) });

// Instantiate the Agent using the provided or default components.
const web5USerAgent = new Web5UserAgent({
return new Web5UserAgent({
agentDid,
agentVault,
cryptoApi,
Expand All @@ -186,11 +184,6 @@ export class Web5UserAgent<TKeyManager extends AgentKeyManager = LocalKeyManager
rpcClient,
syncApi
});

// Set the agent on the resolver cache
didResolverCache.agent = web5USerAgent;

return web5USerAgent;
}

public async firstLaunch(): Promise<boolean> {
Expand Down

0 comments on commit 9ed3f53

Please sign in to comment.