๐Ÿฆ• ๐Ÿ’พ The Redis Streams API will land in deno-redis pretty soon. Iโ€™m nearing completion with this pull request and hope for a thorough review.

๐Ÿž ๐Ÿ• Thereโ€™s been a lot of activity in this repository, which is encouraging!

API design art

We gladly welcome feedback on the design. You can read the method defs in command.ts to see the most up-to-date version of the command inputs & outputs

The effort is nearing completion as a pre-review draft. Thanks for your patience.

Strongly Typed Message IDs

We implemented strong types for stream entry IDs:

export interface XId {
  unixMs: bigint;
  seqNo: bigint;
}

Because Redis returns 64bit ints in these values, we use bigint.

We made an effort to ensure flexibility in the command interfaces. For instance, in xadd, you may also pass simple numbers, or paired numbers [1000,10], or the special string "*".

Methods which return XIds will always return the exact form, so that you can deconstruct them with minimal pain.

See XId and the related types in streams.ts for details.

Return type for XREAD hammer_and_wrench

We offer an interface for the XREAD reply type which is hopefully less annoying to use than the Redis default array type. Please note that we return field_value pairs as a Map.

export interface XMessage {
  id: XId;
  field_values: Map<string, string>;
}
export type XReadStream = { key: string; messages: XMessage[] };
export type XReadReply = XReadStream[];
  • implement a nice return type for XREAD and XREADGROUP

#deno #redis #api #node #developer

Redis Streams API Coming to Deno
9.85 GEEK