diff --git a/src/modules/aggregate/aggregate.service.ts b/src/modules/aggregate/aggregate.service.ts index b861db0c..63f54e39 100644 --- a/src/modules/aggregate/aggregate.service.ts +++ b/src/modules/aggregate/aggregate.service.ts @@ -349,9 +349,10 @@ export class AggregateService { ]) const [todayMaxOnline, todayOnlineTotal] = await Promise.all([ - redisClient.get(getRedisKey(RedisKeys.MaxOnlineCount, dateFormat)), - redisClient.get( - getRedisKey(RedisKeys.MaxOnlineCount, dateFormat, 'total'), + redisClient.hget(getRedisKey(RedisKeys.MaxOnlineCount), dateFormat), + redisClient.hget( + getRedisKey(RedisKeys.MaxOnlineCount, 'total'), + dateFormat, ), ]) diff --git a/src/processors/gateway/web/events.gateway.ts b/src/processors/gateway/web/events.gateway.ts index b5261e34..d568456e 100644 --- a/src/processors/gateway/web/events.gateway.ts +++ b/src/processors/gateway/web/events.gateway.ts @@ -69,16 +69,18 @@ export class WebEventsGateway // get and store max_online_count const maxOnlineCount = - +(await redisClient.get( - getRedisKey(RedisKeys.MaxOnlineCount, dateFormat), + +(await redisClient.hget( + getRedisKey(RedisKeys.MaxOnlineCount), + dateFormat, )) || 0 - await redisClient.set( - getRedisKey(RedisKeys.MaxOnlineCount, dateFormat), + await redisClient.hset( + getRedisKey(RedisKeys.MaxOnlineCount), + dateFormat, Math.max(maxOnlineCount, await this.getcurrentClientCount()), ) - const key = getRedisKey(RedisKeys.MaxOnlineCount, dateFormat) + '_total' - const totalCount = +(await redisClient.get(key)) || 0 - await redisClient.set(key, totalCount + 1) + const key = getRedisKey(RedisKeys.MaxOnlineCount, 'total') + const totalCount = +(await redisClient.hget(key, dateFormat)) || 0 + await redisClient.hset(key, dateFormat, totalCount + 1) }) super.handleConnect(socket)