graphile-cache 3.11.0 → 3.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -10,3 +10,5 @@ CacheEventEmitter, cacheEvents, getCacheConfig, getCacheStats,
10
10
  clearMatchingEntries } from './graphile-cache';
11
11
  // Factory for creating PostGraphile v5 instances
12
12
  export { createGraphileInstance } from './create-instance';
13
+ // Generic module config cache for plugin lookups
14
+ export { ModuleConfigCache } from './module-config-cache';
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ModuleConfigCache — generic LRU cache for module config lookups
3
+ *
4
+ * Provides a bounded, TTL-based cache for runtime config discovery
5
+ * (billing config, agent discovery, inference log info, etc.).
6
+ *
7
+ * Wraps lru-cache with:
8
+ * - LRU eviction (bounded memory)
9
+ * - TTL-based expiry
10
+ * - Named logging for debugging
11
+ * - clear() hook for future LISTEN/NOTIFY invalidation
12
+ */
13
+ import { LRUCache } from 'lru-cache';
14
+ import { Logger } from '@pgpmjs/logger';
15
+ export class ModuleConfigCache {
16
+ cache;
17
+ log;
18
+ name;
19
+ constructor(opts) {
20
+ this.name = opts.name;
21
+ this.log = new Logger(`cache:${opts.name}`);
22
+ this.cache = new LRUCache({
23
+ max: opts.max ?? 100,
24
+ ttl: opts.ttlMs ?? 60_000,
25
+ updateAgeOnGet: true,
26
+ });
27
+ }
28
+ get(key) {
29
+ return this.cache.get(key);
30
+ }
31
+ set(key, value) {
32
+ this.cache.set(key, value);
33
+ }
34
+ delete(key) {
35
+ return this.cache.delete(key);
36
+ }
37
+ clear() {
38
+ this.log.debug(`Clearing all entries (size=${this.cache.size})`);
39
+ this.cache.clear();
40
+ }
41
+ get size() {
42
+ return this.cache.size;
43
+ }
44
+ has(key) {
45
+ return this.cache.has(key);
46
+ }
47
+ }
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { graphileCache, GraphileCacheEntry, closeAllCaches, ONE_HOUR_MS, FIVE_MINUTES_MS, EvictionReason, CacheEventEmitter, CacheEvictionEvent, cacheEvents, CacheConfig, getCacheConfig, CacheStats, getCacheStats, clearMatchingEntries } from './graphile-cache';
2
2
  export { createGraphileInstance } from './create-instance';
3
+ export { ModuleConfigCache, ModuleConfigCacheOptions } from './module-config-cache';
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createGraphileInstance = exports.clearMatchingEntries = exports.getCacheStats = exports.getCacheConfig = exports.cacheEvents = exports.CacheEventEmitter = exports.FIVE_MINUTES_MS = exports.ONE_HOUR_MS = exports.closeAllCaches = exports.graphileCache = void 0;
3
+ exports.ModuleConfigCache = exports.createGraphileInstance = exports.clearMatchingEntries = exports.getCacheStats = exports.getCacheConfig = exports.cacheEvents = exports.CacheEventEmitter = exports.FIVE_MINUTES_MS = exports.ONE_HOUR_MS = exports.closeAllCaches = exports.graphileCache = void 0;
4
4
  // Main exports from graphile-cache package
5
5
  var graphile_cache_1 = require("./graphile-cache");
6
6
  // Cache instance and entry type
@@ -19,3 +19,6 @@ Object.defineProperty(exports, "clearMatchingEntries", { enumerable: true, get:
19
19
  // Factory for creating PostGraphile v5 instances
20
20
  var create_instance_1 = require("./create-instance");
21
21
  Object.defineProperty(exports, "createGraphileInstance", { enumerable: true, get: function () { return create_instance_1.createGraphileInstance; } });
22
+ // Generic module config cache for plugin lookups
23
+ var module_config_cache_1 = require("./module-config-cache");
24
+ Object.defineProperty(exports, "ModuleConfigCache", { enumerable: true, get: function () { return module_config_cache_1.ModuleConfigCache; } });
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ModuleConfigCache — generic LRU cache for module config lookups
3
+ *
4
+ * Provides a bounded, TTL-based cache for runtime config discovery
5
+ * (billing config, agent discovery, inference log info, etc.).
6
+ *
7
+ * Wraps lru-cache with:
8
+ * - LRU eviction (bounded memory)
9
+ * - TTL-based expiry
10
+ * - Named logging for debugging
11
+ * - clear() hook for future LISTEN/NOTIFY invalidation
12
+ */
13
+ export interface ModuleConfigCacheOptions {
14
+ /** Cache name (used in log prefix) */
15
+ name: string;
16
+ /** Max entries before LRU eviction (default: 100) */
17
+ max?: number;
18
+ /** TTL in milliseconds (default: 60_000) */
19
+ ttlMs?: number;
20
+ }
21
+ export declare class ModuleConfigCache<T> {
22
+ private cache;
23
+ private log;
24
+ readonly name: string;
25
+ constructor(opts: ModuleConfigCacheOptions);
26
+ get(key: string): T | undefined;
27
+ set(key: string, value: T): void;
28
+ delete(key: string): boolean;
29
+ clear(): void;
30
+ get size(): number;
31
+ has(key: string): boolean;
32
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * ModuleConfigCache — generic LRU cache for module config lookups
4
+ *
5
+ * Provides a bounded, TTL-based cache for runtime config discovery
6
+ * (billing config, agent discovery, inference log info, etc.).
7
+ *
8
+ * Wraps lru-cache with:
9
+ * - LRU eviction (bounded memory)
10
+ * - TTL-based expiry
11
+ * - Named logging for debugging
12
+ * - clear() hook for future LISTEN/NOTIFY invalidation
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ModuleConfigCache = void 0;
16
+ const lru_cache_1 = require("lru-cache");
17
+ const logger_1 = require("@pgpmjs/logger");
18
+ class ModuleConfigCache {
19
+ cache;
20
+ log;
21
+ name;
22
+ constructor(opts) {
23
+ this.name = opts.name;
24
+ this.log = new logger_1.Logger(`cache:${opts.name}`);
25
+ this.cache = new lru_cache_1.LRUCache({
26
+ max: opts.max ?? 100,
27
+ ttl: opts.ttlMs ?? 60_000,
28
+ updateAgeOnGet: true,
29
+ });
30
+ }
31
+ get(key) {
32
+ return this.cache.get(key);
33
+ }
34
+ set(key, value) {
35
+ this.cache.set(key, value);
36
+ }
37
+ delete(key) {
38
+ return this.cache.delete(key);
39
+ }
40
+ clear() {
41
+ this.log.debug(`Clearing all entries (size=${this.cache.size})`);
42
+ this.cache.clear();
43
+ }
44
+ get size() {
45
+ return this.cache.size;
46
+ }
47
+ has(key) {
48
+ return this.cache.has(key);
49
+ }
50
+ }
51
+ exports.ModuleConfigCache = ModuleConfigCache;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-cache",
3
- "version": "3.11.0",
3
+ "version": "3.11.2",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostGraphile v5 LRU cache with automatic pool cleanup integration",
6
6
  "main": "index.js",
@@ -32,10 +32,10 @@
32
32
  "@pgpmjs/logger": "^2.11.0",
33
33
  "express": "^5.2.1",
34
34
  "grafserv": "1.0.0",
35
- "graphile-realtime-subscriptions": "^0.6.0",
35
+ "graphile-realtime-subscriptions": "^0.7.1",
36
36
  "lru-cache": "^11.2.7",
37
- "pg-cache": "^3.10.0",
38
- "postgraphile": "5.0.0"
37
+ "pg-cache": "^3.10.1",
38
+ "postgraphile": "5.0.3"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/express": "^5.0.6",
@@ -52,5 +52,5 @@
52
52
  "constructive",
53
53
  "v5"
54
54
  ],
55
- "gitHead": "50dc1d69049c207b46c237eba1e1b1cb7a5f928f"
55
+ "gitHead": "030e1144acbd4e288ee74eff2ac0021ca0382ef7"
56
56
  }