Skip to content

Commit 0ad330b

Browse files
committed
add: hDelete on LocalCache
1 parent 9a6d4a8 commit 0ad330b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/cache/localcache.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,19 @@ export class LocalCache implements ICache {
8080
}
8181
}
8282

83-
async hDelete() {
84-
console.log('hDelete not implemented');
85-
return 0;
83+
async hDelete(key: string, field: string) {
84+
try {
85+
const data = LocalCache.localCache.get(this.buildKey(key)) as Object;
86+
87+
if (data && field in data) {
88+
delete data[field];
89+
LocalCache.localCache.set(key, data);
90+
return 1;
91+
}
92+
93+
return 0;
94+
} catch (error) {
95+
this.logger.error(error);
96+
}
8697
}
8798
}

0 commit comments

Comments
 (0)