0

I am able to add & view the key value pairs through my restful API method invocations. response of restful api method

But after adding the key value pairs, when I try to list/ view them using redis-cli console, it is not listing any values. redis-cli results

As you can notice, in the console, it is listing some junk values for the **keys *** command (after adding new key/value via browser), but when I try to retrieve the key, it is showing up as empty.

What could be the reason for this? How to list the values properly in the console?

also attaching the restful api method definitions: restful api methods

1 Answer 1

5

The value you're seeing in the output of KEYS * is the java-serialized string user.

The first two bytes \xac\xed (hex: 0xACED) is the STREAM_MAGIC constant.

The next two bytes \x00\x05 (hex: 0x0005) is the STREAM_VERSION, version of the serialization protocol.

The next byte, t is 0x74 = TC_STRING meaning is a string object.

Finally \x00\x04 is the length of the string.

This protocol is described in the Object Serialization Stream Protocol, in 6.4.2 Terminal Symbols and Constants

You probably want to review your code as to why are the strings being java-serialized before reaching Redis. Probably it is because of the h: that shows in the screenshot.

On the meantime, you can do GET "\xac\xed\x00\x05t\x00\x04user" to inspect the value of your user key.

IDE behaviour

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much for the response, surely will get back to this discussion after reviewing your response. regarding the h in the screenshot, kindly note that it is a feature of intellij IDE wherein the IDE automatically tries to visually represent the expected parameters in this way against the actual ones. This will not impact the code in any way. (I have added the screenshot of the method definition/ signature in the body above)
If you're using Springboot with Redis. You should configure redis serialization to use Jackson to serialize your key/value. Another quick way is to just StringRedisTemplate instead of RedisTemplate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.