Java client
Package: io.github.salihcantekin:ruvio-client on Maven Central · Source on GitHub
Install
Section titled “Install”Maven coordinates:
<dependency> <groupId>io.github.salihcantekin</groupId> <artifactId>ruvio-client</artifactId> <version>0.1.0</version></dependency>Published on Maven Central. To use the repository version instead, run mvn install in this directory.
Packages
Section titled “Packages”| Package | Contents |
|---|---|
io.github.salihcantekin.ruvio |
RuvioClient, RuvioAsync, Pipeline, Transaction, RuvioPubSub, RuvioOptions, codecs, exceptions |
...ruvio.args |
Option builders (SetOptions, XAddArgs, ZRangeArgs, …) and small enums |
...ruvio.model |
Result types (ScoredValue, StreamEntry, ScanResult, …) |
...ruvio.commands |
The typed command families the front-ends inherit |
...ruvio.internal |
Protocol, connection, multiplexing, cluster routing. Not supported API. |
Quick start
Section titled “Quick start”import io.github.salihcantekin.ruvio.RuvioClient;import io.github.salihcantekin.ruvio.RuvioLock;import io.github.salihcantekin.ruvio.args.SetOptions;
try (RuvioClient<String, String> c = RuvioClient.connect("127.0.0.1", 6379)) { c.set("greeting", "hello"); String v = c.get("greeting"); // null when missing
CompletableFuture<Long> n = c.async().incr("hits"); // same connection, async API c.set("k", "v", SetOptions.ex(60).ifAbsent()); // SET k v EX 60 NX -> false if it existed
try (RuvioLock<String> lock = c.tryLock("job:42", 10_000)) { // null if held elsewhere if (lock != null) { /* critical section */ } } // DELEX job:42 IFEQ token}Binary-safe: c.binaryValues() / c.withCodecs(RuvioCodec.BYTES, RuvioCodec.BYTES).
Server errors are RuvioServerException (code() = WRONGTYPE, NOSCRIPT, …), socket failures
RuvioConnectionException (the next call reconnects; nothing is replayed automatically).
Anything without a typed method: c.async().execute("COMMAND", arg, ...).
Design
Section titled “Design”- One socket shared by all threads. A caller encodes its frame straight into the shared output
buffer under a short lock and appends its pending future to a FIFO ring in the same critical
section. When nothing is in flight the caller writes the buffer itself (serial calls are sent at
once, no thread hand-off); otherwise the writer thread drains everything queued in a single
write(no timers, no batch-fill wait). - A reader thread reads into one reusable buffer, decodes each reply in place with the request’s decoder and completes futures in FIFO order. Scalars (integer, OK, nil, bulk) allocate only the returned value. Incomplete replies rewind and wait for more bytes.
- Command names are
static final byte[]complete bulk fragments ($3\r\nGET\r\n, classCmd, generated bytools/generate.py). Integers are written as ASCII digits directly into the buffer. Fixed-shape hot commands (GET, SET, INCR, HGET, … ) encode with no intermediate objects; option-heavy commands go through a small privateArgsbuffer (one extra copy). - The per-call allocation of a typed command is the
CompletableFutureitself plus the decoded value. RuvioAsync(CompletableFuture) is the base API; the blocking facadeRuvioSyncCommands(generated from it) calls the async method and waits. Futures complete on the reader thread, so keepthenApplycallbacks short.- Virtual threads: not used. Plain platform reader/writer threads are the right fit for one socket; blocking calls from virtual threads work as they park on the future.
pipeline()buffers locally and sends one write onflush()/sync().multi()runs MULTI/EXEC on a pooled dedicated connection.pubSub(listener)is a separate connection that resubscribes after a drop.dedicated()gives a second client for blocking commands (BLPOP, BLMOVE, XREAD BLOCK,fillgetWait), because they hold the shared socket.- Two codec parameters:
RuvioClient<K, V>(defaultString/String, UTF-8;byte[]available). Hash fields and stream field names use the key codec; members and field values the value codec.
Coverage
Section titled “Coverage”All 300 commands of docs/compatibility-matrix.json have a typed method (CoverageTest maps every
matrix name to a method and fails otherwise), including the Ruvio options: SET ... IFEQ, SET ... IFGT/IFLT (setIfGreater, setIfLess),
INCRBY ... MAX, FILLGET ... WAIT, FILLSET ... SWR, GETEX, DELEX key IFEQ v, LPUSHCAP/RPUSHCAP,
BF.*, JSON.* incl. JSON.INDEX/FIND, IDEM BEGIN/COMPLETE/ABORT, LEASE/RELEASE, SEMAPHORE, ONCE,
TAKE, TRANSFER/HTRANSFER, SETV, CHANGES, LIMIT. Not typed (use execute): FLUSHDB ASYNC, HELLO ... SETNAME.
Typed keywords
Section titled “Typed keywords”Keywords are enums that write pre-encoded bytes (no per-call string encoding); the older boolean and string forms still work.
c.linsert("list", InsertPosition.BEFORE, "pivot", "value"); // instead of linsert(key, true, ...)c.bitcount("bits", 0, 7, BitUnit.BIT); // instead of the boolean overloadc.scan("0", ScanArgs.count(100).type(KeyType.HASH)); // instead of .type("hash")c.georadius("geo", 13.4, 52.5, 10, GeoUnit.KM, GeoSearchArgs.options().order(GeoOrder.ASC));c.xtrim("events", StreamTrim.maxLen(1000)); // XTRIM events MAXLEN = 1000c.xadd("events", XAddArgs.builder().trim(StreamTrim.minId("1700000000000-0", StreamTrim.Mode.APPROXIMATE)), Map.of("k", "v"));c.info(InfoSection.MEMORY_BREAKDOWN); // INFO memorybreakdownc.clientList(ClientType.PUBSUB); // CLIENT LIST TYPE pubsubc.zrangebyscore("board", RangeBounds.NEGATIVE_INFINITY, RangeBounds.exclusive(100));c.bitfield("bits", BitFieldArgs.builder().get(BitFieldArgs.Type.unsigned(8), 0));TTL on create
Section titled “TTL on create”Counters and other keys that are created by their first write can get their deadline in the same command. The Duration overloads send EX for a whole number of seconds and PX otherwise; the deadline is set only when the call creates the key, and an existing key keeps its own. A zero, negative or too large duration throws IllegalArgumentException before anything is sent.
c.incr("hits:1.2.3.4", Duration.ofMinutes(1)); // INCR key EX 60c.incrbyMax("quota:u1", 1, 100, Duration.ofMillis(1500)); // INCRBY key 1 PX 1500 MAX 100c.hincrby("h", "f", 1, ttl); c.zincrby("z", 1, "m", ttl); c.setbit("b", 7, true, ttl);c.zadd("z", ZAddArgs.builder().ttl(ttl).nx(), Map.of("a", 1.0)); // also XAddArgs, BfInsertArgsc.geoadd("g", false, false, false, ttl, GeoValue.of(13.36, 38.11, "p"));c.jsonSet("j", "$", "{}", ttl); // also jsonSetNx, jsonSetXxAlso: incr, decr, incrby, decrby, incrbyfloat take a trailing Duration. expire, pexpire, expireat and pexpireat accept an ExpireCondition (NX, XX, GT, LT; ALWAYS sends no flag). A key without a deadline counts as infinite, so GT never applies to it and LT always does; a failed condition returns false.
Helpers
Section titled “Helpers”| Helper | Built on |
|---|---|
tryLock / lock(key, ttl, wait) -> RuvioLock (renew, isHeld, close) |
SET NX PX, SET IFEQ PX, DELEX IFEQ (never deletes another owner’s lock) |
tryLease -> RuvioToken (fencing token()), tryAcquirePermit |
LEASE/SEMAPHORE + RELEASE |
rateLimit(key, max, window) -> RateLimitResult(allowed, remaining) |
LIMIT |
limitSliding(key, max, windowMs), limitTokens(key, capacity, refillMs, cost) -> remaining or null |
LIMIT ... SLIDING, LIMIT ... TOKENS |
limitSlidingWithRetry(...), limitTokensWithRetry(...) -> LimitOutcome(allowed, remaining, retryAfterMillis) |
LIMIT ... WITHRETRY |
getOrCreate(key, ttl, factory) (+ stale-while-revalidate form) |
FILLGET/FILLSET; losers poll plain FILLGET with backoff (WAIT would park the shared socket) |
idempotent(key, fingerprint, ttl, wait, action) |
IDEM BEGIN/COMPLETE |
idempotent(key, fingerprint, ttl, wait, action, abortOnError) |
IDEM BEGIN/COMPLETE/ABORT: with abortOnError set (the overload above is false), an exception from action sends ABORT and is rethrown, so a retry runs the action again at once instead of finding the key pending until ttl; a failed abort is ignored. Use it only when a failed action did not take effect or is safe to run again |
idemAbort(key, fingerprint, owner) -> boolean |
IDEM ABORT: true when the pending record of that owner and fingerprint was removed; false for a missing key, a completed record (its result is never removed) or another owner. Abort only when the work did not take effect or is safe to run again; a retry after an abort runs it again |
scanIterable/scanStream, hscan*, sscan*, zscan* |
lazy cursor-driven pages |
jsonSetObject/jsonGetObject/jsonMgetObjects + setJsonCodec(JsonCodec) |
JSON.*; the JDK has no JSON, so plug in Jackson/Gson/… through the 2-method JsonCodec (default: String passthrough) |
pushRecent / recent |
LPUSHCAP |
seenBefore / mightContain |
BF.MADD / BF.MEXISTS |
Cluster
Section titled “Cluster”RuvioClient<String, String> c = RuvioClient.connect( RuvioOptions.builder().host("127.0.0.1").port(7000).cluster(true).build()); // seed = any nodec.isCluster(); // false when the seed answered "cluster mode is disabled": plain standalone clientc.nodeAddresses(); // ["127.0.0.1:7000", ...] nodes that own slotsc.onNode("127.0.0.1:7001").dbsize(); // per-node commands (DBSIZE, KEYS, FLUSHDB, INFO, SCAN ...)cluster(true) asks the seed for CLUSTER SLOTS on connect and builds a 16384-entry slot table. If the
server is not in cluster mode (it answers with an error) nothing changes: the client is the standalone
client, including database(n). In cluster mode the database option is ignored (the server only has
database 0). Every node gets its own lazily opened multiplexed connection with the same fast path as
the standalone one; the standalone path itself only pays one router == null check per command.
How it routes (the key table covers all 300 matrix commands, CoverageTest fails when one has no rule):
| Command shape | Routing |
|---|---|
single key (GET, SET, HSET, LEASE, LIMIT, FILLGET, IDEM, BF.*, JSON.*, XADD, SPUBLISH by channel, …) |
node owning slot(key); {hashtag} aware, hashed in place from the encoded frame |
keyless (PING, INFO, PUBLISH, CLUSTER, JSON.INDEX, JSON.FIND, CHANGES, SCRIPT, …) |
any node (the seed while its connection is up) |
several keys, same slot (RENAME, SUNION, LMOVE, BLPOP, BITOP, SINTERCARD, ZUNIONSTORE, EVAL/FCALL with numkeys, XREAD ... STREAMS, GEOSEARCHSTORE, GEORADIUS ... STORE, JSON.MGET, PFMERGE, …) |
the shared slot’s node, using the real key lists |
MGET, MSET, DEL, UNLINK, EXISTS, TOUCH over several slots |
split per slot, each part sent to its owner, all concurrently, replies re-assembled in the caller’s order (null for a missing MGET key, DEL/EXISTS/… counts summed) |
| any other cross-slot command | fails at once with RuvioServerException (code CROSSSLOT); nothing is sent |
The split is per slot, not per node, because this server (like Redis) refuses a multi-key command whose
keys are in different slots even when one shard owns them all. A big split MGET is therefore many small
pipelined commands; use {hashtag} keys to keep related keys in one slot.
- MOVED: that one slot is pointed at the node named in the reply and the command is sent there; a command
follows at most 3 MOVED redirects, and the 4th MOVED is returned to the caller (no redirect loops). The whole
table is re-read with
CLUSTER SLOTSonly when the named node is unknown, or from the second MOVED for the same command on; the retry still goes to the node the MOVED named. The retry runs on a small background thread, never on a connection reader thread. The router keeps a copy of each command’s frame for this (about 100 bytes allocated per routed command: the request object and the copy). - ASK:
ASKINGand the command are sent to the named node in one write (an unknown node is opened first), the+OKis dropped and the command’s reply is returned; the slot table is not changed, so the next command for the slot still goes to its owner. ASK and MOVED share the 3-redirect budget. - TRYAGAIN: the command is sent again, routed by the current slot table, at most 7 times after waits of 5, 10, 20, 40, 80, 160 and 320 ms (635 ms in all; scheduled on the background thread, never a sleep); the error is returned after the 7th retry.
- Connection loss: only commands in flight on that node fail (
RuvioConnectionException); nothing is replayed, the other nodes keep working, and the node’s connection reopens with its next command. - Pipelines (
pipeline()): commands are routed when queued and grouped per node;flush()sends one write per node and every future still completes with its own reply, so results come back in the caller’s order. A node that cannot be reached fails only its group. - Transactions (
multi()): bound to the node and slot of the first key (orWATCH); a command orWATCHwith a key in another slot throwsCROSSSLOTand is not queued. - Blocking commands (
BLPOP,BLMOVE,XREAD BLOCK,FILLGET WAIT): usededicated(); in cluster mode it is a cluster client of its own, so the blocking call holds a connection to the owning node, not the shared one. - Scan family:
scanIterable/scanStreamwalk the nodes one after the other (each node has its own cursor) and see every key. A singlescan(cursor)call only covers the node it lands on (useonNode(...)per node for manual paging).hscan/sscan/zscanroute by key.KEYS,DBSIZE,FLUSHDBare per node. - Pub/Sub:
SUBSCRIBE/PSUBSCRIBErun on the seed connection andPUBLISHgoes to the seed node too, which is why a publish from the same client reaches its subscribers; this server does not broadcast classic publishes between nodes.SSUBSCRIBE/SPUBLISHare routed by channel slot: the subscriber opens one extra connection per node and subscribes one slot per command. - Helpers (locks, leases, semaphores, rate limit,
getOrCreate, idempotency, capped list, Bloom, typed JSON) only issue single-key commands, so they work unchanged;ClusterLiveTestruns them on the cluster. CLUSTERDOWNhandling: not implemented (ASKredirects andTRYAGAINretries are, see above). Reads from replicas: see below.
Durable replies
Section titled “Durable replies”RuvioOptions.Builder.durability(replicas) or durability(replicas, timeoutMillis) makes the server hold every reply of a connection until that many replicas have the earlier writes on disk. Every connection the client opens (reconnects, Pub/Sub, and the per-node connections of a cluster client) sends CLIENT DURABILITY REPLICAS n [TIMEOUT ms] after its other connect commands, and the connect fails if the server refuses (for example without replication). Nothing is sent by default. After the timeout (5000 ms unless set) the replies of the batch become NOREPLICAS errors and the writes stay applied. clientDurability(n) / clientDurability(n, timeoutMillis) set it on one connection; 0 turns it off.
RuvioOptions options = RuvioOptions.builder().host("10.0.0.1").durability(1, 5000).build();Reads from replicas
Section titled “Reads from replicas”RuvioOptions.Builder.readPolicy(ReadPolicy) sets where a cluster client sends read-only commands. A standalone
connection ignores it.
RuvioOptions options = RuvioOptions.builder() .host("10.0.0.1").cluster(true) .readPolicy(ReadPolicy.PREFER_REPLICA) .build();PRIMARY(default): every command goes to the slot’s primary, as before. No replica connection is opened.PREFER_REPLICA: reads go to a replica of the slot’s shard when one is known and reachable, else to the primary.REPLICA: reads go to a replica; with none known or reachable they fail with aRuvioException(“no replica …”).
Replication is asynchronous, so a read from a replica may miss recent writes, including your own.
- Replicas come from
CLUSTER SLOTS(listed after the primary). Each time the slot map loads, the client picks one replica per primary at random and keeps it until the next load. Each replica connection sendsREADONLYright after it is opened. - A read is a command the server flags
readonlyand not blocking (GET,HGETALL,ZRANGE, …). Writes, keyless commands, transactions, Pub/Sub, scans and blocking commands go to the primaries.MGET/EXISTS-style calls that split by slot send each part by the same rule. - A pipeline goes to replicas only when every command in it is a read; otherwise the whole pipeline goes to the primaries as before.
- A replica that cannot be opened, or answers
LOADING, is skipped until the next slot map load. UnderPREFER_REPLICAthe read goes to the primary (aLOADINGread is sent again there); underREPLICAthe call fails. A connection that drops after a command was sent still fails the command; nothing is replayed. ReplicaReadsFakeTestcovers the routing against scripted nodes;ReplicaReadsLiveTestruns againstRUVIO_REPLICATED_ADDR/RUVIO_REPLICA_ADDR(set byscripts/run_with_servers.sh) and skips without them.MultiNodeLiveTestfollowsMOVEDacross a two-node cluster (RUVIO_MULTINODE_A_ADDR,RUVIO_MULTINODE_B_ADDR,RUVIO_MULTINODE_STALE_ADDR, set byscripts/run_with_servers.sh) and skips without them.
Seed addresses
Section titled “Seed addresses”seeds(...) takes host:port strings (an IPv6 address as [::1]:6379) and replaces host/port; without it
host and port work as before.
RuvioOptions options = RuvioOptions.builder() .seeds("10.0.0.1:6379", "10.0.0.2:6379", "[::1]:6379") .build();RuvioClient<String, String> client = RuvioClient.connect(options);- Connect: the seeds are tried in order, one connect attempt each, and the first that answers is kept. A seed
that cannot be reached is skipped; a refused
AUTHorSELECTstops at once. When none answers, the last connect error is thrown. - Standalone reconnect: each reconnect attempt tries every seed once, starting with the seed after the
address that dropped and ending with it. The command that hit the drop still fails. A
pubSub(...)subscriber opened later starts at the address the command connection is on. - Cluster:
CLUSTER SLOTScomes from the first reachable seed. A slot map reload asks the nodes that have an open socket first; when none answers it opens every other known node and then every seed, one connect attempt each, until one returns a slot map. A node that cannot be opened again triggers that reload and the command goes to the owner the new map names; a keyless command goes to the first reachable node of the new map. Seeds are not asked while the known nodes answer, so routing is unchanged. Pipelines are not re-routed: a group whose node cannot be opened fails, as before.
Retry policies of your own
Section titled “Retry policies of your own”RuvioErrors sorts what a call throws, for a retry policy of your own (resilience4j, Failsafe, a loop).
The client already follows MOVED/ASK, waits out TRYAGAIN during a slot move and finds a new primary after
a failover; these judge what still reaches you. A CompletionException or ExecutionException from the async
API is judged by its cause.
RuvioErrors.isTransient(e): trying again later can succeed. True forRuvioConnectionException,RuvioTimeoutException(no reply within the command timeout) andLOADING,MASTERDOWN,CLUSTERDOWN,TRYAGAIN,READONLYandNOREPLICAS; false forWRONGTYPE,OOM, syntax errors and an interrupted or cancelled wait.RuvioErrors.mayHaveRun(e): the failed call may have changed data. False only for a server error reply (the server refused the command), exceptNOREPLICAS: the write was applied and only the replica confirmation timed out. A failed connection or a timeout may have run.
Repeat a write only when it is safe to repeat or did not run:
RetryConfig config = RetryConfig.custom() .maxAttempts(3) // INCR is not safe to repeat: retry it only when it surely did not run. .retryOnException(e -> RuvioErrors.isTransient(e) && !RuvioErrors.mayHaveRun(e)) .build();long visits = Retry.of("visits", config).executeSupplier(() -> client.incr("visits"));For a read, isTransient alone is enough.
Following a failover
Section titled “Following a failover”A standalone client with at least two seeds, or with a coordinator name, finds the primary again after a failover
instead of staying on a node that is now a replica (the shared contract is in docs/CLIENT_BEHAVIOR.md, “Following a
failover”). A cluster client keeps its MOVED/ASK rules and does not use any of this.
RuvioOptions options = RuvioOptions.builder() .seeds("10.0.0.1:6379", "10.0.0.2:6379") .followPrimary(true) // the default; false returns READONLY and keeps the plain seed order // .sentinelMaster("main") // the seeds are coordinators: SENTINEL get-master-addr-by-name main .build();- On reconnect: each attempt runs one round: every seed is asked
ROLEon a short-lived socket (connect,AUTH, one command, one reply; bounded by the smaller ofconnectTimeoutMillisandcommandTimeoutMillis), a replica’s reported primary is asked once too, and the client connects to the node that answersmaster. With none found, or when opening it fails with an I/O error, the plain seed order applies. The command that hit the drop still fails. - On
READONLY(the error text isREADONLYalone or followed by a space): the client runs up to 8 rounds (waits of 100 ms doubling to 2 s, on a background thread, never on a reader thread), avoiding the address that answered while it still saysmaster(once it says it is a replica, a later round takes it when it is promoted), moves the shared connection to the primary it finds, and sends the refused command once more. The second reply, a secondREADONLYincluded, is the result; there is never a third send. With no primary the originalREADONLYerror is returned and the connection stays. Other errors (LOADING,MASTERDOWN,NOREPLICAS) and I/O errors are never retried. - Not retried: commands of a
pipeline()(theREADONLYreply is returned at its index and nothing follows) and of amulti()transaction (its queued commands are lost with the socket, so the error is returned; the shared connection still moves to the primary, so the next command works). Transactions run on their own sockets here, so aMULTIsent by hand withexecuteon the shared connection is not tracked. - Coordinator name: with
sentinelMaster(name)the first connect and every round ask each seed in orderSENTINEL get-master-addr-by-name name, confirm the named address withROLE, and fail the connect with aRuvioExceptionnaming the master when no coordinator names a primary. The sameAUTHcredentials go to coordinators and data nodes. - Cost: while the connection is healthy nothing is sent and nothing is checked on the success path. A client that follows keeps each command’s encoded bytes in a per-thread scratch array (the way the cluster path does, no copy per command) and uses a request object that can hold them; a client with one address does not.
FollowFailoverFakeTest runs scripted nodes; FailoverLiveTest runs on the pair scripts/run_with_servers.sh starts
(RUVIO_FAILOVER_ADDRS and RUVIO_FAILOVER_REPLICATION, comma separated, primary first) and skips without them.
Plain TCP is the default. tls() turns TLS on for every socket the client opens (first connect, reconnects, shards, replicas, Pub/Sub and failover probes), trusting the JVM’s default certificates. The certificate chain and the host name are always verified.
RuvioOptions options = RuvioOptions.builder() .host("cache.internal") .tls(RuvioTls.context(Path.of("ca.pem"), null, null)) .build();RuvioTls.context(caPem, clientCertPem, clientKeyPem) builds the context from PEM files: caPem trusts only your private CA (null keeps the JVM’s certificates), and the client certificate chain and an unencrypted PKCS#8 key (BEGIN PRIVATE KEY) answer a server that demands mutual TLS (tls_client_auth). Pass any SSLContext to tls(SSLContext) instead if you manage key stores yourself. tlsServerName(name) is the name the certificate carries when you connect by IP address. tlsInsecure() accepts any certificate and skips the host name check, which removes the protection against someone in the middle: use it for a throwaway test only. The handshake is part of the connect (bounded by connectTimeoutMillis), so a refused certificate fails the connect with a RuvioConnectionException. Measured: the live TLS tests (TlsLiveTest); the latency TLS adds: not measured.
Tests and benchmark
Section titled “Tests and benchmark”mvn -q test # unit tests; live tests are skippedRUVIO_TEST_ADDR=127.0.0.1:17104 mvn -q test # all; uses logical DB 9 (and 10, 11, 0 for a few) with FLUSHDBRUVIO_TEST_ADDR=127.0.0.1:17104 mvn -q test -Dtest=BenchTest -DexcludedGroups=none # few-second benchmarkRUVIO_CLUSTER_ADDR=127.0.0.1:17320 RUVIO_TEST_ADDR=127.0.0.1:17323 mvn -q test # + cluster live testsRUVIO_CLUSTER_ADDR=127.0.0.1:17320 RUVIO_TEST_ADDR=127.0.0.1:17323 mvn -q test -Dtest=ClusterBenchTest -DexcludedGroups=noneCluster tests: ClusterUnitTest (slot table, hashtags, key extraction, split/reassembly, MOVED (up to 3, reloads), no
replay after a drop, pipelines, transactions, standalone fallback; scripted fake servers, always runs),
ClusterLiveTest (needs RUVIO_CLUSTER_ADDR = any shard of a 3-shard port_mode = "per-shard" server:
spread over all shards, CLUSTER KEYSLOT agreement, cross-slot MGET/MSET/DEL order, pipeline order, forced
stale slot table, transactions, helpers, scan, shard pub/sub, dropped node connection, concurrency) and
ClusterFallbackLiveTest (cluster(true) against a plain server, uses RUVIO_TEST_ADDR).
Notes: JSON.INDEX works on database 0 only, so that one test uses database 0 with unique names.
Cluster topology commands (CLUSTER SLOTS …) need a server in per-shard cluster mode; against a
standalone server the test asserts the typed “cluster mode is disabled” error and only runs the success
path when RUVIO_TEST_CLUSTER=1 (not verified here).
Local numbers (4 vCPU Linux container, JDK 21, loopback, one shared connection, 256 B values, single run each, not release evidence): encode SET ~35-42 ns, GET ~21-29 ns, INCRBY ~62-68 ns (no allocation); parse bulk 256 B to String ~80-135 ns, integer ~16-19 ns, 10-element string array ~230-500 ns. Live blocking GET/SET: 1 thread ~17-19k ops/s, 16 threads ~110-118k, 64 threads ~185-210k; pipeline of 100 GET ~0.75-0.9M ops/s.
Cluster numbers (ClusterBenchTest, same machine, shared with other jobs at load ~6 on 4 vCPUs, so noisy;
1.5 s per figure, 256 B values, 4096 keys): routing one GET locally (parse + hash + table lookup + frame
copy, no socket) ~100-135 ns on top of ~30 ns of encoding, ~103 bytes allocated per command. Standalone client
on a 1-shard server: GET 1/16/64 threads ~19k/91k/139k ops/s, SET ~19k/86k/129k, pipeline x100 GET ~0.80M.
Cluster client on the 3-shard server: GET ~17k/76k/114k, SET ~18k/79k/124k, pipeline x100 GET (grouped per node)
~0.79M. Routing overhead isolated on one node of the same 3-shard server with the same keys (16 threads):
unrouted onNode view GET 108k / SET 102k vs routed cluster client GET 106k / SET 99k (about 2 %, inside
the noise). The 3-shard server itself shares the 4 vCPUs with the benchmark, so cluster-vs-standalone totals say
little about scaling; they are not release evidence.
Not done / not verified
Section titled “Not done / not verified”- Cluster:
CLUSTERDOWNretries, adding or removing nodes while running (the table is refreshed on MOVED only, there is no periodic refresh), and a cluster-wideDBSIZE/KEYS/FLUSHALL(useonNode) are not implemented. Cluster mode was only exercised against the 3-shard Ruvio server (one process,port_mode = "per-shard"), not against a Redis Cluster. - No automatic retry or replay of commands after a socket drop;
maxInFlight(default 16384) bounds outstanding replies per connection. - Allocation counts for parsing/encoding were reasoned from the code, not measured with an allocation profiler.
- Older server builds differed from the matrix text in places (
SUNIONunsorted; a command refused while queued in MULTI did not abort EXEC). Both are fixed in the server.EXPIRE key 0deletes the key, as Redis does. - Replication, TLS, ACL-file save/load success paths (no
acl_fileconfigured on the test server) not verified.