简体   繁体   中英

How to list the data using redis-cli console?

I am able to add & view the key value pairs through my restful API method invocations. restful api方法的响应

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 结果

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: 宁静的API方法

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 行为

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM