Benki β†’ All Posts

β‡  previous page next page β‡’
Matthias #

How do I access binary data using Vert.x-redis or Quarkus Redis Client?

Vert.x-redis provides the RedisAPI class to access most Redis functionality. The methods provided by RedisAPI only take Strings as arguments, which it encodes in UTF-8. With Quarkus you get to choose between RedisClient and ReactiveRedisClient, both of which mirror RedisAPI, again only containing String-based methods.

So how do you store binary strings?

With Vert.x-redis, use the send method on the Redis class, which is the lower-level interface underlying RedisAPI. Similarly, with Quarkus, instead of injecting a RedisClient or ReactiveRedisClient, inject the lower-level MutinyRedis:

@Inject
MutinyRedis mutinyRedis;

Uni<Void> set(String key, byte[] data) {
    return mutinyRedis
        .send(
            Request.cmd(Command.SET)
                .arg(key)
                .arg(data))
        .replaceWithVoid();
}

Uni<byte[]> get(String key) {
    return mutinyRedis
        .send(
            Request.cmd(Command.GET)
                .arg(key))
        .ifNotNull()
        .transform(Response::toBytes);
}

Racial justice, social justice, environmental justiceβ€”all good causes seem to be justice nowadays. Everything is a struggle between the condemned and the enforcers. Either you are an oppressor or you are one of the oppressed.

Is this a healthy way of looking at the world?

A tutorial on Z3. Z3 is a SAT solver. It is used as the underlying deduction engine in many applications that need a theorem prover.

A relational database browser that can export internally consistent row sets.

β‡  previous page next page β‡’