On Apr 7, 4:53 pm, Salvatore Sanfilippo <
anti...@gmail.com> wrote:
> On Tue, Apr 7, 2009 at 10:46 PM, Mike <
msemin...@gmail.com> wrote:
>
> > I may be dense, but I cloned the git repository and the documentation
> > looks the same to me. Still have the -ERR response and also negative
> > integer replies, for some commands, to indicate errors.
>
> Hello!
>
> please check the html/ProtocolSpecification.html file
> this and the implementation itself are the only things in sync in this moment.
Hi Salvatore,
I'd appreciate your review of the following pattern for return values
as I would like to finalize the java interface for release:
Errors:
Any response from Redis beginning with a '-' will be treated as an
error and will cause an exception in the java client. Exception will
have, as its message any bytes from 1. (ex: "ERR no such key")
ALL methods throw exception (and this may change to an unchecked
exception once there is sufficient feedback), even methods that can't
normally fail, such as "ping", since:
ping
-ERR operation not permitted
This does *not* mean that value responses, such as Bulk or MultiBulk
that return responses with a '-' in offset 1 will be treated as
errors. These will return 'null'.
Return values:
1 - Status Code replies:
Commands returning Status Code will have return type of 'void'.
Error conditions, if any, are treated per the uniform error handling
above, by the throwing of an exception.
ex:
void ping () throws RedisException;
2 - Integer value replies:
a) Commands returning integer values with number semantics will have
return types of either int (or long where appropriate).
typical examples:
int llen (String key) throws ...
int lrem (String key, byte[] value, int count) throws ..
// we use long here since that is what unix epoch is represented by in
JVM
//
long lastsave () throws ...
b) Commands returning integer values with logical conditional
semantics will have return types of boolean.
// :0 -> false, :1 -> true
boolean void expire (String key, int ttl) throws ...
3 - Bulk and MultiBulk replies:
These methods will return null values for $-1 and *-1, respectively a
null byte[], and a null List<byte[]>.
$0, maps to a non-null string of length 0
*0, maps to a non-null List<byte[]> of size 0 (i.e. empty)
A List<byte[]> multibulk value can contain null members. For ex:
mget nosuchkey foo
*2
$-1
$3
bar
which maps to a List<byte[]> with list.get(0) returning null, list.get
(1) returning the byte[] for "bar".
----
Thanks in advance for reviewing this.
/Regards