@hyperttp/cache 1.0.22 → 1.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 IT IF OR
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ ```markdown
2
+ # hyperttp-cache
3
+
4
+ > [Русский](https://github.com/IT-IF-OR/hyperttp-cache/tree/main/lang/ru) | English
5
+
6
+ ---
7
+
8
+ ## 🌐 Language
9
+
10
+ - 🇺🇸 English
11
+ - 🇷🇺 [Русский](https://github.com/IT-IF-OR/hyperttp-cache/tree/main/lang/ru)
12
+
13
+ ---
14
+
15
+ Blazing fast, isomorphic cache management and concurrent request deduplication plugin for the high-performance
16
+ `Hyperttp` HTTP client. Optimized for **Bun** and **Node.js** runtimes.
17
+
18
+ The plugin seamlessly integrates into the flat `HyperCore` lifecycle pipeline, protecting your backend from server
19
+ breakdown (**Cache Stampede Protection**) and providing smart in-memory storage based on the **LRU (Least Recently Used)**
20
+ strategy.
21
+
22
+ ---
23
+
24
+ ## 🔥 Key Features
25
+
26
+ - 🧠 **LRU Strategy with TTL Support:** Automatically evicts old entries when reaching limits. With every `GET`
27
+ request, the entry age resets (`updateAgeOnGet: true`), keeping hot data cached in memory.
28
+ - 🚀 **In-Flight Deduplication:** Concurrent fan-out requests targeting the same URL are grouped into a single network
29
+ hot path. The response is cloned and distributed to all waiting subscribers simultaneously.
30
+ - 🔄 **HTTP Revalidation:** Full freshness verification support via `ETag` (`If-None-Match`) and `Last-Modified`
31
+ (`If-Modified-Since`). Automatically re-hydrates empty `304` responses with cached data bodies.
32
+ - 🛡️ **Fail-Safe Processing:** When network processing exceptions occur, the in-flight waiting pool is instantly
33
+ purged (`onError`), unblocking immediate subsequent retry attempts.
34
+ - 📊 **Core Extension:** Automatically injects cache management methods (`clearCache`) and appends a `cacheSize`
35
+ telemetry metric into the core `getStats()` architecture.
36
+
37
+ ---
38
+
39
+ ## 📦 Installation
40
+
41
+ ```bash
42
+ bun add hyperttp-cache
43
+ # or
44
+ npm install hyperttp-cache
45
+
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 🚀 Quick Start
51
+
52
+ Simply import the `withCache` factory and append it to your client's plugin array. Cache configurations are
53
+ passed directly within the global options block.
54
+
55
+ ```typescript
56
+ import { createClient } from "@hyperttp/core";
57
+ import { withCache } from "hyperttp-cache";
58
+
59
+ const client = createClient({
60
+ plugins: [withCache()],
61
+ cache: {
62
+ enabled: true,
63
+ ttl: 60_000, // 1 minute (defaults to 300_000 ms)
64
+ maxSize: 1000, // Limit to 1000 items (defaults to 500)
65
+ methods: ["GET"], // HTTP methods authorized for downstream caching
66
+ },
67
+ });
68
+
69
+ // 1. The first request goes out to the network and populates the cache
70
+ const res1 = await client.get("/api/data");
71
+
72
+ // 2. Subsequent requests instantly return an isolated clone from the cache
73
+ const res2 = await client.get("/api/data");
74
+
75
+ ```
76
+
77
+ ---
78
+
79
+ ## ⚙️ Configuration Options (`CacheManagerOptions`)
80
+
81
+ The plugin configuration layer is fully typed and extends the default client option interfaces:
82
+
83
+ | Parameter | Type | Default | Description |
84
+ | --- | --- | --- | --- |
85
+ | `cache.enabled` | `boolean` | `false` | Activation status flag for the caching layer. |
86
+ | `cache.ttl` | `number` | `300_000` (5 min) | Cache entry time-to-live threshold (in milliseconds). |
87
+ | `cache.maxSize` | `number` | `500` | Maximum entries allowed inside the LRU pool before eviction begins. |
88
+ | `cache.methods` | `Method[]` | `["GET"]` | Array of HTTP methods authorized for response interception. |
89
+
90
+ ---
91
+
92
+ ## 🛠️ Core API Extensions
93
+
94
+ The plugin extends the global `@hyperttp/types` interface declarations. The following lifecycle methods become
95
+ directly accessible via the client core instance:
96
+
97
+ ### Purging Cache
98
+
99
+ ```typescript
100
+ // Purge the entire cache system
101
+ client.clearCache();
102
+
103
+ // Evict a specific URL key from the storage
104
+ client.clearCache("/api/data");
105
+
106
+ ```
107
+
108
+ ### Telemetry
109
+
110
+ If your core implementation supports the `getStats()` routine, the plugin automatically appends the current cache size:
111
+
112
+ ```typescript
113
+ const stats = client.getStats();
114
+ console.log(stats.cacheSize); // Outputs the current number of active entries inside the LRU storage
115
+
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 📐 Lifecycle Architecture
121
+
122
+ The plugin utilizes atomic, decoupled lifecycle hooks instead of overhead-heavy middleware wrappers:
123
+
124
+ 1. **`onRequest`**: Evaluates local key hits inside the `CacheManager`. If the matching record is fresh and doesn't
125
+ require validation, it returns a clone, short-circuiting the chain. If a concurrent request to the same URL is active,
126
+ it hooks into its matching follower `Promise`. If a partial hit requires validation, it appends conditional headers
127
+ (`If-None-Match` / `If-Modified-Since`).
128
+ 2. **`onResponse`**: Intercepts successful downstream outputs. Re-hydrates an empty `304 Not Modified` status code
129
+ back into a full `200 OK` response by recovering body content from memory. Saves valid `200` ranges containing validation
130
+ metadata and resolves execution triggers for all waiting `In-Flight` threads.
131
+ 3. **`onError`**: In the event of a critical network failure, it instantly flushes matching active tracking task entries
132
+ from the map to ensure subsequent retries targeting the failed endpoint are never deadlocked.
133
+
134
+ ---
135
+
136
+ ## 📄 License
137
+
138
+ MIT
139
+
140
+ ```
141
+
142
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperttp/cache",
3
- "version": "1.0.22",
3
+ "version": "1.1.1",
4
4
  "description": "High-performance LRU caching plugin for Hyperttp client",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -15,10 +15,11 @@
15
15
  "url": "git+https://github.com/IT-IF-OR/hyperttp-cache.git"
16
16
  },
17
17
  "dependencies": {
18
- "lru-cache": "^11.5.0"
18
+ "@hyperttp/types": "^0.1.1",
19
+ "lru-cache": "^11.5.1"
19
20
  },
20
21
  "peerDependencies": {
21
- "@hyperttp/core": "^1.1.8"
22
+ "@hyperttp/core": "^1.2.0"
22
23
  },
23
24
  "private": false
24
25
  }
package/plugin.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { HyperPlugin } from "@hyperttp/core";
1
+ import type { HyperPlugin } from "@hyperttp/types";
2
2
  import type { CacheManagerOptions } from "./types/cache.js";
3
3
  import { CacheManager } from "./utils/CacheManager.js";
4
- declare module "@hyperttp/core" {
4
+ declare module "@hyperttp/types" {
5
5
  interface PluginContext {
6
6
  cache?: CacheManager;
7
7
  }
@@ -10,9 +10,15 @@ declare module "@hyperttp/core" {
10
10
  enabled: boolean;
11
11
  };
12
12
  }
13
- interface HyperCore {
13
+ interface IHyperCore {
14
14
  clearCache(key?: string): void;
15
+ getStats?(): Record<string, any>;
15
16
  }
16
17
  }
18
+ /**
19
+ * @ru Фабрика плагина кэширования и дедупликации конкурентных запросов для HyperCore.
20
+ * @en Cache management and concurrent request deduplication plugin factory for HyperCore.
21
+ * @returns Модуль расширения ядра в рамках линейного жизненного цикла. / Configured extension plugin container.
22
+ */
17
23
  export declare function withCache(): HyperPlugin;
18
24
  //# sourceMappingURL=plugin.d.ts.map
package/plugin.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAKZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,aAAa;QACrB,KAAK,CAAC,EAAE,YAAY,CAAC;KACtB;IACD,UAAU,wBAAwB;QAChC,KAAK,CAAC,EAAE,mBAAmB,GAAG;YAC5B,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;KACH;IACD,UAAU,SAAS;QACjB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAChC;CACF;AAED,wBAAgB,SAAS,IAAI,WAAW,CA+FvC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EAKZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,QAAQ,iBAAiB,CAAC;IAC/B,UAAU,aAAa;QACrB,KAAK,CAAC,EAAE,YAAY,CAAC;KACtB;IACD,UAAU,wBAAwB;QAChC,KAAK,CAAC,EAAE,mBAAmB,GAAG;YAC5B,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;KACH;IACD,UAAU,UAAU;QAClB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAClC;CACF;AAaD;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,WAAW,CA+LvC"}
package/plugin.js CHANGED
@@ -1,12 +1,44 @@
1
1
  import { CacheManager } from "./utils/CacheManager.js";
2
+ /**
3
+ * @ru Фабрика плагина кэширования и дедупликации конкурентных запросов для HyperCore.
4
+ * @en Cache management and concurrent request deduplication plugin factory for HyperCore.
5
+ * @returns Модуль расширения ядра в рамках линейного жизненного цикла. / Configured extension plugin container.
6
+ */
2
7
  export function withCache() {
8
+ /**
9
+ * @private
10
+ * @ru Изолированный инстанс менеджера кэша для текущего клиента.
11
+ * @en Isolated cache manager orchestration instance allocated for the target client.
12
+ */
3
13
  let cache;
14
+ /**
15
+ * @private
16
+ * @ru Список HTTP-методов, для которых разрешено кэширование ответов.
17
+ * @en Set of HTTP request methods authorized for downstream response caching.
18
+ */
4
19
  let allowedMethods;
20
+ /**
21
+ * @private
22
+ * @ru Карта активных сетевых запросов для предотвращения каскадного заваливания бэкенда (Cache Stampede).
23
+ * @en Registry of concurrent requests in execution to prevent backend server breakdown (Cache Stampede).
24
+ */
5
25
  const inFlight = new Map();
6
26
  return {
7
27
  name: "hyperttp-cache",
8
- phase: "PREPARE",
9
- enabled: (config) => !!config.cache?.enabled,
28
+ /**
29
+ * @ru Динамическая проверка необходимости активации кэширования на основе переданных опций.
30
+ * @en Dynamic check evaluating if the caching plugin layer should be appended based on client runtime options.
31
+ * @param config - Глобальная конфигурация инстанса клиента. / Global active client lifecycle options.
32
+ * @returns Индикатор необходимости сборки плагина. / Lifecycle activation indicator status.
33
+ */
34
+ enabled: (config) => {
35
+ return !!config.cache?.enabled;
36
+ },
37
+ /**
38
+ * @ru Однократный хук инициализации. Настраивает менеджер кэша и внедряет методы отладки/очистки в ядро.
39
+ * @en One-time setup context hook. Orchestrates the cache manager and extends telemetry/purge interfaces inside the core.
40
+ * @param ctx - Общий контекст окружения плагина. / Shared plugin execution context metadata.
41
+ */
10
42
  setup(ctx) {
11
43
  const { core, config } = ctx;
12
44
  cache = new CacheManager(config?.cache);
@@ -27,54 +59,99 @@ export function withCache() {
27
59
  return key ? cache.delete(key) : cache.clear();
28
60
  };
29
61
  },
30
- wrapDispatch: (next) => {
31
- return (req) => {
32
- const method = req.method.toUpperCase();
33
- if (!allowedMethods.has(method)) {
34
- return next(req);
35
- }
36
- const cacheKey = req.url;
37
- const cachedEntry = cache.getWithMetadata(cacheKey);
38
- if (cachedEntry !== undefined) {
39
- if (!cachedEntry.etag && !cachedEntry.lastModified) {
40
- return Promise.resolve(cachedEntry.data.clone());
41
- }
42
- req.headers = { ...req.headers };
43
- if (cachedEntry.etag)
44
- req.headers["if-none-match"] = cachedEntry.etag;
45
- if (cachedEntry.lastModified)
46
- req.headers["if-modified-since"] = cachedEntry.lastModified;
47
- }
48
- if (inFlight.has(cacheKey)) {
49
- return inFlight.get(cacheKey);
50
- }
51
- const requestPromise = next(req)
52
- .then((response) => {
53
- inFlight.delete(cacheKey);
54
- if (!response)
55
- return response;
56
- if (response.status === 304 && cachedEntry !== undefined) {
57
- return cachedEntry.data.clone();
58
- }
59
- if (response.status >= 200 && response.status < 300) {
60
- const valueToCache = response.clone();
61
- const headers = response.headers;
62
- const etag = headers?.["etag"] || headers?.["ETag"];
63
- const lastModified = headers?.["last-modified"] || headers?.["Last-Modified"];
64
- cache.setWithMetadata(cacheKey, valueToCache, {
65
- etag: typeof etag === "string" ? etag : undefined,
66
- lastModified: typeof lastModified === "string" ? lastModified : undefined,
67
- });
68
- }
69
- return response;
70
- })
71
- .catch((err) => {
72
- inFlight.delete(cacheKey);
73
- throw err;
62
+ /**
63
+ * @ru Перехватчик фазы отправки запроса. Проверяет локальные кэш-хиты и координирует пулинг конкурентных задач.
64
+ * @en Request phase interceptor. Evaluates local cache hits, appends conditional headers, or hooks into active in-flight targets.
65
+ * @param req - Сконфигурированный внутренний объект запроса. / Contextual internal request parameters.
66
+ * @param ctx - Общий контекст окружения плагина. / Shared plugin execution context metadata.
67
+ * @returns Мгновенный изолированный ответ из кэша, обертку гонки или void для продолжения сетевого цикла. / Short-circuit response clone, matching follower promise tracker, or void execution.
68
+ */
69
+ onRequest(req,
70
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
71
+ _ctx) {
72
+ const method = req.method.toUpperCase();
73
+ if (!allowedMethods.has(method)) {
74
+ return;
75
+ }
76
+ const cacheKey = req.url;
77
+ const cachedEntry = cache.getWithMetadata(cacheKey);
78
+ if (cachedEntry !== undefined &&
79
+ !cachedEntry.etag &&
80
+ !cachedEntry.lastModified) {
81
+ return cachedEntry.data.clone();
82
+ }
83
+ // Частичный кэш-хит, подмешиваем заголовки проверки свежести
84
+ if (cachedEntry !== undefined) {
85
+ req.headers = { ...req.headers };
86
+ if (cachedEntry.etag)
87
+ req.headers["if-none-match"] = cachedEntry.etag;
88
+ if (cachedEntry.lastModified)
89
+ req.headers["if-modified-since"] = cachedEntry.lastModified;
90
+ }
91
+ const currentInFlight = inFlight.get(cacheKey);
92
+ if (currentInFlight) {
93
+ return currentInFlight.promise.then((res) => res.clone());
94
+ }
95
+ let resolveFn;
96
+ let rejectFn;
97
+ const promise = new Promise((res, rej) => {
98
+ resolveFn = res;
99
+ rejectFn = rej;
100
+ });
101
+ promise.catch(() => { });
102
+ inFlight.set(cacheKey, { promise, resolve: resolveFn, reject: rejectFn });
103
+ },
104
+ /**
105
+ * @ru Перехватчик фазы получения ответа. Обновляет хранилище или трансформирует статус 304 в полные данные из кэша.
106
+ * @en Response phase interceptor. Saves raw outputs to the storage layer or re-hydrates empty 304 responses with cached data bodies.
107
+ */
108
+ onResponse(res, req,
109
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
110
+ _ctx) {
111
+ const cacheKey = req.url;
112
+ const trigger = inFlight.get(cacheKey);
113
+ if (!trigger) {
114
+ return;
115
+ }
116
+ inFlight.delete(cacheKey);
117
+ const cachedEntry = cache.getWithMetadata(cacheKey);
118
+ if (res.status === 304 && cachedEntry !== undefined) {
119
+ const clonedCache = cachedEntry.data.clone();
120
+ Object.assign(res, clonedCache);
121
+ res.status = clonedCache.status ?? 200;
122
+ trigger.resolve(clonedCache);
123
+ return;
124
+ }
125
+ if (res.status >= 200 && res.status < 300) {
126
+ const valueToCache = res.clone();
127
+ const headers = res.headers;
128
+ const etag = headers?.["etag"] || headers?.["ETag"];
129
+ const lastModified = headers?.["last-modified"] || headers?.["Last-Modified"];
130
+ cache.setWithMetadata(cacheKey, valueToCache, {
131
+ etag: typeof etag === "string" ? etag : undefined,
132
+ lastModified: typeof lastModified === "string" ? lastModified : undefined,
74
133
  });
75
- inFlight.set(cacheKey, requestPromise);
76
- return requestPromise;
77
- };
134
+ trigger.resolve(res.clone());
135
+ return;
136
+ }
137
+ trigger.resolve(res.clone());
138
+ },
139
+ /**
140
+ * @ru Перехватчик фазы критических сбоев. Разрывает пул ожидания дедупликации, транслируя ошибку всем подписчикам.
141
+ * @en Error phase interceptor. Purges matching metadata maps and forwards pipeline processing exceptions to all waiting threads.
142
+ * @param err - Специфичный объект ошибки сетевого клиента. / Normalized client-level error framework tracking details.
143
+ * @param req - Сконфигурированный внутренний объект запроса. / Contextual internal request parameters.
144
+ * @param ctx - Общий контекст окружения плагина. / Shared plugin execution context metadata.
145
+ */
146
+ onError(err, req,
147
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
148
+ _ctx) {
149
+ const cacheKey = req.url;
150
+ const trigger = inFlight.get(cacheKey);
151
+ if (trigger) {
152
+ inFlight.delete(cacheKey);
153
+ trigger.reject(err);
154
+ }
78
155
  },
79
156
  };
80
157
  }
package/plugin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAgBvD,MAAM,UAAU,SAAS;IACvB,IAAI,KAAmB,CAAC;IACxB,IAAI,cAA2B,CAAC;IAChC,MAAM,QAAQ,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export interface CacheEntry<T> {
3
3
  data: T;
4
4
  etag?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/types/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/types/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B"}