Merge pull request #30338 from tingwai-to/master

[ioredis] Add types for Redis Streams commands
This commit is contained in:
Armando Aguirre 2018-11-07 15:25:38 -08:00 committed by GitHub
commit 70c1fe819a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 0 deletions

View File

@ -9,6 +9,7 @@
// Francis Gulotta <https://github.com/reconbot>
// Dmitry Motovilov <https://github.com/funthing>
// Oleg Repin <https://github.com/iamolegga>
// Ting-Wai To <https://github.com/tingwai-to>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@ -482,6 +483,32 @@ declare namespace IORedis {
sscanStream(key: KeyType, options?: ScanStreamOption): NodeJS.EventEmitter;
hscanStream(key: KeyType, options?: ScanStreamOption): NodeJS.EventEmitter;
zscanStream(key: KeyType, options?: ScanStreamOption): NodeJS.EventEmitter;
xack(key: KeyType, group: string, ...ids: string[]): any;
xadd(key: KeyType, id: string, ...args: string[]): any;
xclaim(key: KeyType, group: string, consumer: string, minIdleTime: number, ...args: any[]): any;
xdel(key: KeyType, ...ids: string[]): any;
xgroup(...args: any[]): any;
xinfo(...args: any[]): any;
xlen(key: KeyType): any;
xpending(key: KeyType, group: string, ...args: any[]): any;
xrange(key: KeyType, start: string, end: string, ...args: any[]): any;
xread(...args: any[]): any;
xreadgroup(groupOption: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): any;
xrevrange(key: KeyType, end: string, start: string, ...args: any[]): any;
xtrim(key: KeyType, maxLenOption: 'MAXLEN' | 'maxlen', ...args: any[]): any;
}
interface Pipeline {
@ -801,6 +828,32 @@ declare namespace IORedis {
pfadd(key: KeyType, ...elements: string[]): Pipeline;
pfcount(...keys: KeyType[]): Pipeline;
xack(key: KeyType, group: string, ...ids: string[]): Pipeline;
xadd(key: KeyType, id: string, ...args: string[]): Pipeline;
xclaim(key: KeyType, group: string, consumer: string, minIdleTime: number, id: string, ...args: any[]): Pipeline;
xdel(key: KeyType, ...ids: string[]): Pipeline;
xgroup(...args: any[]): Pipeline;
xinfo(...args: any[]): Pipeline;
xlen(key: KeyType): Pipeline;
xpending(key: KeyType, group: string, ...args: any[]): Pipeline;
xrange(key: KeyType, start: string, end: string, ...args: any[]): Pipeline;
xread(...args: any[]): Pipeline;
xreadgroup(command: 'GROUP' | 'group', group: string, consumer: string, ...args: any[]): Pipeline;
xrevrange(key: KeyType, end: string, start: string, ...args: any[]): Pipeline;
xtrim(key: KeyType, strategy: 'MAXLEN' | 'maxlen', ...args: any[]): Pipeline;
}
interface NodeConfiguration {

View File

@ -173,3 +173,22 @@ new Redis.Cluster([{
host: 'localhost',
port: 6379
}]);
redis.xack('streamName', 'groupName', 'id');
redis.xadd('streamName', '*', 'field', 'name');
redis.xclaim('streamName', 'groupName', 'consumerName', 3600000, 'id');
redis.xdel('streamName', 'id');
redis.xgroup('CREATE', 'streamName', 'groupName', '$');
redis.xgroup('SETUP', 'streamName', 'groupName', '$');
redis.xgroup('DESTROY', 'streamName', 'groupName');
redis.xgroup('DELCONSUMER', 'streamName', 'groupName', 'consumerName');
redis.xinfo('CONSUMERS', 'streamName', 'groupName');
redis.xinfo('GROUPS', 'streamName');
redis.xinfo('STREAM', 'streamName');
redis.xlen('streamName');
redis.xpending('streamName', 'groupName', '-', '+', '10', 'consumerName');
redis.xrange('streamName', '-', '+', 'COUNT', 1);
redis.xread('STREAMS', 'streamName', '0-0');
redis.xreadgroup('GROUP', 'groupName', 'consumerName', 'STREAMS', 'streamName', '>');
redis.xrevrange('streamName', '+', '-', 'COUNT', 1);
redis.xtrim('streamName', 'MAXLEN', '~', 1000);