nrk / redis-lua

A Lua client library for the redis key value storage system.
MIT License
733 stars 239 forks source link

Fix a bug by deleting code (RANDOMKEY) #24

Closed catwell closed 11 years ago

catwell commented 11 years ago

The empty string is a valid key in Redis.

nrk commented 11 years ago

Hmmm I may be remembering it wrong but I'm pretty sure there was a point in time when Redis actually returned an empty string from RANDOMKEY instead of a nil... but that was probably around v0.9 or so :-) Will merge later, thanks.

catwell commented 11 years ago

Ah, maybe, I only tested on 2.6. But returning nil on the empty string is a bug IMO.

I actually hit it, because in my test suite for fakeredis I use the empty key. I found the bug by running the test suite against redis-lua instead of fakeredis.

nrk commented 11 years ago

Yep nil should be returned only when Redis returns nil, that is only when the database is empty. As far as I remember, storing empty keys was impossible when Redis didn't rely on the unified protocol for requests and that's why very old versions of Redis probably used empty strings to notify users in case of an empty database. It's not that we care for ancient versions of Redis to such an extent, so merging is actually fine.

nrk commented 11 years ago

Manually cherry-picked, thanks!