@travetto/model-redis 7.1.4 → 8.0.0-alpha.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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/service.ts +7 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-redis",
3
- "version": "7.1.4",
3
+ "version": "8.0.0-alpha.1",
4
4
  "type": "module",
5
5
  "description": "Redis backing for the travetto model module.",
6
6
  "keywords": [
@@ -26,12 +26,12 @@
26
26
  "directory": "module/model-redis"
27
27
  },
28
28
  "dependencies": {
29
- "@redis/client": "^5.10.0",
30
- "@travetto/config": "^7.1.4",
31
- "@travetto/model": "^7.1.4"
29
+ "@redis/client": "^5.11.0",
30
+ "@travetto/config": "^8.0.0-alpha.1",
31
+ "@travetto/model": "^8.0.0-alpha.1"
32
32
  },
33
33
  "peerDependencies": {
34
- "@travetto/cli": "^7.1.4"
34
+ "@travetto/cli": "^8.0.0-alpha.1"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@travetto/cli": {
package/src/service.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { createClient } from '@redis/client';
2
2
 
3
- import { ShutdownManager, type Class, type DeepPartial } from '@travetto/runtime';
3
+ import { JSONUtil, ShutdownManager, type Class, type DeepPartial } from '@travetto/runtime';
4
4
  import {
5
5
  type ModelCrudSupport, type ModelExpirySupport, ModelRegistryIndex, type ModelType, type ModelStorageSupport,
6
6
  NotFoundError, ExistsError, type ModelIndexedSupport, type OptionalId,
7
7
  ModelCrudUtil, ModelExpiryUtil, ModelIndexedUtil, ModelStorageUtil,
8
8
  } from '@travetto/model';
9
- import { Injectable } from '@travetto/di';
9
+ import { Injectable, PostConstruct } from '@travetto/di';
10
10
 
11
11
  import type { RedisModelConfig } from './config.ts';
12
12
 
@@ -106,7 +106,7 @@ export class RedisModelService implements ModelCrudSupport, ModelExpirySupport,
106
106
  }
107
107
  switch (action) {
108
108
  case 'write': {
109
- multi.set(key, JSON.stringify(item));
109
+ multi.set(key, JSONUtil.toUTF8(item));
110
110
  this.#addIndices(cls, item, multi);
111
111
  break;
112
112
  }
@@ -119,7 +119,7 @@ export class RedisModelService implements ModelCrudSupport, ModelExpirySupport,
119
119
  } else {
120
120
  switch (action) {
121
121
  case 'write': {
122
- await this.client.set(key, JSON.stringify(item));
122
+ await this.client.set(key, JSONUtil.toUTF8(item));
123
123
  break;
124
124
  }
125
125
  case 'delete': {
@@ -167,11 +167,12 @@ export class RedisModelService implements ModelCrudSupport, ModelExpirySupport,
167
167
  throw new NotFoundError(`${cls.name}: ${idx}`, key);
168
168
  }
169
169
 
170
- async postConstruct(): Promise<void> {
170
+ @PostConstruct()
171
+ async initializeClient(): Promise<void> {
171
172
  this.client = createClient(this.config.client);
172
173
  await this.client.connect();
173
174
  await ModelStorageUtil.storageInitialization(this);
174
- ShutdownManager.signal.addEventListener('abort', () => this.client.destroy());
175
+ ShutdownManager.signal.addEventListener('abort', () => this.client.close());
175
176
  for (const cls of ModelRegistryIndex.getClasses()) {
176
177
  for (const idx of ModelRegistryIndex.getConfig(cls).indices ?? []) {
177
178
  switch (idx.type) {