layercache 1.3.1 → 1.3.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/README.md +0 -39
- package/package.json +2 -12
- package/examples/nestjs-module/app.module.ts +0 -15
- package/packages/nestjs/dist/index.cjs +0 -3952
- package/packages/nestjs/dist/index.d.cts +0 -629
- package/packages/nestjs/dist/index.d.ts +0 -629
- package/packages/nestjs/dist/index.js +0 -3915
package/README.md
CHANGED
|
@@ -182,7 +182,6 @@ layercache plugs into the frameworks you already use:
|
|
|
182
182
|
| **Hono** | `createHonoCacheMiddleware(cache, opts)` - edge-compatible middleware |
|
|
183
183
|
| **tRPC** | `createTrpcCacheMiddleware(cache, prefix, opts)` - procedure middleware |
|
|
184
184
|
| **GraphQL** | `cacheGraphqlResolver(cache, prefix, resolver, opts)` - field resolver wrapper |
|
|
185
|
-
| **NestJS** | `@cachestack/nestjs` - `CacheStackModule.forRoot()`, `@Cacheable()` decorator |
|
|
186
185
|
| **Next.js** | Works natively with App Router and API routes |
|
|
187
186
|
| **OpenTelemetry** | `createOpenTelemetryPlugin(cache, tracer)` - event-driven tracing spans without monkey-patching |
|
|
188
187
|
|
|
@@ -205,42 +204,6 @@ app.get('/api/users', createExpressCacheMiddleware(cache, {
|
|
|
205
204
|
|
|
206
205
|
</details>
|
|
207
206
|
|
|
208
|
-
<details>
|
|
209
|
-
<summary><b>NestJS example</b></summary>
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
npm install @cachestack/nestjs
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
```ts
|
|
216
|
-
// app.module.ts
|
|
217
|
-
import { CacheStackModule } from '@cachestack/nestjs'
|
|
218
|
-
|
|
219
|
-
@Module({
|
|
220
|
-
imports: [
|
|
221
|
-
CacheStackModule.forRoot({
|
|
222
|
-
layers: [
|
|
223
|
-
new MemoryLayer({ ttl: 20 }),
|
|
224
|
-
new RedisLayer({ client: redis, ttl: 300 })
|
|
225
|
-
]
|
|
226
|
-
})
|
|
227
|
-
]
|
|
228
|
-
})
|
|
229
|
-
export class AppModule {}
|
|
230
|
-
|
|
231
|
-
// user.service.ts
|
|
232
|
-
@Injectable()
|
|
233
|
-
export class UserService {
|
|
234
|
-
constructor(@InjectCacheStack() private readonly cache: CacheStack) {}
|
|
235
|
-
|
|
236
|
-
async getUser(id: number) {
|
|
237
|
-
return this.cache.get(`user:${id}`, () => this.db.findUser(id))
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
</details>
|
|
243
|
-
|
|
244
207
|
<details>
|
|
245
208
|
<summary><b>Next.js App Router example</b></summary>
|
|
246
209
|
|
|
@@ -348,7 +311,6 @@ Benchmark commands, fixtures, and scenario notes live in [docs/benchmarking.md](
|
|
|
348
311
|
| Persistence / snapshots | -- | -- | -- | **Yes** |
|
|
349
312
|
| Compression | -- | -- | Yes | **Yes** |
|
|
350
313
|
| Admin CLI | -- | -- | -- | **Yes** |
|
|
351
|
-
| NestJS module | -- | -- | -- | **Yes** |
|
|
352
314
|
| TypeScript-first | Partial | Yes | Yes | **Yes** |
|
|
353
315
|
| Wrap / decorator API | Yes | -- | -- | **Yes** |
|
|
354
316
|
| Namespaces | -- | Yes | Yes | **Yes** |
|
|
@@ -377,7 +339,6 @@ Benchmark commands, fixtures, and scenario notes live in [docs/benchmarking.md](
|
|
|
377
339
|
The [`examples/`](./examples) directory contains ready-to-run projects:
|
|
378
340
|
|
|
379
341
|
- [`express-api/`](./examples/express-api/) - Express REST API with layered caching
|
|
380
|
-
- [`nestjs-module/`](./examples/nestjs-module/) - NestJS module integration
|
|
381
342
|
- [`nextjs-api-routes/`](./examples/nextjs-api-routes/) - Next.js App Router with layercache
|
|
382
343
|
|
|
383
344
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layercache",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Production-ready multi-layer caching for Node.js. Stack memory + Redis + disk behind one API with stampede prevention, tag invalidation, stale serving, and full observability.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cache",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"nodejs",
|
|
19
19
|
"express",
|
|
20
20
|
"fastify",
|
|
21
|
-
"nestjs",
|
|
22
21
|
"hono",
|
|
23
22
|
"trpc",
|
|
24
23
|
"graphql",
|
|
@@ -54,20 +53,15 @@
|
|
|
54
53
|
},
|
|
55
54
|
"files": [
|
|
56
55
|
"dist",
|
|
57
|
-
"packages/nestjs/dist",
|
|
58
56
|
"examples",
|
|
59
57
|
"benchmarks"
|
|
60
58
|
],
|
|
61
59
|
"engines": {
|
|
62
60
|
"node": ">=20"
|
|
63
61
|
},
|
|
64
|
-
"workspaces": [
|
|
65
|
-
"packages/nestjs"
|
|
66
|
-
],
|
|
67
62
|
"scripts": {
|
|
68
63
|
"build": "tsup src/index.ts src/cli.ts src/edge.ts --format esm,cjs --dts",
|
|
69
|
-
"build:
|
|
70
|
-
"build:all": "npm run build && npm run build:nestjs",
|
|
64
|
+
"build:all": "npm run build",
|
|
71
65
|
"test": "vitest run",
|
|
72
66
|
"test:coverage": "vitest run --coverage",
|
|
73
67
|
"test:watch": "vitest",
|
|
@@ -96,16 +90,12 @@
|
|
|
96
90
|
},
|
|
97
91
|
"devDependencies": {
|
|
98
92
|
"@biomejs/biome": "^1.9.4",
|
|
99
|
-
"@nestjs/common": "^11.1.0",
|
|
100
|
-
"@nestjs/core": "^11.1.0",
|
|
101
93
|
"@types/autocannon": "^7.12.7",
|
|
102
94
|
"@types/node": "^22.15.2",
|
|
103
95
|
"@vitest/coverage-v8": "^4.1.2",
|
|
104
96
|
"autocannon": "^8.0.0",
|
|
105
97
|
"ioredis": "^5.6.1",
|
|
106
98
|
"ioredis-mock": "^8.13.0",
|
|
107
|
-
"reflect-metadata": "^0.2.2",
|
|
108
|
-
"rxjs": "^7.8.1",
|
|
109
99
|
"tsup": "^8.5.0",
|
|
110
100
|
"tsx": "^4.19.3",
|
|
111
101
|
"typescript": "^5.8.3",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Module } from '@nestjs/common'
|
|
2
|
-
import Redis from 'ioredis'
|
|
3
|
-
import { CacheStackModule } from '../../packages/nestjs/src'
|
|
4
|
-
import { MemoryLayer, RedisLayer } from '../../src'
|
|
5
|
-
|
|
6
|
-
const redis = new Redis(process.env.REDIS_URL)
|
|
7
|
-
|
|
8
|
-
@Module({
|
|
9
|
-
imports: [
|
|
10
|
-
CacheStackModule.forRoot({
|
|
11
|
-
layers: [new MemoryLayer({ ttl: 20 }), new RedisLayer({ client: redis, ttl: 300 })]
|
|
12
|
-
})
|
|
13
|
-
]
|
|
14
|
-
})
|
|
15
|
-
export class AppModule {}
|