@better-auth/redis-storage 1.6.16 → 1.6.17
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/dist/index.d.mts +1 -0
- package/dist/index.mjs +11 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -36,6 +36,7 @@ interface RedisStorageConfig {
|
|
|
36
36
|
declare function redisStorage(config: RedisStorageConfig): {
|
|
37
37
|
get(key: string): Promise<string | null>;
|
|
38
38
|
getAndDelete(key: string): Promise<unknown>;
|
|
39
|
+
increment(key: string, ttl: number): Promise<number>;
|
|
39
40
|
set(key: string, value: string, ttl?: number | undefined): Promise<void>;
|
|
40
41
|
delete(key: string): Promise<void>;
|
|
41
42
|
listKeys(): Promise<string[]>;
|
package/dist/index.mjs
CHANGED
|
@@ -29,6 +29,13 @@ if value ~= false then
|
|
|
29
29
|
redis.call("DEL", KEYS[1])
|
|
30
30
|
end
|
|
31
31
|
return value
|
|
32
|
+
`;
|
|
33
|
+
const incrementScript = `
|
|
34
|
+
local value = redis.call("INCR", KEYS[1])
|
|
35
|
+
if value == 1 then
|
|
36
|
+
redis.call("EXPIRE", KEYS[1], ARGV[1])
|
|
37
|
+
end
|
|
38
|
+
return value
|
|
32
39
|
`;
|
|
33
40
|
const prefixKey = (key) => {
|
|
34
41
|
return `${keyPrefix}${key}`;
|
|
@@ -48,6 +55,10 @@ return value
|
|
|
48
55
|
}
|
|
49
56
|
return client.eval(getAndDeleteScript, 1, prefixedKey);
|
|
50
57
|
},
|
|
58
|
+
async increment(key, ttl) {
|
|
59
|
+
const value = await client.eval(incrementScript, 1, prefixKey(key), ttl);
|
|
60
|
+
return Number(value);
|
|
61
|
+
},
|
|
51
62
|
async set(key, value, ttl) {
|
|
52
63
|
const prefixedKey = prefixKey(key);
|
|
53
64
|
if (ttl !== void 0 && ttl > 0) await client.setex(prefixedKey, ttl, value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/redis-storage",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.17",
|
|
4
4
|
"description": "Redis storage for Better Auth secondary storage",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"ioredis": "^5.0.0",
|
|
38
|
-
"@better-auth/core": "^1.6.
|
|
38
|
+
"@better-auth/core": "^1.6.17"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^25.3.2",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"tsdown": "0.21.1",
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
45
|
"vitest": "^4.1.5",
|
|
46
|
-
"@better-auth/core": "1.6.
|
|
46
|
+
"@better-auth/core": "1.6.17"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsdown",
|