5 ms·
Most of redis' API is quite coherent. Some of the incoherence is due to the fact that some commands get less attention, such as LPUSHX (which I've never really
by dvirsky 10y ago
Most of redis' API is quite coherent. Some of the incoherence is due to the fact that some commands get less attention, such as LPUSHX (which I've never really noticed and I've been using redis for 6 years). Some is because of the core idea of remaining backwards compatible, so even if you have option or commands added, they will never replace old ones, which can cause a bit of complexity and inconsistency.
> Why there is even hyperloglog in a database?
Remember that redis is not really a database but a "data structure server". I have to say I personally don't think this should have been part of the redis core, and it's a textbook example of what redis modules should be, but it came 2-3 years before modules.
> Where did the need for RPUSHLPOP come from?
It came from distributed work queues, which are a popular use case for redis. The documentation actually goes into great detail explaining how to use it.
- catwell 10y agoLPUSHX got my attention so I opened a pull request making it variadic (along with other commands) three years ago [1]. Of course since then the codebase changed and it can no longer be merged. If there is still interest I could try to fix it, although I don't use Redis as much anymore and I have not looked at its code for a long time. [1] https://github.com/antirez/redis/pull/1232 https://github.com/antirez/redis/pull/1232
- dvirsky 10y agotry to go on the #redis freenode channel and ask antirez about it.
- antirez 10y agoHey! Yes I'm interested, the PR was not handled for the usual reasons but making the commands variadic is a good idea. However I'm surprised there is not just the need to change the command table since I remembered, incorrectly, all the variants were handled by a single function.
- catwell 10y agoYeah, as you can see the issue was that it is a different function, pushxGenericCommand(), which is used for LPUSHX, RPUSHX and LINSERT. For me having the same function for LPUSHX / RPUSHX and LINSERT does not make much sense (it uses different code depending on whether or not an argument is NULL anyway) so I had started by making LINSERT not rely on it. My initial goal at the time was not to make LPUSHX and RPUSHX variadic, since like you said they are not used so much. It was actually to make LINSERT variadic, which can result in a significant performance boost compared to calling it several times. Anyway, I will try to find the time to adapt it to the current code base.
- jamespedwards 10y ago"data structure server" hits the nail on the head. Because Redis is such a paradigm shift from a traditional database, it doesn't matter how simple Redis is, it will always feel complicated if people go into it anticipating a traditional database. ...Some of us don't like Chipotle because it has too many choices, even though we could just order the get/set burrito.