Skip to content

Commit

Permalink
cache interace change
Browse files Browse the repository at this point in the history
  • Loading branch information
LiranCohen committed Apr 2, 2024
1 parent a9acb8f commit a0ebcf8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServerInfo| void> {
async get(dwnUrl: string): Promise<ServerInfo| undefined> {
try {
const str = await this.cache.get(dwnUrl);
const cacheWrapper: CacheWrapper = JSON.parse(str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServerInfo| void> {
public async get(dwnUrl: string): Promise<ServerInfo| undefined> {
return this.cache.get(dwnUrl);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { DwnServerInfoCache, ServerInfo } from './web5-rpc-types.js';

export class DwnServerInfoCacheNoOp implements DwnServerInfoCache {

public async get(_dwnUrl: string): Promise<ServerInfo| void> {}
public async get(_dwnUrl: string): Promise<ServerInfo|undefined> {
return;
}

public async set(_dwnUrl: string, _value: ServerInfo): Promise<void> {}

Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/prototyping/clients/web5-rpc-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ export type ServerInfo = {
webSocketSupport: boolean,
}

export interface DwnServerInfoCache extends KeyValueStore<string, ServerInfo| void> {}
export interface DwnServerInfoCache extends KeyValueStore<string, ServerInfo| undefined> {}

export interface DwnServerInfo {
/** retrieves the DWN Sever info, used to detect features such as WebSocket Subscriptions */
getServerInfo(url: string): Promise<ServerInfo>;
}

Expand Down

0 comments on commit a0ebcf8

Please sign in to comment.