node-karin 1.11.2 → 1.11.3
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/CHANGELOG.md +7 -0
- package/dist/index.mjs +43 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [1.11.3](https://github.com/KarinJS/Karin/compare/core-v1.11.2...core-v1.11.3) (2025-10-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### 🐛 Bug Fixes
|
|
7
|
+
|
|
8
|
+
* correct Redis mock SET method options handling and type checking ([#546](https://github.com/KarinJS/Karin/issues/546)) ([fb6a999](https://github.com/KarinJS/Karin/commit/fb6a99957974932d7222eb0be1510906483d4483))
|
|
9
|
+
|
|
3
10
|
## [1.11.2](https://github.com/KarinJS/Karin/compare/core-v1.11.1...core-v1.11.2) (2025-10-07)
|
|
4
11
|
|
|
5
12
|
|
package/dist/index.mjs
CHANGED
|
@@ -20449,21 +20449,58 @@ var init_mock = __esm({
|
|
|
20449
20449
|
const PXAT = Number(options.PXAT);
|
|
20450
20450
|
if (!isNaN(PXAT)) expire = PXAT;
|
|
20451
20451
|
this.store[key] = { type: "str" /* STR */, expire };
|
|
20452
|
+
this.#str[key] = value;
|
|
20452
20453
|
} else if (options?.KEEPTTL) {
|
|
20453
|
-
if (this.#str[key]) {
|
|
20454
|
+
if (this.#str[key] && this.store[key]) {
|
|
20454
20455
|
this.#str[key] = value;
|
|
20456
|
+
expire = this.store[key].expire;
|
|
20455
20457
|
} else {
|
|
20456
20458
|
this.store[key] = { type: "str" /* STR */, expire: -1 };
|
|
20457
20459
|
this.#str[key] = value;
|
|
20460
|
+
expire = -1;
|
|
20458
20461
|
}
|
|
20459
20462
|
} else if (options?.NX) {
|
|
20460
|
-
if (!this
|
|
20463
|
+
if (!this.store[key] || this.checkExpire(key, false)) {
|
|
20461
20464
|
this.store[key] = { type: "str" /* STR */, expire: -1 };
|
|
20462
20465
|
this.#str[key] = value;
|
|
20466
|
+
this.#sqlite.set(key, value, "str" /* STR */, -1);
|
|
20463
20467
|
}
|
|
20468
|
+
return "OK";
|
|
20464
20469
|
} else if (options?.XX) {
|
|
20465
|
-
if (this
|
|
20470
|
+
if (this.store[key]) {
|
|
20471
|
+
const currentExpire = this.store[key].expire;
|
|
20472
|
+
const oldType = this.store[key].type;
|
|
20473
|
+
if (oldType !== "str" /* STR */) {
|
|
20474
|
+
switch (oldType) {
|
|
20475
|
+
case "num" /* NUM */:
|
|
20476
|
+
delete this.#num[key];
|
|
20477
|
+
break;
|
|
20478
|
+
case "hash" /* HASH */:
|
|
20479
|
+
delete this.#hash[key];
|
|
20480
|
+
break;
|
|
20481
|
+
case "list" /* LIST */:
|
|
20482
|
+
delete this.#list[key];
|
|
20483
|
+
break;
|
|
20484
|
+
case "set" /* SET */:
|
|
20485
|
+
delete this.#set[key];
|
|
20486
|
+
break;
|
|
20487
|
+
case "zset" /* ZSET */:
|
|
20488
|
+
delete this.#zset[key];
|
|
20489
|
+
break;
|
|
20490
|
+
case "pf" /* PF */:
|
|
20491
|
+
delete this.#pf[key];
|
|
20492
|
+
break;
|
|
20493
|
+
case "bit" /* BIT */:
|
|
20494
|
+
delete this.#bit[key];
|
|
20495
|
+
break;
|
|
20496
|
+
}
|
|
20497
|
+
}
|
|
20498
|
+
this.store[key] = { type: "str" /* STR */, expire: currentExpire };
|
|
20466
20499
|
this.#str[key] = value;
|
|
20500
|
+
this.#sqlite.set(key, value, "str" /* STR */, currentExpire);
|
|
20501
|
+
return "OK";
|
|
20502
|
+
} else {
|
|
20503
|
+
return null;
|
|
20467
20504
|
}
|
|
20468
20505
|
} else if (options?.GET) {
|
|
20469
20506
|
this.store[key] = { type: "str" /* STR */, expire: -1 };
|
|
@@ -20519,13 +20556,14 @@ var init_mock = __esm({
|
|
|
20519
20556
|
* @description 仅当键不存在时设置键值对
|
|
20520
20557
|
* @param key 键
|
|
20521
20558
|
* @param value 值
|
|
20559
|
+
* @returns 返回 1 表示键已设置,0 表示键已存在
|
|
20522
20560
|
*/
|
|
20523
20561
|
async setNX(key, value) {
|
|
20524
20562
|
if (this.store[key] && !this.checkExpire(key)) {
|
|
20525
|
-
return
|
|
20563
|
+
return 0;
|
|
20526
20564
|
}
|
|
20527
20565
|
await this.set(key, value, { NX: true });
|
|
20528
|
-
return
|
|
20566
|
+
return 1;
|
|
20529
20567
|
}
|
|
20530
20568
|
/**
|
|
20531
20569
|
* @description 获取键值并设置过期时间
|