@open-mercato/cache 0.11.1-develop.8593.1.50784dae35 → 0.11.1-develop.8665.1.2455b2503c
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/.turbo/turbo-build.log +1 -1
- package/AGENTS.md +27 -21
- package/README.md +30 -0
- package/dist/codec.js +1 -74
- package/dist/codec.js.map +2 -2
- package/dist/defaults.js +1 -6
- package/dist/defaults.js.map +2 -2
- package/dist/errors.js +1 -12
- package/dist/errors.js.map +2 -2
- package/dist/index.js.map +1 -1
- package/dist/patterns.js +1 -35
- package/dist/patterns.js.map +2 -2
- package/dist/provider.js +440 -0
- package/dist/provider.js.map +7 -0
- package/dist/redisConnection.js +2 -0
- package/dist/redisConnection.js.map +7 -0
- package/dist/service.js +320 -80
- package/dist/service.js.map +3 -3
- package/dist/strategies/jsonfile.js +1 -186
- package/dist/strategies/jsonfile.js.map +3 -3
- package/dist/strategies/memory.js +1 -196
- package/dist/strategies/memory.js.map +3 -3
- package/dist/strategies/redis.js +1 -443
- package/dist/strategies/redis.js.map +3 -3
- package/dist/strategies/sqlite.js +1 -196
- package/dist/strategies/sqlite.js.map +3 -3
- package/dist/testing/conformance.js +448 -0
- package/dist/testing/conformance.js.map +7 -0
- package/dist/testing/index.js +12 -0
- package/dist/testing/index.js.map +7 -0
- package/dist/testing/remote.js +182 -0
- package/dist/testing/remote.js.map +7 -0
- package/fixtures/build-conformance-host.mjs +58 -0
- package/fixtures/cache-provider-fixture/index.d.ts +18 -0
- package/fixtures/cache-provider-fixture/index.js +307 -0
- package/fixtures/cache-provider-fixture/package.json +25 -0
- package/fixtures/conformance-child.mjs +41 -0
- package/jest.config.cjs +3 -1
- package/package.json +10 -2
- package/src/__tests__/cache-di-contract-docs.test.ts +2 -2
- package/src/__tests__/conformance.memory-provider.test.ts +77 -0
- package/src/__tests__/provider-fixture.packed.test.ts +178 -0
- package/src/__tests__/provider.test.ts +469 -0
- package/src/__tests__/service.provider.test.ts +513 -0
- package/src/__tests__/service.test.ts +94 -3
- package/src/codec.ts +1 -94
- package/src/defaults.ts +1 -2
- package/src/errors.ts +1 -14
- package/src/index.ts +4 -0
- package/src/patterns.ts +1 -40
- package/src/provider.ts +641 -0
- package/src/redisConnection.ts +1 -0
- package/src/service.ts +396 -89
- package/src/strategies/jsonfile.ts +1 -242
- package/src/strategies/memory.ts +1 -275
- package/src/strategies/redis.ts +1 -615
- package/src/strategies/sqlite.ts +1 -292
- package/src/testing/conformance.ts +569 -0
- package/src/testing/index.ts +11 -0
- package/src/testing/remote.ts +240 -0
- package/src/types.ts +8 -106
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[build:cache] found
|
|
1
|
+
[build:cache] found 17 entry points
|
|
2
2
|
[build:cache] built successfully
|
package/AGENTS.md
CHANGED
|
@@ -14,22 +14,33 @@ The `memory` strategy is per process: a write on one instance never invalidates
|
|
|
14
14
|
|
|
15
15
|
## Memory Strategy Bounds
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Bounded so a process-shared instance (`OM_BOOTSTRAP_CACHE`, workers, CRUD list cache) cannot grow with user-controlled key cardinality.
|
|
18
18
|
|
|
19
|
-
- **LRU cap** —
|
|
20
|
-
-
|
|
21
|
-
- **
|
|
22
|
-
- **Observability** — `stats()` on a memory-backed service surfaces `evictions`, `sweeps`, and `lastSweepReclaimed` (process-global counters) alongside the tenant-scoped `size`/`expired`, so operators can tell whether the bound is actively protecting the process. Other backends omit these fields.
|
|
19
|
+
- **LRU cap** — `maxEntries` (default `50000`); reads refresh recency, writes evict the LRU entries past the cap. Override with `CACHE_MEMORY_MAX_ENTRIES` (commented in `.env.example`); a non-positive value disables the cap (**unbounded** — per-request instances only); an unparseable one is ignored.
|
|
20
|
+
- **Amortized sweep** — every 256 writes a budgeted `O(budget)` pass from the LRU head reclaims expired entries (no timer); the rest go on access, eviction or `cleanup()`.
|
|
21
|
+
- **Observability** — memory-backed `stats()` adds process-global `evictions`, `sweeps`, `lastSweepReclaimed` next to tenant-scoped `size`/`expired`; other backends omit them.
|
|
23
22
|
|
|
24
23
|
## Value Compression
|
|
25
24
|
|
|
26
25
|
The redis and sqlite strategies can compress serialized entries (`packages/cache/src/codec.ts`); memory and jsonfile never do.
|
|
27
26
|
|
|
28
|
-
- **`CACHE_COMPRESSION`** — `off` (default) | `zstd`
|
|
29
|
-
- **`CACHE_COMPRESSION_MIN_BYTES`** —
|
|
30
|
-
- **Reads detect the format by magic bytes**,
|
|
31
|
-
- **
|
|
32
|
-
- **Rollout:**
|
|
27
|
+
- **`CACHE_COMPRESSION`** — `off` (default) | `zstd` (level 1; falls back to `gzip` with one warning when the runtime lacks zstd) | `gzip` (level 6).
|
|
28
|
+
- **`CACHE_COMPRESSION_MIN_BYTES`** — smaller entries (default `1024`) stay plain JSON; compressed form kept only when smaller.
|
|
29
|
+
- **Reads detect the format by magic bytes**, so JSON, zstd and gzip entries coexist across setting changes. Decompression capped at 64 MiB; a corrupt frame is a miss.
|
|
30
|
+
- **Enable** for remote or memory-bound Redis; on localhost Redis/SQLite it only saves memory/disk at a small read cost.
|
|
31
|
+
- **Rollout:** enable only once every instance supports the codec; set `off` before rolling back (older versions drop compressed entries as misses).
|
|
32
|
+
|
|
33
|
+
## Pluggable providers
|
|
34
|
+
|
|
35
|
+
An npm package can replace the stock strategies deployment-wide. Docs: `apps/docs/docs/architecture/cache-providers.mdx`.
|
|
36
|
+
|
|
37
|
+
- **Contract** — server-only `@open-mercato/cache/provider`: `defineCacheProvider` (id `<scope>/<name>`, `safeParse` settings schema, `capability()` → `placement: 'shared' | 'local'`, `create()` → base `CacheStrategy` with required `healthcheck` + `close`), `defineCacheProviderRegistration`, `CacheProviderError` (stable `code`, sanitized message).
|
|
38
|
+
- **Selection** — `src/providers/cache.ts` exports `cacheProviders` (`yarn generate` re-exports it). `CACHE_PROVIDER=<id>` beats `CACHE_STRATEGY`; explicit `strategy` option beats both; `CACHE_PROVIDER_NAMESPACE` required. Unset `CACHE_PROVIDER` ignores registrations (no validation). The selection memo is keyed on (registrations, id, namespace); `setCacheProviderRegistrations` resets it.
|
|
39
|
+
- **Runtime** — every provider operation/close error is rethrown as host-authored `unavailable` (cause non-enumerable); failed init is reused for `CACHE_PROVIDER_RETRY_COOLDOWN_MS` (default 1000); `close()` is terminal (later ops reject `unavailable`, never reconnect). Root `yarn generate` (turbo) passes only `CACHE_*` env — provider settings under other env names must live in `.env`.
|
|
40
|
+
- **MUST NOT fall back to memory** for a provider — rethrow `isCacheProviderError` errors from bootstrap catches. Providers always use the process singleton.
|
|
41
|
+
- Use `describeCacheSelection()`, not `CACHE_STRATEGY`, for readiness, the multi-instance guard and placement warnings.
|
|
42
|
+
- **Provider rules** — keys/tags arrive tenant-scoped; fence by `context.namespace`; `helpers.decode` throws → miss; `deleteByTags`/`cleanup`/`clear` count physical records; apply `context.defaultTtl`.
|
|
43
|
+
- **Verify** with `defineCacheProviderConformance` (`@open-mercato/cache/testing`); reference `fixtures/cache-provider-fixture` + `src/__tests__/provider-fixture.packed.test.ts`.
|
|
33
44
|
|
|
34
45
|
## Always
|
|
35
46
|
|
|
@@ -74,9 +85,9 @@ await cache.deleteByTags(['customers']) // Clears all customer-related cache
|
|
|
74
85
|
|
|
75
86
|
## Consistency vs commit timing
|
|
76
87
|
|
|
77
|
-
Cache invalidation and query-index side effects (`emitCrudSideEffects`) MUST fire **after** the
|
|
88
|
+
Cache invalidation and query-index side effects (`emitCrudSideEffects`) MUST fire **after** the domain write commits, OUTSIDE `withAtomicFlush` (see `packages/core/AGENTS.md`). The read-projection tail (search tokens, vectors, fulltext, coverage) converges asynchronously, so reads may briefly lag a write.
|
|
78
89
|
|
|
79
|
-
|
|
90
|
+
Opt-in `OM_CACHE_SAFETY_ALWAYS_CONSISTENT` (default **OFF**) makes that tail converge synchronously and propagates index-write failures, at added write latency; it does not move side effects into the transaction. See `.ai/specs/2026-06-05-cache-safety-always-consistent.md`.
|
|
80
91
|
|
|
81
92
|
## Adding Caching to a Module
|
|
82
93
|
|
|
@@ -88,15 +99,10 @@ The opt-in env flag `OM_CACHE_SAFETY_ALWAYS_CONSISTENT` (default **OFF**, 100% b
|
|
|
88
99
|
|
|
89
100
|
## Structure
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
packages/cache/src/
|
|
93
|
-
├── strategies/ # Redis, SQLite, memory implementations
|
|
94
|
-
└── __tests__/
|
|
95
|
-
```
|
|
102
|
+
`src/strategies/` (stock backends), `src/provider.ts` (provider contract), `src/testing/` (conformance kit), `fixtures/` (packed provider fixture).
|
|
96
103
|
|
|
97
104
|
## When Modifying This Package
|
|
98
105
|
|
|
99
|
-
- Follow the strategy pattern —
|
|
100
|
-
- Run `yarn test` in `packages/cache
|
|
101
|
-
-
|
|
102
|
-
- The DI token and method names quoted in this file and in `.ai/review-checklist.md` are pinned to the real sources by `src/__tests__/cache-di-contract-docs.test.ts` (it re-derives the token from `packages/core/src/bootstrap.ts` and the members from `CacheStrategy`). Renaming the token or a method MUST update both docs in the same change.
|
|
106
|
+
- Follow the strategy pattern — new strategies go in `strategies/` with the same interface
|
|
107
|
+
- Run `yarn test` in `packages/cache`; verify tag invalidation across all strategies when touching invalidation
|
|
108
|
+
- `src/__tests__/cache-di-contract-docs.test.ts` pins the DI token and method names quoted here and in `.ai/review-checklist.md`; renaming either MUST update both docs.
|
package/README.md
CHANGED
|
@@ -137,6 +137,36 @@ The glob-matching happens on logical keys, so you can keep friendly names for tr
|
|
|
137
137
|
|
|
138
138
|
---
|
|
139
139
|
|
|
140
|
+
## Pluggable cache providers
|
|
141
|
+
|
|
142
|
+
The built-in strategies ship with this package as independent npm providers for memory, SQLite, Redis and JSON files. Existing `CACHE_STRATEGY` settings and the memory default apply. A deployment can also select an installed npm **cache provider**. The app registers it explicitly in `src/providers/cache.ts`:
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { defineCacheProviderRegistration } from '@open-mercato/cache/provider'
|
|
146
|
+
|
|
147
|
+
export const cacheProviders = [
|
|
148
|
+
defineCacheProviderRegistration({
|
|
149
|
+
id: 'acme/example',
|
|
150
|
+
load: () => import('@acme/cache-provider-example').then((module) => module.provider),
|
|
151
|
+
settings: () => ({ endpoints: [process.env.ACME_CACHE_ENDPOINT ?? ''] }),
|
|
152
|
+
}),
|
|
153
|
+
]
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
yarn generate
|
|
158
|
+
CACHE_PROVIDER=acme/example
|
|
159
|
+
CACHE_PROVIDER_NAMESPACE=shop-prod
|
|
160
|
+
#CACHE_PROVIDER_CONNECT_TIMEOUT_MS=10000
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- `CACHE_PROVIDER` wins over `CACHE_STRATEGY`. An explicit programmatic `strategy` still wins over it. A selected provider never falls back to memory: failures surface as a sanitized `CacheProviderError` with a stable `code`.
|
|
164
|
+
- Provider authors build packages with `defineCacheProvider` from `@open-mercato/cache/provider` and verify them with `defineCacheProviderConformance` from `@open-mercato/cache/testing`. The reference implementation is `fixtures/cache-provider-fixture`.
|
|
165
|
+
|
|
166
|
+
Full operator and author guide: [Pluggable cache providers](https://docs.openmercato.com/architecture/cache-providers).
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
140
170
|
## Building & publishing
|
|
141
171
|
|
|
142
172
|
This package lives inside the monorepo but publishes independently. The emitted JS and declaration files live in `dist/` (ignored by git).
|
package/dist/codec.js
CHANGED
|
@@ -1,75 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
const DEFAULT_COMPRESSION_MIN_BYTES = 1024;
|
|
3
|
-
const MAX_DECOMPRESSED_BYTES = 64 * 1024 * 1024;
|
|
4
|
-
const ZSTD_LEVEL = 1;
|
|
5
|
-
const COMPRESSIONS = ["off", "zstd", "gzip"];
|
|
6
|
-
const warnedMessages = /* @__PURE__ */ new Set();
|
|
7
|
-
function warnOnce(message) {
|
|
8
|
-
if (warnedMessages.has(message)) return;
|
|
9
|
-
warnedMessages.add(message);
|
|
10
|
-
console.warn(message);
|
|
11
|
-
}
|
|
12
|
-
function isZstdAvailable() {
|
|
13
|
-
return typeof zlib.zstdCompressSync === "function" && typeof zlib.zstdDecompressSync === "function";
|
|
14
|
-
}
|
|
15
|
-
function parseCacheCompression(raw) {
|
|
16
|
-
const value = raw?.trim().toLowerCase();
|
|
17
|
-
if (!value) return "off";
|
|
18
|
-
if (COMPRESSIONS.includes(value)) return value;
|
|
19
|
-
warnOnce(`[cache] Unknown CACHE_COMPRESSION value "${raw}". Compression stays off.`);
|
|
20
|
-
return "off";
|
|
21
|
-
}
|
|
22
|
-
function parseCacheCompressionMinBytes(raw) {
|
|
23
|
-
if (!raw) return void 0;
|
|
24
|
-
const parsed = Number.parseInt(raw, 10);
|
|
25
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
26
|
-
}
|
|
27
|
-
function resolveCacheCodecConfig(options) {
|
|
28
|
-
const minBytes = options?.compressionMinBytes && options.compressionMinBytes > 0 ? options.compressionMinBytes : DEFAULT_COMPRESSION_MIN_BYTES;
|
|
29
|
-
let compression = options?.compression ?? "off";
|
|
30
|
-
if (compression === "zstd" && !isZstdAvailable()) {
|
|
31
|
-
warnOnce("[cache] zstd is not available in this Node.js runtime. Falling back to gzip cache compression.");
|
|
32
|
-
compression = "gzip";
|
|
33
|
-
}
|
|
34
|
-
return { compression, minBytes };
|
|
35
|
-
}
|
|
36
|
-
function compress(input, compression) {
|
|
37
|
-
if (compression === "zstd") {
|
|
38
|
-
return zlib.zstdCompressSync(input, { params: { [zlib.constants.ZSTD_c_compressionLevel]: ZSTD_LEVEL } });
|
|
39
|
-
}
|
|
40
|
-
return zlib.gzipSync(input);
|
|
41
|
-
}
|
|
42
|
-
function encodeCacheText(json, config) {
|
|
43
|
-
if (config.compression === "off") return json;
|
|
44
|
-
const size = Buffer.byteLength(json);
|
|
45
|
-
if (size < config.minBytes || size > MAX_DECOMPRESSED_BYTES) return json;
|
|
46
|
-
const compressed = compress(Buffer.from(json, "utf8"), config.compression);
|
|
47
|
-
return compressed.length < size ? compressed : json;
|
|
48
|
-
}
|
|
49
|
-
function isZstdFrame(raw) {
|
|
50
|
-
return raw.length >= 4 && raw[0] === 40 && raw[1] === 181 && raw[2] === 47 && raw[3] === 253;
|
|
51
|
-
}
|
|
52
|
-
function isGzipStream(raw) {
|
|
53
|
-
return raw.length >= 2 && raw[0] === 31 && raw[1] === 139;
|
|
54
|
-
}
|
|
55
|
-
function decodeCacheText(raw) {
|
|
56
|
-
if (typeof raw === "string") return raw;
|
|
57
|
-
if (isZstdFrame(raw)) {
|
|
58
|
-
return zlib.zstdDecompressSync(raw, { maxOutputLength: MAX_DECOMPRESSED_BYTES }).toString("utf8");
|
|
59
|
-
}
|
|
60
|
-
if (isGzipStream(raw)) {
|
|
61
|
-
return zlib.gunzipSync(raw, { maxOutputLength: MAX_DECOMPRESSED_BYTES }).toString("utf8");
|
|
62
|
-
}
|
|
63
|
-
return raw.toString("utf8");
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
DEFAULT_COMPRESSION_MIN_BYTES,
|
|
67
|
-
MAX_DECOMPRESSED_BYTES,
|
|
68
|
-
decodeCacheText,
|
|
69
|
-
encodeCacheText,
|
|
70
|
-
isZstdAvailable,
|
|
71
|
-
parseCacheCompression,
|
|
72
|
-
parseCacheCompressionMinBytes,
|
|
73
|
-
resolveCacheCodecConfig
|
|
74
|
-
};
|
|
1
|
+
export * from "@open-mercato/cache-provider-kit/codec";
|
|
75
2
|
//# sourceMappingURL=codec.js.map
|
package/dist/codec.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/codec.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["export * from '@open-mercato/cache-provider-kit/codec'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/defaults.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
const DEFAULT_JSON_FILE_CACHE_PATH = ".mercato/cache/cache.json";
|
|
3
|
-
export {
|
|
4
|
-
DEFAULT_JSON_FILE_CACHE_PATH,
|
|
5
|
-
DEFAULT_SQLITE_CACHE_PATH
|
|
6
|
-
};
|
|
1
|
+
export * from "@open-mercato/cache-provider-kit/defaults";
|
|
7
2
|
//# sourceMappingURL=defaults.js.map
|
package/dist/defaults.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/defaults.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export * from '@open-mercato/cache-provider-kit/defaults'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/errors.js
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
constructor(strategy, dependency, originalError) {
|
|
3
|
-
super(`Cache strategy "${strategy}" requires dependency "${dependency}" which is not available`);
|
|
4
|
-
this.name = "CacheDependencyUnavailableError";
|
|
5
|
-
this.strategy = strategy;
|
|
6
|
-
this.dependency = dependency;
|
|
7
|
-
this.originalError = originalError;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
CacheDependencyUnavailableError
|
|
12
|
-
};
|
|
1
|
+
export * from "@open-mercato/cache-provider-kit/errors";
|
|
13
2
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/errors.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export * from '@open-mercato/cache-provider-kit/errors'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './types'\nexport * from './service'\nexport * from './defaults'\nexport { createMemoryStrategy } from './strategies/memory'\nexport { createRedisStrategy } from './strategies/redis'\nexport { createSqliteStrategy } from './strategies/sqlite'\nexport { createJsonFileStrategy } from './strategies/jsonfile'\nexport { runWithCacheTenant, getCurrentCacheTenant } from './tenantContext'\n"],
|
|
4
|
+
"sourcesContent": ["export * from './types'\nexport * from './service'\nexport * from './defaults'\nexport { createMemoryStrategy } from './strategies/memory'\nexport { createRedisStrategy } from './strategies/redis'\nexport { createSqliteStrategy } from './strategies/sqlite'\nexport { createJsonFileStrategy } from './strategies/jsonfile'\nexport { runWithCacheTenant, getCurrentCacheTenant } from './tenantContext'\nexport type {\n CacheProviderPlacement,\n ResolvedCacheProvider,\n} from './provider'\n"],
|
|
5
5
|
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,oBAAoB,6BAA6B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/patterns.js
CHANGED
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
let patternIndex = 0;
|
|
3
|
-
let keyIndex = 0;
|
|
4
|
-
let starIndex = -1;
|
|
5
|
-
let keyRetryIndex = 0;
|
|
6
|
-
while (keyIndex < key.length) {
|
|
7
|
-
const patternChar = pattern[patternIndex];
|
|
8
|
-
const keyChar = key[keyIndex];
|
|
9
|
-
if (patternChar === "*") {
|
|
10
|
-
starIndex = patternIndex;
|
|
11
|
-
keyRetryIndex = keyIndex;
|
|
12
|
-
patternIndex += 1;
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
if (patternChar === "?" || patternChar === keyChar) {
|
|
16
|
-
patternIndex += 1;
|
|
17
|
-
keyIndex += 1;
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if (starIndex !== -1) {
|
|
21
|
-
patternIndex = starIndex + 1;
|
|
22
|
-
keyRetryIndex += 1;
|
|
23
|
-
keyIndex = keyRetryIndex;
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
while (pattern[patternIndex] === "*") {
|
|
29
|
-
patternIndex += 1;
|
|
30
|
-
}
|
|
31
|
-
return patternIndex === pattern.length;
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
matchCacheKeyPattern
|
|
35
|
-
};
|
|
1
|
+
export * from "@open-mercato/cache-provider-kit/patterns";
|
|
36
2
|
//# sourceMappingURL=patterns.js.map
|
package/dist/patterns.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/patterns.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export * from '@open-mercato/cache-provider-kit/patterns'\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|