From a0ebcf8b25a59691e88867fd7c775094744f3210 Mon Sep 17 00:00:00 2001 From: Liran Cohen Date: Tue, 2 Apr 2024 18:04:14 -0400 Subject: [PATCH] cache interace change --- .../src/prototyping/clients/dwn-server-info-cache-level.ts | 2 +- .../src/prototyping/clients/dwn-server-info-cache-memory.ts | 2 +- .../src/prototyping/clients/dwn-server-info-cache-no-op.ts | 4 +++- packages/agent/src/prototyping/clients/web5-rpc-types.ts | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/agent/src/prototyping/clients/dwn-server-info-cache-level.ts b/packages/agent/src/prototyping/clients/dwn-server-info-cache-level.ts index fd13a8f0b..28764c9fe 100644 --- a/packages/agent/src/prototyping/clients/dwn-server-info-cache-level.ts +++ b/packages/agent/src/prototyping/clients/dwn-server-info-cache-level.ts @@ -91,7 +91,7 @@ export class DwnServerInfoCacheLevel implements DwnServerInfoCache { * @param dwnUrl - The DWN URL endpoint string used as the key for retrieving the cached result. * @returns The cached ServerInfo entry or undefined if not found or expired. */ - async get(dwnUrl: string): Promise { + async get(dwnUrl: string): Promise { try { const str = await this.cache.get(dwnUrl); const cacheWrapper: CacheWrapper = JSON.parse(str); diff --git a/packages/agent/src/prototyping/clients/dwn-server-info-cache-memory.ts b/packages/agent/src/prototyping/clients/dwn-server-info-cache-memory.ts index b649a04bb..b3e05f27e 100644 --- a/packages/agent/src/prototyping/clients/dwn-server-info-cache-memory.ts +++ b/packages/agent/src/prototyping/clients/dwn-server-info-cache-memory.ts @@ -33,7 +33,7 @@ export class DwnServerInfoCacheMemory implements DwnServerInfoCache { * @param dwnUrl - The DWN URL endpoint string used as the key for getting the entry. * @returns The cached DWN ServerInfo entry or undefined if not found or expired. */ - public async get(dwnUrl: string): Promise { + public async get(dwnUrl: string): Promise { return this.cache.get(dwnUrl); } diff --git a/packages/agent/src/prototyping/clients/dwn-server-info-cache-no-op.ts b/packages/agent/src/prototyping/clients/dwn-server-info-cache-no-op.ts index 64ad7b183..9254a70bf 100644 --- a/packages/agent/src/prototyping/clients/dwn-server-info-cache-no-op.ts +++ b/packages/agent/src/prototyping/clients/dwn-server-info-cache-no-op.ts @@ -3,7 +3,9 @@ import { DwnServerInfoCache, ServerInfo } from './web5-rpc-types.js'; export class DwnServerInfoCacheNoOp implements DwnServerInfoCache { - public async get(_dwnUrl: string): Promise {} + public async get(_dwnUrl: string): Promise { + return; + } public async set(_dwnUrl: string, _value: ServerInfo): Promise {} diff --git a/packages/agent/src/prototyping/clients/web5-rpc-types.ts b/packages/agent/src/prototyping/clients/web5-rpc-types.ts index ba9011840..b276e510c 100644 --- a/packages/agent/src/prototyping/clients/web5-rpc-types.ts +++ b/packages/agent/src/prototyping/clients/web5-rpc-types.ts @@ -82,9 +82,10 @@ export type ServerInfo = { webSocketSupport: boolean, } -export interface DwnServerInfoCache extends KeyValueStore {} +export interface DwnServerInfoCache extends KeyValueStore {} export interface DwnServerInfo { + /** retrieves the DWN Sever info, used to detect features such as WebSocket Subscriptions */ getServerInfo(url: string): Promise; }