dt-common-device 2.0.2 → 2.0.3
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class RedisUtils {
|
|
2
2
|
private client;
|
|
3
|
-
hget(key: string, field: string): Promise<
|
|
3
|
+
hget(key: string, field: string): Promise<any | null>;
|
|
4
4
|
hset(key: string, field: string, value: string): Promise<number>;
|
|
5
5
|
hdel(key: string, ...fields: string[]): Promise<number>;
|
|
6
6
|
exists(key: string): Promise<number>;
|
|
@@ -52,7 +52,8 @@ let RedisUtils = (() => {
|
|
|
52
52
|
}
|
|
53
53
|
async hget(key, field) {
|
|
54
54
|
try {
|
|
55
|
-
|
|
55
|
+
const value = await this.client.hget(key, field);
|
|
56
|
+
return JSON.parse(value);
|
|
56
57
|
}
|
|
57
58
|
catch (error) {
|
|
58
59
|
console.error(`Error getting value for key ${key}:`, error);
|
package/package.json
CHANGED
package/src/utils/redis.utils.ts
CHANGED
|
@@ -5,9 +5,10 @@ import { getRedisClient } from "../db/redis";
|
|
|
5
5
|
export class RedisUtils {
|
|
6
6
|
private client = getRedisClient(); // singleton Redis client instance
|
|
7
7
|
|
|
8
|
-
async hget(key: string, field: string): Promise<
|
|
8
|
+
async hget(key: string, field: string): Promise<any | null> {
|
|
9
9
|
try {
|
|
10
|
-
|
|
10
|
+
const value: any = await this.client.hget(key, field);
|
|
11
|
+
return JSON.parse(value);
|
|
11
12
|
} catch (error) {
|
|
12
13
|
console.error(`Error getting value for key ${key}:`, error);
|
|
13
14
|
throw error;
|