Lachim / redis

Automatically exported from code.google.com/p/redis
2 stars 0 forks source link

[FEATURE REQUEST] redis-cli should set error status on nil key #447

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
it would be great if redis-cli would permit this:

redis-cli get "somekey" || echo "no such key"

and possibly drop the (nil) output, instead sending it to stderr. (of course, 
this could break existing scripts.)

Proper error status setting could render this point somewhat moot, however, by 
allowing something like this:

foo=$(redis-cli get "foo") || foo=""

Of course, that's still possible even without error status:
foo=$(redis-cli get "foo"); [ $foo == "(nil) ] && foo="";

Original issue reported on code.google.com by jamiesonbecker@gmail.com on 31 Jan 2011 at 1:16

GoogleCodeExporter commented 8 years ago
Nil is not an error per-se, a key not existing might be a good thing :-). 
Something like this for chaining would indeed be very cool, but there still 
needs to be a way to detect connection failure and so forth. Using the exit 
status for that (as is done currently) makes more sense in my opinion.

Original comment by pcnoordh...@gmail.com on 6 Mar 2011 at 7:30

GoogleCodeExporter commented 8 years ago
agreed - so here's a proposal:
error status:
0 True (change made or key found)
1 for False
2-255 connection error codes, etc.

Original comment by jamiesonbecker@gmail.com on 7 Mar 2011 at 9:54