@travetto/model-redis 3.0.0-rc.3 → 3.0.0-rc.6
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 +3 -3
- package/{index.ts → __index__.ts} +0 -0
- package/package.json +17 -7
- package/src/service.ts +5 -4
- package/support/service.redis.ts +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- This file was generated by @travetto/doc and should not be modified directly -->
|
|
2
|
-
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/model-redis/
|
|
2
|
+
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/model-redis/DOC.ts and execute "npx trv doc" to rebuild -->
|
|
3
3
|
# Redis Model Support
|
|
4
4
|
## Redis backing for the travetto model module.
|
|
5
5
|
|
|
@@ -59,5 +59,5 @@ export class RedisModelConfig {
|
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Additionally, you can see that the class is registered with the [@Config](https://github.com/travetto/travetto/tree/main/module/config/src/decorator.ts#
|
|
63
|
-
standard [Configuration](https://github.com/travetto/travetto/tree/main/module/config#readme "
|
|
62
|
+
Additionally, you can see that the class is registered with the [@Config](https://github.com/travetto/travetto/tree/main/module/config/src/decorator.ts#L13) annotation, and so these values can be overridden using the
|
|
63
|
+
standard [Configuration](https://github.com/travetto/travetto/tree/main/module/config#readme "Configuration support")resolution paths.
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-redis",
|
|
3
|
-
"
|
|
4
|
-
"version": "3.0.0-rc.3",
|
|
3
|
+
"version": "3.0.0-rc.6",
|
|
5
4
|
"description": "Redis backing for the travetto model module.",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"typescript",
|
|
@@ -16,19 +15,30 @@
|
|
|
16
15
|
"name": "Travetto Framework"
|
|
17
16
|
},
|
|
18
17
|
"files": [
|
|
19
|
-
"
|
|
18
|
+
"__index__.ts",
|
|
20
19
|
"src",
|
|
21
20
|
"support"
|
|
22
21
|
],
|
|
23
|
-
"main": "
|
|
22
|
+
"main": "__index__.ts",
|
|
24
23
|
"repository": {
|
|
25
24
|
"url": "https://github.com/travetto/travetto.git",
|
|
26
25
|
"directory": "module/model-redis"
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^3.0.0-rc.
|
|
30
|
-
"@travetto/model": "^3.0.0-rc.
|
|
31
|
-
"redis": "^4.
|
|
28
|
+
"@travetto/config": "^3.0.0-rc.6",
|
|
29
|
+
"@travetto/model": "^3.0.0-rc.6",
|
|
30
|
+
"redis": "^4.5.1"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@travetto/command": "^3.0.0-rc.4"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@travetto/command": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"travetto": {
|
|
41
|
+
"displayName": "Redis Model Support"
|
|
32
42
|
},
|
|
33
43
|
"publishConfig": {
|
|
34
44
|
"access": "public"
|
package/src/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as redis from 'redis';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ShutdownManager, type Class } from '@travetto/base';
|
|
4
4
|
import { DeepPartial } from '@travetto/schema';
|
|
5
5
|
import {
|
|
6
6
|
ModelCrudSupport, ModelExpirySupport, ModelRegistry, ModelType, ModelStorageSupport,
|
|
@@ -12,6 +12,7 @@ import { ModelCrudUtil } from '@travetto/model/src/internal/service/crud';
|
|
|
12
12
|
import { ModelExpiryUtil } from '@travetto/model/src/internal/service/expiry';
|
|
13
13
|
import { ModelIndexedUtil } from '@travetto/model/src/internal/service/indexed';
|
|
14
14
|
import { ModelStorageUtil } from '@travetto/model/src/internal/service/storage';
|
|
15
|
+
import { ModelUtil } from '@travetto/model/src/internal/util';
|
|
15
16
|
|
|
16
17
|
import { RedisModelConfig } from './config';
|
|
17
18
|
|
|
@@ -175,12 +176,12 @@ export class RedisModelService implements ModelCrudSupport, ModelExpirySupport,
|
|
|
175
176
|
this.client = redis.createClient(this.config.client);
|
|
176
177
|
await this.client.connect();
|
|
177
178
|
await ModelStorageUtil.registerModelChangeListener(this);
|
|
178
|
-
ShutdownManager.onShutdown(this
|
|
179
|
+
ShutdownManager.onShutdown(this, () => this.client.disconnect());
|
|
179
180
|
for (const el of ModelRegistry.getClasses()) {
|
|
180
181
|
for (const idx of ModelRegistry.get(el).indices ?? []) {
|
|
181
182
|
switch (idx.type) {
|
|
182
183
|
case 'unique': {
|
|
183
|
-
console.error('Unique indices are not supported in redis for', { cls: el
|
|
184
|
+
console.error('Unique indices are not supported in redis for', { cls: el.Ⲑid, idx: idx.name });
|
|
184
185
|
break;
|
|
185
186
|
}
|
|
186
187
|
}
|
|
@@ -189,7 +190,7 @@ export class RedisModelService implements ModelCrudSupport, ModelExpirySupport,
|
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
uuid(): string {
|
|
192
|
-
return
|
|
193
|
+
return ModelUtil.uuid(32);
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
async has<T extends ModelType>(cls: Class<T>, id: string, error?: 'notfound' | 'data'): Promise<void> {
|
package/support/service.redis.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Service } from '@travetto/command/bin/
|
|
1
|
+
import { Env } from '@travetto/base';
|
|
2
|
+
import type { Service } from '@travetto/command/support/bin/service';
|
|
3
3
|
|
|
4
|
-
const version =
|
|
4
|
+
const version = Env.get('REDIS_VERSION', '5');
|
|
5
5
|
|
|
6
6
|
export const service: Service = {
|
|
7
7
|
name: 'redis',
|