Skip to content

Commit 1c5cd73

Browse files
authored
feat: removed the cache from the full config endpoint (#151)
1 parent f8b67ea commit 1c5cd73

File tree

4 files changed

+3
-84
lines changed

4 files changed

+3
-84
lines changed

package-lock.json

Lines changed: 0 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
"@sinclair/typebox": "^0.34.30",
5050
"ajv": "^8.17.1",
5151
"ajv-formats": "^3.0.1",
52-
"async-cache-dedupe": "^3.4.0",
5352
"compression": "^1.8.0",
5453
"config": "^3.3.12",
5554
"date-fns": "^4.1.0",

src/configs/models/configManager.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { inject, injectable } from 'tsyringe';
99
import { Clone } from '@sinclair/typebox/value';
1010
import pointer, { type JsonObject } from 'json-pointer';
1111
import { formatISO, parseISO } from 'date-fns';
12-
import { Cache, createCache } from 'async-cache-dedupe';
1312
import { get } from 'lodash';
1413
import { paths, components } from '@openapi';
1514
import type { Prettify } from '@common/interfaces';
@@ -36,39 +35,18 @@ type DefaultConfigToInsert = Parameters<ConfigManager['createConfig']>[0] & {
3635
visited: boolean;
3736
};
3837

39-
interface FullConfigMetadataParams {
40-
name: string;
41-
schemaId: string;
42-
version?: number;
43-
}
44-
4538
// Constants for configuration metadata
4639
const MAX_RECURSION_DEPTH = 2;
4740

4841
@injectable()
4942
export class ConfigManager {
50-
private readonly fullConfigCache: Cache & {
51-
getMetadata: (args: FullConfigMetadataParams) => Promise<ConfigFullMetadata>;
52-
};
53-
5443
public constructor(
5544
@inject(SERVICES.LOGGER) private readonly logger: Logger,
5645
@inject(ConfigRepository) private readonly configRepository: ConfigRepository,
5746
@inject(Validator) private readonly configValidator: Validator,
5847
@inject(HashPropagationHelper) private readonly hashPropagationHelper: HashPropagationHelper,
5948
@inject(SchemaManager) private readonly schemaManager: SchemaManager
60-
) {
61-
// Initialize async-cache-dedupe for full config metadata
62-
const cache = createCache({
63-
ttl: 300, // 5 minutes in seconds
64-
storage: { type: 'memory' },
65-
});
66-
67-
// Define cached function for full config metadata
68-
this.fullConfigCache = cache.define('getMetadata', async (params: FullConfigMetadataParams) => {
69-
return this.generateFullConfigMetadata(params.name, params.schemaId, params.version);
70-
});
71-
}
49+
) {}
7250

7351
@withSpan()
7452
public async getConfig(name: string, schemaId: string, version?: number, shouldDereferenceConfig?: boolean): Promise<Config> {
@@ -803,11 +781,10 @@ export class ConfigManager {
803781
}
804782

805783
/**
806-
* Generate comprehensive config metadata (uncached)
807-
* Internal method used by cached getFullConfigMetadata
784+
* Get comprehensive config metadata for inspector page
808785
*/
809786
@withSpan()
810-
private async generateFullConfigMetadata(name: string, schemaId: string, version?: number): Promise<ConfigFullMetadata> {
787+
public async getFullConfigMetadata(name: string, schemaId: string, version?: number): Promise<ConfigFullMetadata> {
811788
this.logger.info({ msg: 'Generating full config metadata', name, schemaId, version });
812789

813790
// 1. Fetch raw and resolved config in parallel
@@ -894,12 +871,4 @@ export class ConfigManager {
894871

895872
return metadata;
896873
}
897-
898-
/**
899-
* Get comprehensive config metadata for inspector page (cached)
900-
*/
901-
@withSpan()
902-
public async getFullConfigMetadata(name: string, schemaId: string, version?: number): Promise<ConfigFullMetadata> {
903-
return this.fullConfigCache.getMetadata({ name, schemaId, version });
904-
}
905874
}

tests/integration/configs/configs.spec.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,29 +1476,6 @@ describe('config', function () {
14761476
});
14771477
});
14781478

1479-
describe('Caching Behavior', function () {
1480-
it('should return consistent results on repeated calls (caching works)', async function () {
1481-
// First call
1482-
const response1 = await requestSender.getFullConfig({
1483-
pathParams: { name: 'config2', version: 1 },
1484-
queryParams: { schemaId: 'https://mapcolonies.com/simpleSchema/v1' },
1485-
});
1486-
1487-
expectResponseStatus(response1, 200);
1488-
1489-
// Second call - should get same result (potentially from cache)
1490-
const response2 = await requestSender.getFullConfig({
1491-
pathParams: { name: 'config2', version: 1 },
1492-
queryParams: { schemaId: 'https://mapcolonies.com/simpleSchema/v1' },
1493-
});
1494-
1495-
expectResponseStatus(response2, 200);
1496-
1497-
// Verify both responses are identical
1498-
expect(response1.body).toStrictEqual(response2.body);
1499-
});
1500-
});
1501-
15021479
describe('Complex Scenarios', function () {
15031480
it('should handle configs with latest version references correctly', async function () {
15041481
// config-ref-3 uses 'latest' version reference

0 commit comments

Comments
 (0)