v0.2.0 — single-flight, OTel, integration tests
Pre-release
Pre-release
First minor bump. Three differentiators land in this release.
Added
- Single-flight refresh lock (
singleFlight: true,
singleFlightLockTtlSec: 10). Opt-in stampede protection at the SWR
boundary. Uses the bundledrefresh-tag-lock.luascript over a Redis
SETNX-style lock; only the leader's stale read triggers the
background refresh, all others fall through to the follower path.
Two newMetricEventtypes (cache.stale.refresh.leader,
cache.stale.refresh.follower) appear inonMetricso operators can
verify leadership balance. Lock-acquisition failures are best-effort
and always degrade to the safe follower path; the stale entry is
served regardless. - OpenTelemetry reference adapter at
examples/opentelemetry/.
The library itself stays dependency-free; the example shows the
smallest viable wiring ofonMetricto OTel counters and histograms
with bounded cardinality (no cache keys or tag names emitted as
attributes). - Integration tests against real Redis 7 (21 scenarios) covering
bothredis@5andioredisadapters. Each adapter runs the same
test grid so a regression in either client library is pinpointed
immediately. New scripts:npm run test:integration,
npm run test:integration:up/:downfor the docker-compose
fixture. - CI integration job runs the integration suite against an
ephemeral Redis 7 service container on every PR. - GitHub Actions OIDC publish path in
.github/workflows/release.yml
withid-token: writeandNPM_CONFIG_PROVENANCE=true. Currently
scoped toworkflow_dispatchtrigger so the first GHA-driven publish
can be observed; flip topush: mainonce the changesets cadence
stabilizes. Tarballs published from the workflow will land on npm
with verified provenance.
Changed
MetricEventTypeunion grew three new entries:
cache.stale.refresh.leader,cache.stale.refresh.follower,
cache.stale.refresh.skipped. The legacycache.staleevent still
fires whensingleFlightis off (default).HandlerStatenow carries aninstanceId(read fromHOSTNAME/
ECS_TASK_ID/pid-<pid>) and embeds it in every refresh-lock
acquisition for operator-side observability.
Compatibility
- No breaking changes. All existing 0.1.x configurations continue to
work;singleFlightdefaults tofalse.
Verified
- 72 unit tests (8 files) + 21 integration tests (1 file × 21 scenarios)
all green. - arethetypeswrong: 28/28 cells green.
- publint: clean.
Install: npm install @leejpsd/nextjs-cache-handler
npm: https://www.npmjs.com/package/@leejpsd/nextjs-cache-handler/v/0.2.0