You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-17 19:41:06 +03:00
Add support for lua scripts in client & muilti, fix client socket initiator, implement simple cluster nodes discovery strategy
This commit is contained in:
24
lib/lua-script.ts
Normal file
24
lib/lua-script.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { createHash } from 'crypto';
|
||||
import { RedisCommand } from './commands';
|
||||
|
||||
export interface RedisLuaScriptConfig extends RedisCommand {
|
||||
SCRIPT: string;
|
||||
NUMBER_OF_KEYS: number;
|
||||
}
|
||||
|
||||
interface SHA {
|
||||
SHA: string;
|
||||
}
|
||||
|
||||
export type RedisLuaScript = RedisLuaScriptConfig & SHA;
|
||||
|
||||
export interface RedisLuaScripts {
|
||||
[key: string]: RedisLuaScript;
|
||||
}
|
||||
|
||||
export function defineScript<S extends RedisLuaScriptConfig>(script: S): S & SHA {
|
||||
return {
|
||||
...script,
|
||||
SHA: createHash('sha1').update(script.SCRIPT).digest('hex')
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user