Class RedisConnection
java.lang.Object
com.codename1.backend.kv.RedisConnection
One connection to a Redis server speaking RESP2, the protocol every Redis, Valkey and KeyDB release understands.
RedisKeyValueStore keeps a pool of these and lends one per call; ask it for
a RedisKeyValueStore.dedicated() connection for a command that blocks --
XREADGROUP ... BLOCK, BLPOP, SUBSCRIBE -- so it never holds a pooled one.
Replies come back as Java values: a simple string as String, a bulk string
as byte[], an integer as Long, an array as Object[], a nil as null. An
error reply is thrown as a RedisException, and leaves the connection usable.
Any other failure leaves it in an unknown state; the caller closes it.
Not thread safe.
-
Method Summary
Modifier and TypeMethodDescriptioncall(byte[][] args) Sends one command whose arguments are already bytes and answers its reply.Sends one command and answers its reply.voidclose()Closes the socket.voidflush()Sends whatwrite(byte[][])staged.booleanisBroken()Whether a failure other than an error reply happened on this connection, after which it must not be reused.read()Reads the next reply.voidsetReadTimeout(int millis) Changes how long a reply may take; zero waits forever.voidwrite(byte[][] args)
-
Method Details
-
isBroken
public boolean isBroken()Whether a failure other than an error reply happened on this connection, after which it must not be reused. -
setReadTimeout
Changes how long a reply may take; zero waits forever.- Throws:
IOException
-
call
Sends one command and answers its reply.- Throws:
IOException
-
call
Sends one command whose arguments are already bytes and answers its reply.- Throws:
IOException
-
write
-
flush
-
read
Reads the next reply. An error reply is thrown after it has been read whole, so the connection stays in step.- Throws:
IOException
-
close
public void close()Closes the socket. Never throws.
-