From 453ffc9e8a24c7404ca2951fa28e9e54da42f20d Mon Sep 17 00:00:00 2001 From: "Angus.Fenying" Date: Sun, 22 Jan 2017 16:17:37 +0800 Subject: [PATCH] Added methods cork and uncork for RedisClient. --- redis/index.d.ts | 10 ++++++++++ redis/redis-tests.ts | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/redis/index.d.ts b/redis/index.d.ts index 75745b99f4..0e7e2ec4de 100644 --- a/redis/index.d.ts +++ b/redis/index.d.ts @@ -94,6 +94,16 @@ export interface RedisClient extends NodeJS.EventEmitter { end(): void; unref(): void; + /** + * Stop sending commands and queue the commands. + */ + cork(): void; + + /** + * Resume and send the queued commands at once. + */ + uncork(): void; + // Low level command execution send_command(command: string, ...args: any[]): boolean; diff --git a/redis/redis-tests.ts b/redis/redis-tests.ts index d98979f256..e0315a809f 100644 --- a/redis/redis-tests.ts +++ b/redis/redis-tests.ts @@ -112,4 +112,10 @@ client.monitor(resCallback); // Send command client.send_command(str, args, resCallback); // Duplicate -client.duplicate(); \ No newline at end of file +client.duplicate(); + +// Pipeline +client.cork(); +client.set("abc", "fff", strCallback); +client.get("abc", resCallback); +client.uncork();