redis-rcp icon indicating copy to clipboard operation
redis-rcp copied to clipboard

Request for RCP number 5

Open adriano-di-giovanni opened this issue 9 years ago • 4 comments

Developing abstraction libraries for Redis sometimes require to know which data type a given command operates on.

It'd be great to have COMMAND and COMMAND INFO to return a nested result for type.

adriano-di-giovanni avatar May 17 '15 13:05 adriano-di-giovanni

That's possible but is not the right way IMHO... I think we should change RESP in the long time (no short time change possible) in order to return multi-bulk replies in a different format:

  1. Use # instead of * to prefix the count for key,val pairs, unordered. Example: HGETALL (client libs will likely represent that data type with an hash).
  2. Use _ instead of * to prefix the count of ordered lists of elements. Example: LRANGE, ZRANGE (client libs will likely represent that with an array).
  3. Use % instead of * to prefix the count of unordered list of elements. Example: SMEMBERS (client libs will use either an Hash with value set to Nil or a Set data type if there is a native one).
  4. Use @ instead of * to prefix the count of ordered key,val pairs. Example: ZRANGE WITHSCORES (client libs will likely use an Array of two-element Arrays or something like that).
  5. Use ! as a single way to represent NULL.
  6. Use =3243432.432 to represent double values.

antirez avatar May 17 '15 16:05 antirez

@antirez, any simpler alternative? Should I "pull request"?

adriano-di-giovanni avatar May 17 '15 20:05 adriano-di-giovanni

I don't think there are other alternatives since clients designed to execute COMMAND every time they reconnect would result in a big overhead: there are still many conditions out there where apps are (mis)designed to use a new connection for every pageview or alike. So there are no simpler alternatives IMHO.

antirez avatar May 17 '15 22:05 antirez

You're delving deep into details and I can't completely understand but I'd like to be sure we're talking about the same feature.

I recently developed node-redis-commands.

The module reports all commands implemented by Redis.

Report record contains info from COMMAND plus the data type the given command operates on (if applicable):

{ name: 'get',
  arity: 2,
  flags: [ 'readonly', 'fast' ],
  firstKeyAt: 1,
  lastKeyAt: 1,
  step: 1,
  types: [ 'string' ] }

Thanks to node-redis-command I know that GET operates on strings. I implemented myself the feature that's subject of my RCP.

Did you talk about that?

Please, take a look at types.js for additional clarification.

Thanks in advance, Adriano

adriano-di-giovanni avatar May 18 '15 07:05 adriano-di-giovanni