瀏覽代碼

修复cache service与固定typescript版本

gemercheung 2 年之前
父節點
當前提交
f17327d3ad
共有 4 個文件被更改,包括 6115 次插入6186 次删除
  1. 1 1
      package.json
  2. 13 1
      src/cache/cache.service.ts
  3. 1 1
      src/scene/scene.service.ts
  4. 6100 6183
      yarn.lock

+ 1 - 1
package.json

@@ -73,7 +73,7 @@
     "ts-loader": "^9.2.3",
     "ts-node": "^10.0.0",
     "tsconfig-paths": "^3.10.1",
-    "typescript": "^4.3.5"
+    "typescript": "4.3.5"
   },
   "jest": {
     "moduleFileExtensions": [

+ 13 - 1
src/cache/cache.service.ts

@@ -10,7 +10,7 @@ import { RedisService } from 'nestjs-redis';
 export class CacheService implements OnModuleInit, OnModuleDestroy {
   public client;
   private logger: Logger = new Logger('CacheService');
-  constructor(private redisService: RedisService) {}
+  constructor(private redisService: RedisService) { }
 
   async onModuleInit() {
     try {
@@ -84,6 +84,18 @@ export class CacheService implements OnModuleInit, OnModuleDestroy {
     }
     await this.client.del(key);
   }
+  public async hDel(key: string, data: any) {
+    if (!this.client) {
+      await this.getClient();
+    }
+    return this.client.hdel(key, data);
+  }
+  public async hSet(key: string, data: any, value: any) {
+    if (!this.client) {
+      await this.getClient();
+    }
+    return this.client.hset(key, data, value);
+  }
   // 清理缓存
   public async flushall(): Promise<any> {
     if (!this.client) {

+ 1 - 1
src/scene/scene.service.ts

@@ -1178,7 +1178,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         ? `test-room:${roomId}`
         : `room:${roomId}`;
 
-    this.cacheService.hset(roomKey, userId, 1);
+    this.cacheService.hSet(roomKey, userId, 1);
     // debugger;
     this.channel.onBufferedAmountLow(() => {
       console.error('onBufferedAmountLow-rtt', this.peer.rtt());

文件差異過大導致無法顯示
+ 6100 - 6183
yarn.lock