You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-17 19:41:06 +03:00
25 lines
552 B
TypeScript
25 lines
552 B
TypeScript
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')
|
|
};
|
|
}
|