I was debugging a script and found a blank key which EXISTS '' returned TRUE, this was created by script but is this OK to allow having a BLANK KEY? how to prevent this from happening?
Comment From: itamarhaber
Hello @deepesh-agarwal
The empty string, "" or '', is a valid value for any Redis String. Redis Strings are used all over, as keys' names, key String values, Hash fields and values, Set values, ...
It is perfectly valid to create a key with the empty string being its name and/or value. All the following are considered ok:
redis> SET "" val
redis> HSET '' ""
redis> SADD myset ""
redis> LPUSH mylist ''
There are no easy ways to "prevent this from happening", but while you're debugging you may want to find the code path in your script that had created that key and fix the issue there.