Skip to content

Commit

Permalink
Renamed UrlKeyCache (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Oct 8, 2024
1 parent 96f9374 commit 746949d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/services/cache/DheClientCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import type {
EnterpriseDhType as DheType,
EnterpriseClient,
} from '@deephaven-enterprise/jsapi-types';
import { CacheByUrlService } from './CacheByUrlService';
import { UrlKeyCache } from './UrlKeyCache';
import { createDheClient, getWsUrl } from '../../dh/dhe';
import type { ICacheService } from '../../types';

/**
* Cache DHE client instances by URL.
*/
export class DheClientCache extends CacheByUrlService<EnterpriseClient> {
export class DheClientCache extends UrlKeyCache<EnterpriseClient> {
constructor(dheJsApiCache: ICacheService<URL, DheType>) {
super(async (url: URL) => {
const dhe = await dheJsApiCache.get(url);
Expand Down
4 changes: 2 additions & 2 deletions src/services/cache/DheJsApiCache.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { initDheApi } from '@deephaven/require-jsapi';
import type { EnterpriseDhType as DheType } from '@deephaven-enterprise/jsapi-types';
import { getTempDir, urlToDirectoryName } from '../../util';
import { CacheByUrlService } from './CacheByUrlService';
import { UrlKeyCache } from './UrlKeyCache';

/**
* Cache DHE jsapi instances by URL.
*/
export class DheJsApiCache extends CacheByUrlService<DheType> {
export class DheJsApiCache extends UrlKeyCache<DheType> {
constructor() {
super(async url =>
initDheApi(url, getTempDir({ subDirectory: urlToDirectoryName(url) }))
Expand Down
4 changes: 2 additions & 2 deletions src/services/cache/DheServiceCache.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CacheByUrlService } from './CacheByUrlService';
import { UrlKeyCache } from './UrlKeyCache';
import type { IDheService, IDheServiceFactory } from '../../types';

/**
* Cache `IdheService` instances by URL.
*/
export class DheServiceCache extends CacheByUrlService<IDheService> {
export class DheServiceCache extends UrlKeyCache<IDheService> {
constructor(dheServiceFactory: IDheServiceFactory) {
super(async url => {
return dheServiceFactory.create(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { URLMap } from '../URLMap';
/**
* Cache service that stores values by URL.
*/
export class CacheByUrlService<TValue> implements ICacheService<URL, TValue> {
export class UrlKeyCache<TValue> implements ICacheService<URL, TValue> {
constructor(loader: (url: URL) => Promise<TValue>) {
this._loader = loader;
this._promiseMap = new URLMap<Promise<TValue>>();
Expand Down
2 changes: 1 addition & 1 deletion src/services/cache/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './CacheByUrlService';
export * from './UrlKeyCache';
export * from './DheClientCache';
export * from './DheJsApiCache';
export * from './DheServiceCache';

0 comments on commit 746949d

Please sign in to comment.