@atproto-labs/simple-store-redis 0.0.1 → 0.1.0
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 +17 -0
- package/LICENSE.txt +1 -1
- package/dist/index.js +7 -23
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atproto-labs/simple-store-redis
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Drop support for Node.js 18 and 20. Node.js 22 is now the minimum supported version. Docker images now use Node.js 24.
|
|
8
|
+
|
|
9
|
+
- [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Convert to pure ESM. All packages now ship `"type": "module"` with ES module output and Node16 module resolution.
|
|
10
|
+
|
|
11
|
+
Node.js 22's `require()` compatibility layer can still load these packages in CommonJS code.
|
|
12
|
+
|
|
13
|
+
- [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705) Thanks [@devinivy](https://github.com/devinivy)! - Build with TypeScript 6.0.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c), [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9), [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705)]:
|
|
18
|
+
- @atproto-labs/simple-store@0.4.0
|
|
19
|
+
|
|
3
20
|
## 0.0.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Dual MIT/Apache-2.0 License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022-
|
|
3
|
+
Copyright (c) 2022-2026 Bluesky Social PBC, and Contributors
|
|
4
4
|
|
|
5
5
|
Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
|
|
6
6
|
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const defaultEncoder = (value) => JSON.stringify(value);
|
|
5
|
-
exports.defaultEncoder = defaultEncoder;
|
|
6
|
-
const defaultDecoder = (value) => JSON.parse(value);
|
|
7
|
-
exports.defaultDecoder = defaultDecoder;
|
|
8
|
-
class SimpleStoreRedis {
|
|
1
|
+
export const defaultEncoder = (value) => JSON.stringify(value);
|
|
2
|
+
export const defaultDecoder = (value) => JSON.parse(value);
|
|
3
|
+
export class SimpleStoreRedis {
|
|
9
4
|
constructor(redis, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value: redis
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(this, "options", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: options
|
|
21
|
-
});
|
|
5
|
+
this.redis = redis;
|
|
6
|
+
this.options = options;
|
|
22
7
|
if (!options.keyPrefix) {
|
|
23
8
|
throw new TypeError(`keyPrefix must be a non-empty string`);
|
|
24
9
|
}
|
|
@@ -35,12 +20,12 @@ class SimpleStoreRedis {
|
|
|
35
20
|
if (eValue == null)
|
|
36
21
|
return undefined;
|
|
37
22
|
options?.signal?.throwIfAborted();
|
|
38
|
-
const { decode =
|
|
23
|
+
const { decode = defaultDecoder } = this.options;
|
|
39
24
|
return decode(eValue, key);
|
|
40
25
|
}
|
|
41
26
|
async set(key, value) {
|
|
42
27
|
const eKey = this.encodeKey(key);
|
|
43
|
-
const { encode =
|
|
28
|
+
const { encode = defaultEncoder, ttl } = this.options;
|
|
44
29
|
const eValue = await encode(value, key);
|
|
45
30
|
if (ttl)
|
|
46
31
|
await this.redis.set(eKey, eValue, 'PX', ttl);
|
|
@@ -52,5 +37,4 @@ class SimpleStoreRedis {
|
|
|
52
37
|
await this.redis.del(eKey);
|
|
53
38
|
}
|
|
54
39
|
}
|
|
55
|
-
exports.SimpleStoreRedis = SimpleStoreRedis;
|
|
56
40
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,cAAc,GAAwB,CAAC,KAAK,EAAE,EAAE,CAC3D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AACvB,MAAM,CAAC,MAAM,cAAc,GAAwB,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAY/E,MAAM,OAAO,gBAAgB;IAG3B,YACqB,KAAY,EACZ,OAAsC;QADtC,UAAK,GAAL,KAAK,CAAO;QACZ,YAAO,GAAP,OAAO,CAA+B;QAEzD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAA;QAC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AC,GAAM;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QAChC,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { Redis } from 'ioredis'\nimport {\n Awaitable,\n GetOptions,\n SimpleStore,\n Value,\n} from '@atproto-labs/simple-store'\n\nexport type { Awaitable, GetOptions, SimpleStore, Value }\n\nexport type Encoder<K extends string, V extends Value> = (\n value: V,\n key: K,\n) => Awaitable<string>\nexport type Decoder<K extends string, V extends Value> = (\n value: string,\n key: K,\n) => Awaitable<V>\n\nexport const defaultEncoder: Encoder<any, Value> = (value) =>\n JSON.stringify(value)\nexport const defaultDecoder: Decoder<any, Value> = (value) => JSON.parse(value)\n\nexport type SimpleStoreRedisOptions<K extends string, V extends Value> = {\n keyPrefix: string\n /** In milliseconds */\n ttl?: number\n /** @default JSON.stringify */\n encode?: Encoder<K, V>\n /** @default JSON.parse */\n decode?: Decoder<K, V>\n}\n\nexport class SimpleStoreRedis<K extends string, V extends Value>\n implements SimpleStore<K, V>\n{\n constructor(\n protected readonly redis: Redis,\n protected readonly options: SimpleStoreRedisOptions<K, V>,\n ) {\n if (!options.keyPrefix) {\n throw new TypeError(`keyPrefix must be a non-empty string`)\n }\n if (options.ttl != null && options.ttl <= 0) {\n throw new TypeError(`ttl must be greater than 0`)\n }\n }\n\n protected encodeKey(key: K): string {\n return `${this.options.keyPrefix}${key satisfies string}`\n }\n\n async get(key: K, options?: GetOptions): Promise<V | undefined> {\n const eKey = this.encodeKey(key)\n const eValue = await this.redis.get(eKey)\n if (eValue == null) return undefined\n options?.signal?.throwIfAborted()\n const { decode = defaultDecoder as Decoder<any, V> } = this.options\n return decode(eValue, key)\n }\n\n async set(key: K, value: V): Promise<void> {\n const eKey = this.encodeKey(key)\n const { encode = defaultEncoder, ttl } = this.options\n const eValue = await encode(value, key)\n if (ttl) await this.redis.set(eKey, eValue, 'PX', ttl)\n else await this.redis.set(eKey, eValue)\n }\n\n async del(key: K): Promise<void> {\n const eKey = this.encodeKey(key)\n await this.redis.del(eKey)\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto-labs/simple-store-redis",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=22"
|
|
6
|
+
},
|
|
4
7
|
"license": "MIT",
|
|
5
8
|
"description": "Redis based simple-store implementation",
|
|
6
9
|
"keywords": [
|
|
@@ -14,9 +17,7 @@
|
|
|
14
17
|
"url": "https://github.com/bluesky-social/atproto",
|
|
15
18
|
"directory": "packages/internal/simple-store-redis"
|
|
16
19
|
},
|
|
17
|
-
"type": "
|
|
18
|
-
"main": "dist/index.js",
|
|
19
|
-
"types": "dist/index.d.ts",
|
|
20
|
+
"type": "module",
|
|
20
21
|
"exports": {
|
|
21
22
|
".": {
|
|
22
23
|
"types": "./dist/index.d.ts",
|
|
@@ -24,10 +25,10 @@
|
|
|
24
25
|
}
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@atproto-labs/simple-store": "0.
|
|
28
|
+
"@atproto-labs/simple-store": "^0.4.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"typescript": "^
|
|
31
|
+
"typescript": "^6.0.3"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"ioredis": "^5.3.2"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts"],"version":"
|
|
1
|
+
{"root":["./src/index.ts"],"version":"6.0.3"}
|