create-bcp-app 0.2.15 → 0.2.16
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 +61 -4
- package/package.json +1 -1
- package/template/README.md +53 -0
package/README.md
CHANGED
|
@@ -69,17 +69,17 @@ Select storage provider:
|
|
|
69
69
|
|
|
70
70
|
New projects include `bcp.project.json`.
|
|
71
71
|
|
|
72
|
-
Example for the `0.2.
|
|
72
|
+
Example for the `0.2.16` target:
|
|
73
73
|
|
|
74
74
|
```json
|
|
75
75
|
{
|
|
76
76
|
"schemaVersion": 1,
|
|
77
77
|
"framework": "bcp",
|
|
78
78
|
"projectName": "my-app",
|
|
79
|
-
"frameworkPackage": "npm:@chidchanun/bcp@0.2.
|
|
79
|
+
"frameworkPackage": "npm:@chidchanun/bcp@0.2.16",
|
|
80
80
|
"createdWith": {
|
|
81
81
|
"package": "create-bcp-app",
|
|
82
|
-
"version": "0.2.
|
|
82
|
+
"version": "0.2.16"
|
|
83
83
|
},
|
|
84
84
|
"packageManager": "npm",
|
|
85
85
|
"presets": {
|
|
@@ -367,6 +367,63 @@ Plugins can use `setup/start/stop/dispose`, typed config parsers, a shared servi
|
|
|
367
367
|
|
|
368
368
|
`bcp/plugins` is server-only and cannot be imported into page/client bundles.
|
|
369
369
|
|
|
370
|
+
## Cache Platform v2 — 0.2.16+
|
|
371
|
+
|
|
372
|
+
Use the existing `bcp/cache` entrypoint for provider-neutral shared caching while keeping the original `cache()` and `dedupe()` APIs available.
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
import {
|
|
376
|
+
createCacheStore,
|
|
377
|
+
} from "bcp/cache";
|
|
378
|
+
|
|
379
|
+
export const cache =
|
|
380
|
+
createCacheStore();
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Cache-aside loading:
|
|
384
|
+
|
|
385
|
+
```ts
|
|
386
|
+
const user =
|
|
387
|
+
await cache.getOrSet(
|
|
388
|
+
"user:42",
|
|
389
|
+
() => loadUser(42),
|
|
390
|
+
{
|
|
391
|
+
ttlMs: 60_000,
|
|
392
|
+
tags: ["users"],
|
|
393
|
+
paths: ["/users/42"],
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
For multi-instance deployments, applications can supply Redis-compatible cache and lock adapters:
|
|
399
|
+
|
|
400
|
+
```ts
|
|
401
|
+
import {
|
|
402
|
+
createRedisCacheAdapter,
|
|
403
|
+
createRedisCacheLockAdapter,
|
|
404
|
+
} from "bcp/cache";
|
|
405
|
+
|
|
406
|
+
const redisCache =
|
|
407
|
+
createRedisCacheAdapter({
|
|
408
|
+
client: redisClient,
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
const redisLock =
|
|
412
|
+
createRedisCacheLockAdapter({
|
|
413
|
+
client: redisClient,
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
export const cache =
|
|
417
|
+
createCacheStore({
|
|
418
|
+
adapter: redisCache,
|
|
419
|
+
lock: redisLock,
|
|
420
|
+
});
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
BCP does not install or own the Redis client. Applications remain responsible for credentials, TLS, Cluster/Sentinel configuration, reconnect behavior and connection shutdown.
|
|
424
|
+
|
|
425
|
+
`getOrSet()` provides local singleflight and can use distributed lock leases with heartbeat renewal to reduce cache stampedes across instances.
|
|
426
|
+
|
|
370
427
|
## Storage providers
|
|
371
428
|
|
|
372
429
|
Supported presets are Local Server, Amazon S3 and Cloudflare R2. Storage credentials are server-only and must not use `BCP_PUBLIC_*` variables.
|
|
@@ -405,5 +462,5 @@ npm run generate -- migration create_users
|
|
|
405
462
|
For prerelease/local package verification:
|
|
406
463
|
|
|
407
464
|
```bash
|
|
408
|
-
npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.
|
|
465
|
+
npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.16.tgz
|
|
409
466
|
```
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -288,6 +288,59 @@ Use `defineModule()` when a reusable package needs to bundle multiple plugin def
|
|
|
288
288
|
|
|
289
289
|
`bcp/plugins` is server-only and cannot be imported from page/client bundles.
|
|
290
290
|
|
|
291
|
+
## Cache Platform v2 — BCP 0.2.16+
|
|
292
|
+
|
|
293
|
+
Use `createCacheStore()` for async cache-aside loading, shared adapters and distributed cache-fill coordination.
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
import {
|
|
297
|
+
createCacheStore,
|
|
298
|
+
} from "bcp/cache";
|
|
299
|
+
|
|
300
|
+
export const cache =
|
|
301
|
+
createCacheStore();
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
const user =
|
|
306
|
+
await cache.getOrSet(
|
|
307
|
+
"user:42",
|
|
308
|
+
() => loadUser(42),
|
|
309
|
+
{
|
|
310
|
+
ttlMs: 60_000,
|
|
311
|
+
tags: ["users"],
|
|
312
|
+
paths: ["/users/42"],
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
For multiple instances, connect a shared cache and lock provider:
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
import {
|
|
321
|
+
createRedisCacheAdapter,
|
|
322
|
+
createRedisCacheLockAdapter,
|
|
323
|
+
} from "bcp/cache";
|
|
324
|
+
|
|
325
|
+
const redisCache =
|
|
326
|
+
createRedisCacheAdapter({
|
|
327
|
+
client: redisClient,
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const redisLock =
|
|
331
|
+
createRedisCacheLockAdapter({
|
|
332
|
+
client: redisClient,
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
export const cache =
|
|
336
|
+
createCacheStore({
|
|
337
|
+
adapter: redisCache,
|
|
338
|
+
lock: redisLock,
|
|
339
|
+
});
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
BCP does not install or own a Redis client. The default adapter namespace is `bcp:{cache}`. The original `cache()` and `dedupe()` APIs remain available for backward-compatible process-local caching.
|
|
343
|
+
|
|
291
344
|
## Generate framework files
|
|
292
345
|
|
|
293
346
|
```bash
|