'Unable to view the byte formatted value from redis-cli
My requirement is that in redis db, keys should be stored as strings and values as byte array. And I am able to achieve the same in java using lettuce's RedisCodec. But when I view the value through reds-cli it appears to be in original string itself rather than the byte format. Following is the simple code I am trying with.
RedisURI redisURI = RedisURI.builder().withHost("localhost")
.withPort(6379)
.build();
RedisClient redisClient = RedisClient.create(redisURI);
RedisCommands<String, byte[]> redisCommands = redisClient.connect(RedisCodec.of(new StringCodec(), new ByteArrayCodec())).sync();
redisCommands.set("key", "value".getBytes(StandardCharsets.UTF_8));
System.out.println(redisCommands.get("key"));
Console O/p : [B@3bd7f8dc
redis-cli o/p:
127.0.0.1:6379> get key
"value"
I am using lettuce as redis client. I am unable to understand why the value I obtained from redis-cli is in string itself rather than the byte format.
Any help is appreciated. Thanks in advance.
Solution 1:[1]
I believe that below answer helps you to understand reading byte value from redis-cli.
How to read Redis binary values in redis console
Here is also detail explaniton of redis-cli. I hope it makes sense. https://redis.io/docs/manual/cli/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alper Derya |
