@postgresx/noredis 0.5.2 → 0.6.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/README.md +59 -2
- package/dist/adapters/ioredis.d.ts +2 -2
- package/dist/adapters/redis.d.ts +2 -2
- package/dist/adapters/web.d.ts +2 -0
- package/dist/{chunk-VLFUE33D.js → chunk-BD36RDOX.js} +111 -11
- package/dist/{client-Dpoe2LdN.d.ts → client-DP3ssToT.d.ts} +16 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +133 -5
- package/dist/kv-cache.d.ts +23 -1
- package/dist/kv-cache.js +1 -1
- package/dist/kv.d.ts +3 -1
- package/dist/kv.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -249,6 +249,36 @@ If package-name aliasing is useful during migration, use the thin re-export
|
|
|
249
249
|
packages `@postgresx/noredis-ioredis` and `@postgresx/noredis-redis`. They are
|
|
250
250
|
still facades over `PgredisClient`; they do not provide drop-in constructors.
|
|
251
251
|
|
|
252
|
+
### L1 invalidation and atomic swaps
|
|
253
|
+
|
|
254
|
+
Configure a listener factory to keep the local L1 cache coherent across
|
|
255
|
+
processes. The listener must use a dedicated connection that supports
|
|
256
|
+
`LISTEN`; do not reuse a transaction-pooled request connection.
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
import { createPgredis } from "@postgresx/noredis";
|
|
260
|
+
import { createPgNodeListener } from "@postgresx/noredis/adapters/node";
|
|
261
|
+
|
|
262
|
+
const pg = createPgredis({
|
|
263
|
+
sql,
|
|
264
|
+
cache: {
|
|
265
|
+
notify: {
|
|
266
|
+
listener: ({ channels, onNotify }) =>
|
|
267
|
+
createPgNodeListener(directDatabaseUrl, { channels, onNotify })
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
pg.cache.stopInvalidationListener();
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Remote notifications invalidate matching L1 entries. A listener reconnect
|
|
276
|
+
clears the complete L1 cache by default so notifications missed during the
|
|
277
|
+
disconnect cannot leave stale entries behind. `getset()` runs in a retried
|
|
278
|
+
serializable transaction and therefore requires an adapter with `begin()`;
|
|
279
|
+
the built-in Bun and Node adapters provide it. `getdel()` uses one atomic
|
|
280
|
+
`DELETE ... RETURNING` statement.
|
|
281
|
+
|
|
252
282
|
## Pub/Sub
|
|
253
283
|
|
|
254
284
|
Publishing uses only the configured SQL adapter. Bun LISTEN/NOTIFY consumption
|
|
@@ -411,7 +441,7 @@ Remaining gates before a production or 1.0 launch:
|
|
|
411
441
|
|
|
412
442
|
| Area | Status | Why it matters | Recommended action |
|
|
413
443
|
| --- | --- | --- | --- |
|
|
414
|
-
| Real database coverage | Added in CI | PostgreSQL DDL, indexes, transactions, JSONB behavior, and LISTEN/NOTIFY reconnect behavior need real database coverage. | CI runs `bun run test:integration` against PostgreSQL
|
|
444
|
+
| Real database coverage | Added in CI | PostgreSQL DDL, indexes, transactions, JSONB behavior, and LISTEN/NOTIFY reconnect behavior need real database coverage. | CI runs `bun run test:integration` against PostgreSQL 17 and 18. Run locally with `TEST_DATABASE_URL` when debugging. |
|
|
415
445
|
| Benchmark baseline | Generated | `benchmark.md` is generated by GitHub Actions and includes both service-level PostgreSQL columns and L1 hot-read columns. | Benchmark-relevant changes refresh it automatically; local benchmark runs are optional. |
|
|
416
446
|
| Install smoke test | Added in CI | Build output exists, but the published package shape should be verified from a packed tarball, including subpath exports. | CI runs `bun run smoke:pack` to import packed tarballs from clean Node and Bun entrypoints. |
|
|
417
447
|
| Monorepo release chain | Guarded in CI | Source package manifests must keep internal packages as `workspace:*`; publish rewrites them to concrete versions in a temp tree. | CI runs `check:workspace-deps` before install, and `publish:packages` remains the only npm publish path. |
|
|
@@ -720,6 +750,33 @@ await redisJsLike.hSet("profile:1", "name", "Ada");
|
|
|
720
750
|
`@postgresx/noredis-ioredis` 和 `@postgresx/noredis-redis`。它们仍然是
|
|
721
751
|
`PgredisClient` 之上的外观,不提供即插即用构造器。
|
|
722
752
|
|
|
753
|
+
### L1 失效与原子交换
|
|
754
|
+
|
|
755
|
+
通过 listener factory 让多个进程的本地 L1 缓存保持一致。监听器必须使用
|
|
756
|
+
支持 `LISTEN` 的独立连接,不要复用 transaction pooler 的请求连接。
|
|
757
|
+
|
|
758
|
+
```ts
|
|
759
|
+
import { createPgredis } from "@postgresx/noredis";
|
|
760
|
+
import { createPgNodeListener } from "@postgresx/noredis/adapters/node";
|
|
761
|
+
|
|
762
|
+
const pg = createPgredis({
|
|
763
|
+
sql,
|
|
764
|
+
cache: {
|
|
765
|
+
notify: {
|
|
766
|
+
listener: ({ channels, onNotify }) =>
|
|
767
|
+
createPgNodeListener(directDatabaseUrl, { channels, onNotify })
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
pg.cache.stopInvalidationListener();
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
远端通知会使匹配的 L1 条目失效。监听连接重连时默认清空完整 L1,避免断线期间
|
|
776
|
+
漏掉的通知留下陈旧缓存。`getset()` 在可重试的串行化事务中执行,因此 SQL
|
|
777
|
+
适配器必须提供 `begin()`;内置 Bun 和 Node 适配器均支持。`getdel()` 使用单条
|
|
778
|
+
原子 `DELETE ... RETURNING` 语句。
|
|
779
|
+
|
|
723
780
|
## Pub/Sub
|
|
724
781
|
|
|
725
782
|
发布仅使用配置的 SQL 适配器。Bun LISTEN/NOTIFY 消费使用独立的 `@postgresx/bun-listen` 包,并动态加载。
|
|
@@ -868,7 +925,7 @@ npm install @postgresx/noredis pg-boss
|
|
|
868
925
|
|
|
869
926
|
| 领域 | 状态 | 重要性 | 建议操作 |
|
|
870
927
|
| --- | --- | --- | --- |
|
|
871
|
-
| 真实数据库覆盖 | CI 中已添加 | PostgreSQL DDL、索引、事务、JSONB 行为和 LISTEN/NOTIFY 重连行为需要真实数据库覆盖。 | CI 针对 PostgreSQL
|
|
928
|
+
| 真实数据库覆盖 | CI 中已添加 | PostgreSQL DDL、索引、事务、JSONB 行为和 LISTEN/NOTIFY 重连行为需要真实数据库覆盖。 | CI 针对 PostgreSQL 17 和 18 运行 `bun run test:integration`。调试时使用 `TEST_DATABASE_URL` 本地运行。 |
|
|
872
929
|
| 基准测试基线 | 已生成 | `benchmark.md` 已由 GitHub Actions 生成,并区分主服务级对比和 L1 热读说明。 | benchmark 相关文件变化会自动刷新;本地基准测试运行是可选的。 |
|
|
873
930
|
| 安装冒烟测试 | CI 中已添加 | 构建输出存在,但已发布包的形状应从打包的 tarball 验证,包括子路径导出。 | CI 运行 `bun run smoke:pack` 从干净的 Node 和 Bun 入口点导入打包的 tarball。 |
|
|
874
931
|
| 发布凭证 | 在工作流中保护 | Release Please 和 npm publish 依赖仓库密钥和 npm provenance 设置。 | 当 `RELEASE_PAT` 或 `NPM_TOKEN` 缺失时,工作流会提前失败;首次发布前仍需验证包访问权限。 |
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Q as PgredisClient, _ as PipelineFacade, U as PgredisMigrationAliases } from '../client-DP3ssToT.js';
|
|
2
2
|
import '../kv-cache.js';
|
|
3
|
+
import '../pubsub-index.js';
|
|
3
4
|
import '../sql-DKf2TDlu.js';
|
|
4
5
|
import '../hash-index.js';
|
|
5
6
|
import '../list-index.js';
|
|
6
|
-
import '../pubsub-index.js';
|
|
7
7
|
import '../set-index.js';
|
|
8
8
|
import '../sorted-set-index.js';
|
|
9
9
|
|
package/dist/adapters/redis.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Q as PgredisClient, _ as PipelineFacade, U as PgredisMigrationAliases } from '../client-DP3ssToT.js';
|
|
2
2
|
import '../kv-cache.js';
|
|
3
|
+
import '../pubsub-index.js';
|
|
3
4
|
import '../sql-DKf2TDlu.js';
|
|
4
5
|
import '../hash-index.js';
|
|
5
6
|
import '../list-index.js';
|
|
6
|
-
import '../pubsub-index.js';
|
|
7
7
|
import '../set-index.js';
|
|
8
8
|
import '../sorted-set-index.js';
|
|
9
9
|
|
package/dist/adapters/web.d.ts
CHANGED
|
@@ -49,6 +49,11 @@ function normalizeTtlMs(ttlMs) {
|
|
|
49
49
|
if (!Number.isFinite(ttlMs)) throw new Error(`Invalid ttlMs: ${ttlMs}`);
|
|
50
50
|
return Math.max(0, Math.floor(ttlMs));
|
|
51
51
|
}
|
|
52
|
+
function isSerializationFailure(error) {
|
|
53
|
+
if (!error || typeof error !== "object") return false;
|
|
54
|
+
if ("code" in error && error.code === "40001") return true;
|
|
55
|
+
return "cause" in error && isSerializationFailure(error.cause);
|
|
56
|
+
}
|
|
52
57
|
function escapeLike(value) {
|
|
53
58
|
return value.replace(/[\\%_]/g, (match) => `\\${match}`);
|
|
54
59
|
}
|
|
@@ -75,6 +80,9 @@ var PgKvCache = class {
|
|
|
75
80
|
notifyEnabled;
|
|
76
81
|
serializer;
|
|
77
82
|
l1 = /* @__PURE__ */ new Map();
|
|
83
|
+
l1Generation = 0;
|
|
84
|
+
invalidationListener = null;
|
|
85
|
+
invalidationReconnectUnsubscribe = null;
|
|
78
86
|
constructor(options) {
|
|
79
87
|
this.sql = options.sql;
|
|
80
88
|
this.namespace = options.namespace || DEFAULT_NAMESPACE;
|
|
@@ -91,6 +99,12 @@ var PgKvCache = class {
|
|
|
91
99
|
serialize: (value) => value,
|
|
92
100
|
deserialize: (value) => value
|
|
93
101
|
};
|
|
102
|
+
const listenerFactory = this.resolveNotifyOptions(options.notify)?.listener;
|
|
103
|
+
if (listenerFactory) {
|
|
104
|
+
this.startInvalidationListener(listenerFactory, {
|
|
105
|
+
clearL1OnReconnect: this.resolveNotifyOptions(options.notify)?.clearL1OnReconnect
|
|
106
|
+
});
|
|
107
|
+
}
|
|
94
108
|
}
|
|
95
109
|
async ensureSchema(options = {}) {
|
|
96
110
|
const persistence = options.unlogged === false ? "" : "UNLOGGED ";
|
|
@@ -117,6 +131,7 @@ var PgKvCache = class {
|
|
|
117
131
|
async get(key) {
|
|
118
132
|
const cached = this.getL1(key);
|
|
119
133
|
if (cached.hit) return cached.value;
|
|
134
|
+
const l1Generation = this.l1Generation;
|
|
120
135
|
const rows = await this.sql.unsafe(
|
|
121
136
|
`SELECT value, expires_at
|
|
122
137
|
FROM ${this.quotedTableName}
|
|
@@ -132,7 +147,7 @@ var PgKvCache = class {
|
|
|
132
147
|
return null;
|
|
133
148
|
}
|
|
134
149
|
const value = this.deserialize(row.value);
|
|
135
|
-
this.setL1(key, value, rowExpiresAt(row));
|
|
150
|
+
this.setL1(key, value, rowExpiresAt(row), l1Generation);
|
|
136
151
|
return value;
|
|
137
152
|
}
|
|
138
153
|
async mget(keys) {
|
|
@@ -147,6 +162,7 @@ var PgKvCache = class {
|
|
|
147
162
|
}
|
|
148
163
|
}
|
|
149
164
|
if (missing.length === 0) return result;
|
|
165
|
+
const l1Generation = this.l1Generation;
|
|
150
166
|
const placeholders = missing.map((_, index) => `$${index + 2}`).join(", ");
|
|
151
167
|
const rows = await this.sql.unsafe(
|
|
152
168
|
`SELECT key, value, expires_at
|
|
@@ -160,7 +176,7 @@ var PgKvCache = class {
|
|
|
160
176
|
if (!row.key) continue;
|
|
161
177
|
const value = this.deserialize(row.value);
|
|
162
178
|
result.set(row.key, value);
|
|
163
|
-
this.setL1(row.key, value, rowExpiresAt(row));
|
|
179
|
+
this.setL1(row.key, value, rowExpiresAt(row), l1Generation);
|
|
164
180
|
}
|
|
165
181
|
for (const key of missing) {
|
|
166
182
|
if (!result.has(key)) this.deleteL1(key);
|
|
@@ -261,7 +277,7 @@ var PgKvCache = class {
|
|
|
261
277
|
RETURNING key`,
|
|
262
278
|
[this.namespace]
|
|
263
279
|
);
|
|
264
|
-
this.
|
|
280
|
+
this.invalidateAll();
|
|
265
281
|
if (options.notify !== false) await this.publish({ op: "clearNamespace" });
|
|
266
282
|
return rows.length;
|
|
267
283
|
}
|
|
@@ -396,6 +412,31 @@ var PgKvCache = class {
|
|
|
396
412
|
invalidate(key) {
|
|
397
413
|
this.deleteL1(key);
|
|
398
414
|
}
|
|
415
|
+
invalidateAll() {
|
|
416
|
+
this.l1Generation += 1;
|
|
417
|
+
this.l1.clear();
|
|
418
|
+
}
|
|
419
|
+
startInvalidationListener(factory, options = {}) {
|
|
420
|
+
this.stopInvalidationListener();
|
|
421
|
+
const listener = factory({
|
|
422
|
+
channels: [this.notifyChannel],
|
|
423
|
+
onNotify: (channel, payload) => {
|
|
424
|
+
if (channel === this.notifyChannel) this.handleNotification(payload);
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
const reconnectUnsubscribe = options.clearL1OnReconnect === false ? null : listener.on("reconnect", () => this.invalidateAll());
|
|
428
|
+
this.invalidationListener = listener;
|
|
429
|
+
this.invalidationReconnectUnsubscribe = reconnectUnsubscribe;
|
|
430
|
+
return listener;
|
|
431
|
+
}
|
|
432
|
+
stopInvalidationListener() {
|
|
433
|
+
const listener = this.invalidationListener;
|
|
434
|
+
const reconnectUnsubscribe = this.invalidationReconnectUnsubscribe;
|
|
435
|
+
this.invalidationListener = null;
|
|
436
|
+
this.invalidationReconnectUnsubscribe = null;
|
|
437
|
+
reconnectUnsubscribe?.();
|
|
438
|
+
listener?.close();
|
|
439
|
+
}
|
|
399
440
|
handleNotification(payload) {
|
|
400
441
|
const event = typeof payload === "string" ? this.parseNotification(payload) : payload;
|
|
401
442
|
if (!event || event.namespace !== this.namespace || event.senderId === this.instanceId) return false;
|
|
@@ -405,13 +446,14 @@ var PgKvCache = class {
|
|
|
405
446
|
}
|
|
406
447
|
if (event.op === "clearPrefix") {
|
|
407
448
|
if (!event.prefix) return false;
|
|
449
|
+
this.l1Generation += 1;
|
|
408
450
|
for (const key of this.l1.keys()) {
|
|
409
451
|
if (key.startsWith(event.prefix)) this.l1.delete(key);
|
|
410
452
|
}
|
|
411
453
|
return true;
|
|
412
454
|
}
|
|
413
455
|
if (event.op === "clearNamespace") {
|
|
414
|
-
this.
|
|
456
|
+
this.invalidateAll();
|
|
415
457
|
return true;
|
|
416
458
|
}
|
|
417
459
|
return false;
|
|
@@ -502,14 +544,50 @@ var PgKvCache = class {
|
|
|
502
544
|
return written ? 1 : 0;
|
|
503
545
|
}
|
|
504
546
|
async getset(key, value) {
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
547
|
+
const serialized = jsonValue(this.serializer.serialize(value));
|
|
548
|
+
const l1Generation = this.l1Generation;
|
|
549
|
+
const oldValue = await this.runSerializable(async (tx) => {
|
|
550
|
+
const rows = await tx.unsafe(
|
|
551
|
+
`SELECT value, expires_at
|
|
552
|
+
FROM ${this.quotedTableName}
|
|
553
|
+
WHERE namespace = $1
|
|
554
|
+
AND key = $2
|
|
555
|
+
AND (expires_at IS NULL OR expires_at > NOW())
|
|
556
|
+
FOR UPDATE`,
|
|
557
|
+
[this.namespace, key]
|
|
558
|
+
);
|
|
559
|
+
await tx.unsafe(
|
|
560
|
+
`INSERT INTO ${this.quotedTableName} (namespace, key, value, expires_at, updated_at)
|
|
561
|
+
VALUES ($1, $2, $3::jsonb, NULL, NOW())
|
|
562
|
+
ON CONFLICT (namespace, key) DO UPDATE
|
|
563
|
+
SET value = EXCLUDED.value,
|
|
564
|
+
expires_at = NULL,
|
|
565
|
+
updated_at = NOW()`,
|
|
566
|
+
[this.namespace, key, serialized]
|
|
567
|
+
);
|
|
568
|
+
return rows[0] ? this.deserialize(rows[0].value) : null;
|
|
569
|
+
});
|
|
570
|
+
this.setL1(key, value, null, l1Generation);
|
|
571
|
+
await this.publish({ op: "set", key });
|
|
572
|
+
return oldValue;
|
|
508
573
|
}
|
|
509
574
|
async getdel(key) {
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
575
|
+
const rows = await this.sql.unsafe(
|
|
576
|
+
`WITH deleted AS (
|
|
577
|
+
DELETE FROM ${this.quotedTableName}
|
|
578
|
+
WHERE namespace = $1 AND key = $2
|
|
579
|
+
RETURNING value, expires_at
|
|
580
|
+
)
|
|
581
|
+
SELECT value,
|
|
582
|
+
(expires_at IS NULL OR expires_at > NOW()) AS is_live
|
|
583
|
+
FROM deleted`,
|
|
584
|
+
[this.namespace, key]
|
|
585
|
+
);
|
|
586
|
+
const row = rows[0];
|
|
587
|
+
this.deleteL1(key);
|
|
588
|
+
if (!row) return null;
|
|
589
|
+
await this.publish({ op: "delete", key });
|
|
590
|
+
return row.is_live ? this.deserialize(row.value) : null;
|
|
513
591
|
}
|
|
514
592
|
stats() {
|
|
515
593
|
this.cleanupL1();
|
|
@@ -529,6 +607,23 @@ var PgKvCache = class {
|
|
|
529
607
|
};
|
|
530
608
|
await this.sql.unsafe("SELECT pg_notify($1, $2)", [this.notifyChannel, JSON.stringify(payload)]);
|
|
531
609
|
}
|
|
610
|
+
async runSerializable(operation) {
|
|
611
|
+
const begin = this.sql.begin?.bind(this.sql);
|
|
612
|
+
if (!begin) {
|
|
613
|
+
throw new Error("PgKvCache.getset requires a transaction-capable sql adapter");
|
|
614
|
+
}
|
|
615
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
616
|
+
try {
|
|
617
|
+
return await begin(async (tx) => {
|
|
618
|
+
await tx.unsafe("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
|
|
619
|
+
return operation(tx);
|
|
620
|
+
});
|
|
621
|
+
} catch (error) {
|
|
622
|
+
if (!isSerializationFailure(error) || attempt === 2) throw error;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
throw new Error("PgKvCache serializable transaction retry exhausted");
|
|
626
|
+
}
|
|
532
627
|
deserialize(value) {
|
|
533
628
|
return this.serializer.deserialize(parseValue(value));
|
|
534
629
|
}
|
|
@@ -538,6 +633,9 @@ var PgKvCache = class {
|
|
|
538
633
|
if (options.xx) return "xx";
|
|
539
634
|
return options.mode ?? "always";
|
|
540
635
|
}
|
|
636
|
+
resolveNotifyOptions(options) {
|
|
637
|
+
return options === false ? void 0 : options;
|
|
638
|
+
}
|
|
541
639
|
parseNotification(payload) {
|
|
542
640
|
try {
|
|
543
641
|
const value = JSON.parse(payload);
|
|
@@ -559,8 +657,9 @@ var PgKvCache = class {
|
|
|
559
657
|
this.l1.set(key, entry);
|
|
560
658
|
return { hit: true, value: entry.value };
|
|
561
659
|
}
|
|
562
|
-
setL1(key, value, l2ExpiresAt) {
|
|
660
|
+
setL1(key, value, l2ExpiresAt, generation = this.l1Generation) {
|
|
563
661
|
if (!this.l1Enabled || this.l1Max <= 0) return;
|
|
662
|
+
if (generation !== this.l1Generation) return;
|
|
564
663
|
const l1ExpiresAt = this.computeL1ExpiresAt(l2ExpiresAt);
|
|
565
664
|
if (l1ExpiresAt !== null && l1ExpiresAt <= this.now()) {
|
|
566
665
|
this.l1.delete(key);
|
|
@@ -578,6 +677,7 @@ var PgKvCache = class {
|
|
|
578
677
|
}
|
|
579
678
|
deleteL1(key) {
|
|
580
679
|
if (!this.l1Enabled) return;
|
|
680
|
+
this.l1Generation += 1;
|
|
581
681
|
this.l1.delete(key);
|
|
582
682
|
}
|
|
583
683
|
cleanupL1() {
|
|
@@ -179,6 +179,14 @@ interface PgRateLimitHitOptions {
|
|
|
179
179
|
windowMs?: number;
|
|
180
180
|
cost?: number;
|
|
181
181
|
}
|
|
182
|
+
interface PgRateLimitStateOptions {
|
|
183
|
+
limit?: number;
|
|
184
|
+
windowMs?: number;
|
|
185
|
+
}
|
|
186
|
+
interface PgRateLimitBlockOptions extends PgRateLimitStateOptions {
|
|
187
|
+
blockMs: number;
|
|
188
|
+
count?: number;
|
|
189
|
+
}
|
|
182
190
|
interface PgRateLimitSchemaOptions {
|
|
183
191
|
unlogged?: boolean;
|
|
184
192
|
}
|
|
@@ -226,7 +234,14 @@ declare class PgFixedWindowRateLimiter {
|
|
|
226
234
|
constructor(options: PgRateLimiterOptions);
|
|
227
235
|
ensureSchema(options?: PgRateLimitSchemaOptions): Promise<void>;
|
|
228
236
|
hit(key: string, options?: PgRateLimitHitOptions): Promise<PgRateLimitResult>;
|
|
237
|
+
get(key: string, options?: PgRateLimitStateOptions): Promise<PgRateLimitResult | null>;
|
|
238
|
+
reward(key: string, cost?: number, options?: PgRateLimitStateOptions): Promise<PgRateLimitResult | null>;
|
|
239
|
+
private decrementWindow;
|
|
240
|
+
block(key: string, options: PgRateLimitBlockOptions): Promise<PgRateLimitResult>;
|
|
241
|
+
delete(key: string): Promise<boolean>;
|
|
229
242
|
cleanupExpired(limit?: number): Promise<number>;
|
|
243
|
+
private resultFromRow;
|
|
244
|
+
private getActiveBlock;
|
|
230
245
|
}
|
|
231
246
|
declare function createPgFixedWindowRateLimiter(options: PgRateLimiterOptions): PgFixedWindowRateLimiter;
|
|
232
247
|
declare class PgSlidingWindowRateLimiter {
|
|
@@ -491,4 +506,4 @@ interface PgredisClient {
|
|
|
491
506
|
}
|
|
492
507
|
declare function createPgredis(options: PgredisOptions): PgredisClient;
|
|
493
508
|
|
|
494
|
-
export {
|
|
509
|
+
export { type RedisSetAliasOptions as $, type PgOutboxStreamSchemaOptions as A, type PgOutboxTrimOptions as B, type PgRateLimitBlockOptions as C, type PgRateLimitHitOptions as D, type PgRateLimitResult as E, type PgRateLimitSchemaOptions as F, type PgRateLimitStateOptions as G, type PgRateLimiterOptions as H, PgSlidingWindowRateLimiter as I, type PgSlidingWindowRateLimiterOptions as J, PgTokenBucketRateLimiter as K, type PgTokenBucketRateLimiterOptions as L, type PgTokenBucketResult as M, type PgredisBatchOperation as N, type PgredisCleanupMetrics as O, PgAdvisoryLockBusyError as P, type PgredisClient as Q, type PgredisListenerMetrics as R, type PgredisMetrics as S, type PgredisMetricsOptions as T, type PgredisMigrationAliases as U, type PgredisOptions as V, PgredisPipeline as W, type PgredisQueueMetrics as X, type PgredisTableMetrics as Y, type PipelineCommand as Z, type PipelineFacade as _, type PgAdvisoryLockKey as a, advisoryLockKeyToSqlArgs as a0, collectPgredisMetrics as a1, createPgAdvisoryLocker as a2, createPgBossJobQueue as a3, createPgCounter as a4, createPgFixedWindowRateLimiter as a5, createPgOutboxStream as a6, createPgSlidingWindowRateLimiter as a7, createPgTokenBucketRateLimiter as a8, createPgredis as a9, createPgredisMigrationAliases as aa, withPgAdvisoryLock as ab, type PgAdvisoryLockOptions as b, PgAdvisoryLocker as c, type PgBossJob as d, PgBossJobQueue as e, type PgBossLike as f, type PgBossOptions as g, type PgBossQueueDefinition as h, type PgBossQueueMap as i, type PgBossQueueOptions as j, type PgBossQueueResult as k, type PgBossSendOptions as l, type PgBossWorkHandler as m, type PgBossWorkOptions as n, PgCounter as o, type PgCounterOptions as p, type PgCounterSchemaOptions as q, type PgCounterSetOptions as r, PgFixedWindowRateLimiter as s, type PgOutboxAppendOptions as t, type PgOutboxClaimOptions as u, type PgOutboxMessage as v, type PgOutboxPendingSummary as w, type PgOutboxReadOptions as x, PgOutboxStream as y, type PgOutboxStreamOptions as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { BunSqlLike, PgKvCache, PgKvCacheL1Options, PgKvCacheNotifyOptions, PgKvCacheOptions, PgKvCacheStats, PgKvNotification, PgKvSchemaOptions, PgKvSetOptions, createPgKvCache } from './kv-cache.js';
|
|
2
|
-
export { d as Job, P as PgAdvisoryLockBusyError, a as PgAdvisoryLockKey, b as PgAdvisoryLockOptions, c as PgAdvisoryLocker, f as PgBoss, d as PgBossJob, e as PgBossJobQueue, f as PgBossLike, g as PgBossOptions, h as PgBossQueueDefinition, i as PgBossQueueMap, j as PgBossQueueOptions, k as PgBossQueueResult, l as PgBossSendOptions, m as PgBossWorkHandler, n as PgBossWorkOptions, o as PgCounter, p as PgCounterOptions, q as PgCounterSchemaOptions, r as PgCounterSetOptions, s as PgFixedWindowRateLimiter, t as PgOutboxAppendOptions, u as PgOutboxClaimOptions, v as PgOutboxMessage, w as PgOutboxPendingSummary, x as PgOutboxReadOptions, y as PgOutboxStream, z as PgOutboxStreamOptions, A as PgOutboxStreamSchemaOptions, B as PgOutboxTrimOptions, C as
|
|
1
|
+
export { BunSqlLike, PgKvCache, PgKvCacheInvalidationOptions, PgKvCacheL1Options, PgKvCacheListenerFactory, PgKvCacheListenerFactoryOptions, PgKvCacheNotifyOptions, PgKvCacheOptions, PgKvCacheStats, PgKvNotification, PgKvSchemaOptions, PgKvSetOptions, createPgKvCache } from './kv-cache.js';
|
|
2
|
+
export { d as Job, P as PgAdvisoryLockBusyError, a as PgAdvisoryLockKey, b as PgAdvisoryLockOptions, c as PgAdvisoryLocker, f as PgBoss, d as PgBossJob, e as PgBossJobQueue, f as PgBossLike, g as PgBossOptions, h as PgBossQueueDefinition, i as PgBossQueueMap, j as PgBossQueueOptions, k as PgBossQueueResult, l as PgBossSendOptions, m as PgBossWorkHandler, n as PgBossWorkOptions, o as PgCounter, p as PgCounterOptions, q as PgCounterSchemaOptions, r as PgCounterSetOptions, s as PgFixedWindowRateLimiter, t as PgOutboxAppendOptions, u as PgOutboxClaimOptions, v as PgOutboxMessage, w as PgOutboxPendingSummary, x as PgOutboxReadOptions, y as PgOutboxStream, z as PgOutboxStreamOptions, A as PgOutboxStreamSchemaOptions, B as PgOutboxTrimOptions, C as PgRateLimitBlockOptions, D as PgRateLimitHitOptions, E as PgRateLimitResult, F as PgRateLimitSchemaOptions, G as PgRateLimitStateOptions, H as PgRateLimiterOptions, I as PgSlidingWindowRateLimiter, J as PgSlidingWindowRateLimiterOptions, K as PgTokenBucketRateLimiter, L as PgTokenBucketRateLimiterOptions, M as PgTokenBucketResult, N as PgredisBatchOperation, O as PgredisCleanupMetrics, Q as PgredisClient, R as PgredisListenerMetrics, S as PgredisMetrics, T as PgredisMetricsOptions, U as PgredisMigrationAliases, V as PgredisOptions, W as PgredisPipeline, X as PgredisQueueMetrics, Y as PgredisTableMetrics, Z as PipelineCommand, _ as PipelineFacade, h as Queue, k as QueueResult, $ as RedisSetAliasOptions, l as SendOptions, m as WorkHandler, n as WorkOptions, a0 as advisoryLockKeyToSqlArgs, a1 as collectPgredisMetrics, a2 as createPgAdvisoryLocker, a3 as createPgBossJobQueue, a4 as createPgCounter, a5 as createPgFixedWindowRateLimiter, a6 as createPgOutboxStream, a7 as createPgSlidingWindowRateLimiter, a8 as createPgTokenBucketRateLimiter, a9 as createPgredis, aa as createPgredisMigrationAliases, ab as withPgAdvisoryLock } from './client-DP3ssToT.js';
|
|
3
3
|
export { PgHash, PgHashOptions, PgHashScanResult, PgHashSchemaOptions, createPgHash } from './hash-index.js';
|
|
4
4
|
export { PgList, PgListBlockingPopOptions, PgListBlockingPopResult, PgListOptions, PgListScanResult, PgListSchemaOptions, createPgList } from './list-index.js';
|
|
5
5
|
export { NotifyHandler, PgListenerEvents, PgListenerHandle, PgListenerHealth, PgListenerOptions, PgNotifyPayload, PgPublisher, createBunPgListener, createPgListener, createPgPublisher, publishPgNotify } from './pubsub-index.js';
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
PgKvCache,
|
|
11
11
|
createPgKvCache
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BD36RDOX.js";
|
|
13
13
|
import {
|
|
14
14
|
PgList,
|
|
15
15
|
createPgList
|
|
@@ -414,6 +414,20 @@ var DEFAULT_TABLE_NAME2 = "pg_rate_limit";
|
|
|
414
414
|
var DEFAULT_NAMESPACE2 = "default";
|
|
415
415
|
var DEFAULT_SLIDING_TABLE_NAME = "pg_sliding_rate_limit";
|
|
416
416
|
var DEFAULT_TOKEN_BUCKET_TABLE_NAME = "pg_token_bucket_rate_limit";
|
|
417
|
+
var BLOCK_WINDOW_START = -1;
|
|
418
|
+
function normalizeLimit(value, name) {
|
|
419
|
+
if (!Number.isFinite(value) || value < 0) throw new Error(`Invalid ${name}: ${value}`);
|
|
420
|
+
return Math.floor(value);
|
|
421
|
+
}
|
|
422
|
+
function dateMs(value, fallback) {
|
|
423
|
+
if (value instanceof Date) return value.getTime();
|
|
424
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
425
|
+
if (typeof value === "string") {
|
|
426
|
+
const parsed = Date.parse(value);
|
|
427
|
+
if (!Number.isNaN(parsed)) return parsed;
|
|
428
|
+
}
|
|
429
|
+
return fallback;
|
|
430
|
+
}
|
|
417
431
|
var PgFixedWindowRateLimiter = class {
|
|
418
432
|
namespace;
|
|
419
433
|
tableName;
|
|
@@ -456,6 +470,8 @@ var PgFixedWindowRateLimiter = class {
|
|
|
456
470
|
const now = this.now();
|
|
457
471
|
const windowStart = Math.floor(now / windowMs) * windowMs;
|
|
458
472
|
const resetAtMs = windowStart + windowMs;
|
|
473
|
+
const blocked = await this.getActiveBlock(key, limit, now, resetAtMs);
|
|
474
|
+
if (blocked) return blocked;
|
|
459
475
|
const rows = await this.sql.unsafe(
|
|
460
476
|
`INSERT INTO ${this.quotedTableName} (namespace, key, window_start, count, expires_at, updated_at)
|
|
461
477
|
VALUES (
|
|
@@ -485,6 +501,90 @@ var PgFixedWindowRateLimiter = class {
|
|
|
485
501
|
retryAfterMs
|
|
486
502
|
};
|
|
487
503
|
}
|
|
504
|
+
async get(key, options = {}) {
|
|
505
|
+
const limit = normalizeLimit(options.limit ?? this.limit, "limit");
|
|
506
|
+
const windowMs = normalizePositiveInteger(options.windowMs ?? this.windowMs, "windowMs");
|
|
507
|
+
const now = this.now();
|
|
508
|
+
const windowStart = Math.floor(now / windowMs) * windowMs;
|
|
509
|
+
const resetAtMs = windowStart + windowMs;
|
|
510
|
+
const blocked = await this.getActiveBlock(key, limit, now, resetAtMs);
|
|
511
|
+
if (blocked) return blocked;
|
|
512
|
+
const rows = await this.sql.unsafe(
|
|
513
|
+
`SELECT count, expires_at
|
|
514
|
+
FROM ${this.quotedTableName}
|
|
515
|
+
WHERE namespace = $1
|
|
516
|
+
AND key = $2
|
|
517
|
+
AND window_start = $3
|
|
518
|
+
AND expires_at > NOW()
|
|
519
|
+
LIMIT 1`,
|
|
520
|
+
[this.namespace, key, windowStart]
|
|
521
|
+
);
|
|
522
|
+
const row = rows[0];
|
|
523
|
+
if (!row) return null;
|
|
524
|
+
return this.resultFromRow(row, limit, now, resetAtMs);
|
|
525
|
+
}
|
|
526
|
+
async reward(key, cost = 1, options = {}) {
|
|
527
|
+
const limit = normalizeLimit(options.limit ?? this.limit, "limit");
|
|
528
|
+
const windowMs = normalizePositiveInteger(options.windowMs ?? this.windowMs, "windowMs");
|
|
529
|
+
const normalizedCost = normalizePositiveInteger(cost, "cost");
|
|
530
|
+
const now = this.now();
|
|
531
|
+
const windowStart = Math.floor(now / windowMs) * windowMs;
|
|
532
|
+
const resetAtMs = windowStart + windowMs;
|
|
533
|
+
const blockRows = await this.decrementWindow(key, BLOCK_WINDOW_START, normalizedCost);
|
|
534
|
+
const blockRow = blockRows[0];
|
|
535
|
+
if (blockRow) return this.resultFromRow(blockRow, limit, now, resetAtMs);
|
|
536
|
+
const rows = await this.decrementWindow(key, windowStart, normalizedCost);
|
|
537
|
+
const row = rows[0];
|
|
538
|
+
if (!row) return null;
|
|
539
|
+
return this.resultFromRow(row, limit, now, resetAtMs);
|
|
540
|
+
}
|
|
541
|
+
async decrementWindow(key, windowStart, cost) {
|
|
542
|
+
return await this.sql.unsafe(
|
|
543
|
+
`UPDATE ${this.quotedTableName}
|
|
544
|
+
SET count = GREATEST(count - $4, 0),
|
|
545
|
+
updated_at = NOW()
|
|
546
|
+
WHERE namespace = $1
|
|
547
|
+
AND key = $2
|
|
548
|
+
AND window_start = $3
|
|
549
|
+
AND expires_at > NOW()
|
|
550
|
+
RETURNING count, expires_at`,
|
|
551
|
+
[this.namespace, key, windowStart, cost]
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
async block(key, options) {
|
|
555
|
+
const limit = normalizeLimit(options.limit ?? this.limit, "limit");
|
|
556
|
+
const blockMs = normalizePositiveInteger(options.blockMs, "blockMs");
|
|
557
|
+
const count = normalizePositiveInteger(options.count ?? Math.max(limit + 1, 1), "count");
|
|
558
|
+
const now = this.now();
|
|
559
|
+
const resetAtMs = now + blockMs;
|
|
560
|
+
const rows = await this.sql.unsafe(
|
|
561
|
+
`INSERT INTO ${this.quotedTableName} (namespace, key, window_start, count, expires_at, updated_at)
|
|
562
|
+
VALUES (
|
|
563
|
+
$1,
|
|
564
|
+
$2,
|
|
565
|
+
$3,
|
|
566
|
+
$4,
|
|
567
|
+
NOW() + ($5::bigint * INTERVAL '1 millisecond'),
|
|
568
|
+
NOW()
|
|
569
|
+
)
|
|
570
|
+
ON CONFLICT (namespace, key, window_start) DO UPDATE
|
|
571
|
+
SET count = GREATEST(${this.quotedTableName}.count, EXCLUDED.count),
|
|
572
|
+
expires_at = GREATEST(${this.quotedTableName}.expires_at, EXCLUDED.expires_at),
|
|
573
|
+
updated_at = NOW()
|
|
574
|
+
RETURNING count, expires_at`,
|
|
575
|
+
[this.namespace, key, BLOCK_WINDOW_START, count, blockMs]
|
|
576
|
+
);
|
|
577
|
+
return this.resultFromRow(rows[0] ?? { count }, limit, now, resetAtMs);
|
|
578
|
+
}
|
|
579
|
+
async delete(key) {
|
|
580
|
+
const rows = await this.sql.unsafe(
|
|
581
|
+
`DELETE FROM ${this.quotedTableName}
|
|
582
|
+
WHERE namespace = $1 AND key = $2
|
|
583
|
+
RETURNING key`,
|
|
584
|
+
[this.namespace, key]
|
|
585
|
+
);
|
|
586
|
+
return rows.length > 0;
|
|
587
|
+
}
|
|
488
588
|
async cleanupExpired(limit = 1e3) {
|
|
489
589
|
const rows = await this.sql.unsafe(
|
|
490
590
|
`DELETE FROM ${this.quotedTableName}
|
|
@@ -499,6 +599,34 @@ var PgFixedWindowRateLimiter = class {
|
|
|
499
599
|
);
|
|
500
600
|
return rows.length;
|
|
501
601
|
}
|
|
602
|
+
resultFromRow(row, limit, now, fallbackResetAtMs) {
|
|
603
|
+
const count = Number(row.count);
|
|
604
|
+
const resetAtMs = dateMs(row.expires_at, fallbackResetAtMs);
|
|
605
|
+
const allowed = count <= limit;
|
|
606
|
+
return {
|
|
607
|
+
allowed,
|
|
608
|
+
limit,
|
|
609
|
+
count,
|
|
610
|
+
remaining: Math.max(0, limit - count),
|
|
611
|
+
resetAt: new Date(resetAtMs),
|
|
612
|
+
retryAfterMs: allowed ? 0 : Math.max(0, resetAtMs - now)
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
async getActiveBlock(key, limit, now, fallbackResetAtMs) {
|
|
616
|
+
const rows = await this.sql.unsafe(
|
|
617
|
+
`SELECT count, expires_at
|
|
618
|
+
FROM ${this.quotedTableName}
|
|
619
|
+
WHERE namespace = $1
|
|
620
|
+
AND key = $2
|
|
621
|
+
AND window_start = $3
|
|
622
|
+
AND expires_at > NOW()
|
|
623
|
+
LIMIT 1`,
|
|
624
|
+
[this.namespace, key, BLOCK_WINDOW_START]
|
|
625
|
+
);
|
|
626
|
+
const row = rows[0];
|
|
627
|
+
if (!row || Number(row.count) <= limit) return null;
|
|
628
|
+
return this.resultFromRow(row, limit, now, fallbackResetAtMs);
|
|
629
|
+
}
|
|
502
630
|
};
|
|
503
631
|
function createPgFixedWindowRateLimiter(options) {
|
|
504
632
|
return new PgFixedWindowRateLimiter(options);
|
|
@@ -709,7 +837,7 @@ function toDate2(value) {
|
|
|
709
837
|
if (value === null) return null;
|
|
710
838
|
return value instanceof Date ? value : new Date(value);
|
|
711
839
|
}
|
|
712
|
-
function
|
|
840
|
+
function normalizeLimit2(limit, fallback) {
|
|
713
841
|
if (limit === void 0) return fallback;
|
|
714
842
|
if (!Number.isFinite(limit)) throw new Error(`Invalid limit: ${limit}`);
|
|
715
843
|
return Math.max(1, Math.floor(limit));
|
|
@@ -779,7 +907,7 @@ var PgOutboxStream = class {
|
|
|
779
907
|
this.namespace,
|
|
780
908
|
stream,
|
|
781
909
|
options.afterId ?? 0,
|
|
782
|
-
|
|
910
|
+
normalizeLimit2(options.limit, 100),
|
|
783
911
|
options.includeProcessed ?? false
|
|
784
912
|
]
|
|
785
913
|
);
|
|
@@ -809,7 +937,7 @@ var PgOutboxStream = class {
|
|
|
809
937
|
WHERE target.id = picked.id
|
|
810
938
|
RETURNING target.id, target.stream, target.payload, target.consumer, target.delivery_count,
|
|
811
939
|
target.available_at, target.locked_until, target.processed_at, target.created_at`,
|
|
812
|
-
[this.namespace, stream, consumer,
|
|
940
|
+
[this.namespace, stream, consumer, normalizeLimit2(options.limit, 1), visibilityTimeoutMs]
|
|
813
941
|
);
|
|
814
942
|
return rows.map((row) => this.mapMessage(row));
|
|
815
943
|
}
|
|
@@ -863,7 +991,7 @@ var PgOutboxStream = class {
|
|
|
863
991
|
options.stream ?? null,
|
|
864
992
|
options.beforeId ?? null,
|
|
865
993
|
options.maxAgeMs ?? null,
|
|
866
|
-
|
|
994
|
+
normalizeLimit2(options.limit, 1e3)
|
|
867
995
|
]
|
|
868
996
|
);
|
|
869
997
|
return rows.length;
|
package/dist/kv-cache.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { NotifyHandler, PgListenerHandle } from './pubsub-index.js';
|
|
2
|
+
import './sql-DKf2TDlu.js';
|
|
3
|
+
|
|
1
4
|
interface BunSqlLike {
|
|
2
5
|
unsafe<T = Record<string, unknown>>(query: string, params?: readonly unknown[]): Promise<T[]>;
|
|
6
|
+
begin?<T>(callback: (tx: BunSqlLike) => Promise<T>): Promise<T>;
|
|
3
7
|
}
|
|
4
8
|
interface PgKvCacheL1Options {
|
|
5
9
|
max?: number;
|
|
@@ -8,6 +12,16 @@ interface PgKvCacheL1Options {
|
|
|
8
12
|
interface PgKvCacheNotifyOptions {
|
|
9
13
|
channel?: string;
|
|
10
14
|
enabled?: boolean;
|
|
15
|
+
listener?: PgKvCacheListenerFactory;
|
|
16
|
+
clearL1OnReconnect?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface PgKvCacheListenerFactoryOptions {
|
|
19
|
+
channels: string[];
|
|
20
|
+
onNotify: NotifyHandler;
|
|
21
|
+
}
|
|
22
|
+
type PgKvCacheListenerFactory = (options: PgKvCacheListenerFactoryOptions) => PgListenerHandle;
|
|
23
|
+
interface PgKvCacheInvalidationOptions {
|
|
24
|
+
clearL1OnReconnect?: boolean;
|
|
11
25
|
}
|
|
12
26
|
interface PgKvCacheOptions {
|
|
13
27
|
sql: BunSqlLike;
|
|
@@ -63,6 +77,9 @@ declare class PgKvCache {
|
|
|
63
77
|
private readonly notifyEnabled;
|
|
64
78
|
private readonly serializer;
|
|
65
79
|
private readonly l1;
|
|
80
|
+
private l1Generation;
|
|
81
|
+
private invalidationListener;
|
|
82
|
+
private invalidationReconnectUnsubscribe;
|
|
66
83
|
constructor(options: PgKvCacheOptions);
|
|
67
84
|
ensureSchema(options?: PgKvSchemaOptions): Promise<void>;
|
|
68
85
|
get<T = unknown>(key: string): Promise<T | null>;
|
|
@@ -89,6 +106,9 @@ declare class PgKvCache {
|
|
|
89
106
|
touch(key: string): Promise<boolean>;
|
|
90
107
|
ttl(key: string): Promise<number | null>;
|
|
91
108
|
invalidate(key: string): void;
|
|
109
|
+
invalidateAll(): void;
|
|
110
|
+
startInvalidationListener(factory: PgKvCacheListenerFactory, options?: PgKvCacheInvalidationOptions): PgListenerHandle;
|
|
111
|
+
stopInvalidationListener(): void;
|
|
92
112
|
handleNotification(payload: string | PgKvNotification): boolean;
|
|
93
113
|
keys(pattern?: string, limit?: number): Promise<string[]>;
|
|
94
114
|
scan(cursor?: string | null, count?: number, pattern?: string): Promise<{
|
|
@@ -105,8 +125,10 @@ declare class PgKvCache {
|
|
|
105
125
|
getdel<T = unknown>(key: string): Promise<T | null>;
|
|
106
126
|
stats(): PgKvCacheStats;
|
|
107
127
|
private publish;
|
|
128
|
+
private runSerializable;
|
|
108
129
|
private deserialize;
|
|
109
130
|
private resolveSetMode;
|
|
131
|
+
private resolveNotifyOptions;
|
|
110
132
|
private parseNotification;
|
|
111
133
|
private getL1;
|
|
112
134
|
private setL1;
|
|
@@ -117,4 +139,4 @@ declare class PgKvCache {
|
|
|
117
139
|
}
|
|
118
140
|
declare function createPgKvCache(options: PgKvCacheOptions): PgKvCache;
|
|
119
141
|
|
|
120
|
-
export { type BunSqlLike, PgKvCache, type PgKvCacheL1Options, type PgKvCacheNotifyOptions, type PgKvCacheOptions, type PgKvCacheStats, type PgKvCompareAndSwapOptions, type PgKvNotification, type PgKvSchemaOptions, type PgKvSerializer, type PgKvSetOptions, createPgKvCache };
|
|
142
|
+
export { type BunSqlLike, PgKvCache, type PgKvCacheInvalidationOptions, type PgKvCacheL1Options, type PgKvCacheListenerFactory, type PgKvCacheListenerFactoryOptions, type PgKvCacheNotifyOptions, type PgKvCacheOptions, type PgKvCacheStats, type PgKvCompareAndSwapOptions, type PgKvNotification, type PgKvSchemaOptions, type PgKvSerializer, type PgKvSetOptions, createPgKvCache };
|
package/dist/kv-cache.js
CHANGED
package/dist/kv.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { BunSqlLike, PgKvCache, PgKvCacheL1Options, PgKvCacheNotifyOptions, PgKvCacheOptions, PgKvCacheStats, PgKvNotification, PgKvSchemaOptions, PgKvSerializer, PgKvSetOptions, createPgKvCache } from './kv-cache.js';
|
|
1
|
+
export { BunSqlLike, PgKvCache, PgKvCacheInvalidationOptions, PgKvCacheL1Options, PgKvCacheListenerFactory, PgKvCacheListenerFactoryOptions, PgKvCacheNotifyOptions, PgKvCacheOptions, PgKvCacheStats, PgKvNotification, PgKvSchemaOptions, PgKvSerializer, PgKvSetOptions, createPgKvCache } from './kv-cache.js';
|
|
2
|
+
import './pubsub-index.js';
|
|
3
|
+
import './sql-DKf2TDlu.js';
|
package/dist/kv.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postgresx/noredis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "PostgreSQL-backed Redis feature replacement toolkit: KV/TTL cache, pub/sub, advisory locks, rate limiting, and pg-boss queues",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@types/bun": "^1.3.14",
|
|
93
93
|
"@types/node": "^25.0.0",
|
|
94
94
|
"@types/pg": "^8.16.0",
|
|
95
|
-
"@postgresx/bun-listen": "^0.3.
|
|
95
|
+
"@postgresx/bun-listen": "^0.3.1",
|
|
96
96
|
"tsup": "^8.5.0",
|
|
97
97
|
"typescript": "^6.0.3"
|
|
98
98
|
}
|