Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ export class Evaluator {
[__getKey(flag, $3), key],
{ result: { promise: true } }
),
delall: (key, flag) => $9.apply(
undefined,
[__getKey(flag, $3), key],
{ result: { promise: true } }
),
len: (key, flag) => $6.apply(
undefined,
[__getKey(flag, $3), key],
Expand All @@ -443,6 +448,7 @@ export class Evaluator {
store.g = store.get;
store.s = store.set;
store.d = store.del;
store.da = store.delall;
store.l = store.len;
global.s = store;
global.p = permissions;
Expand Down Expand Up @@ -476,15 +482,16 @@ export class Evaluator {
}
`,
[
new Reference(store.get),
new Reference(store.set),
new Reference(store.del),
new ExternalCopy(msg).copyInto(),
new ExternalCopy(permissions).copyInto(),
new Reference(this.fetchImplement.bind(this, potatData)),
new Reference(store.len),
new Reference(store.ex),
new Reference(this.runCommand.bind(this)),
new Reference(store.get), // $0
new Reference(store.set), // $1
new Reference(store.del), // $2
new ExternalCopy(msg).copyInto(), // $3
new ExternalCopy(permissions).copyInto(), // $4
new Reference(this.fetchImplement.bind(this, potatData)), // $5
new Reference(store.len), // $6
new Reference(store.ex), // $7
new Reference(this.runCommand.bind(this)), // $8
new Reference(store.delall), // $9
],
);

Expand Down
4 changes: 4 additions & 0 deletions src/store/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class PotatStore {
return this.#client.hdel(key, ...fields);
}

public async del(key: string | Buffer): Promise<number> {
return this.#client.del(key);
}

public async hmget<T = unknown>(
primaryKey: string,
key: string,
Expand Down
11 changes: 11 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ const del = async (
return redis.hdel(privateKey, key);
};

const delall = async (
privateKey: string,
): Promise<number> => {
if (!redis.ready) {
throw new Error('Redis store is not initialized');
}

return redis.del(privateKey);
};

const ex = async (
privateKey: string,
key: string,
Expand All @@ -74,6 +84,7 @@ export const store = {
get,
set,
del,
delall,
len,
ex,
};