Request for RCP number 5
adriano-di-giovanni opened this issue · 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
.
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:
- 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). - Use
_
instead of*
to prefix the count of ordered lists of elements. Example: LRANGE, ZRANGE (client libs will likely represent that with an array). - 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). - 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). - Use
!
as a single way to represent NULL. - Use
=3243432.432
to represent double values.
@antirez, any simpler alternative? Should I "pull request"?
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.
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