Reputation: 11
I'm trying to save sorted array to Redis, preserving it's order of keys (it's crucial)
[ 'abcdef' => value1, 'abcd' => value2, 'abc' => value3 ]
,and I need to restore it in the same order;
I tried hashes, but when I get the array back, it's realized unordered. For example:
[ 'abc' => value3, 'abcd' => value2, 'abcded' => value1 ]
I have some ideas about ZADD, but I can't figure out exactly, what I have to do.
Upvotes: 1
Views: 367
Reputation: 64
I don't understant you mean array: [ 'abc' => value3, 'abcd' => value2, 'abcded' => value1 ], I think this is a hash.
The array should be like: ['abc', 'abcd', 'abcded'], and if your want store in redis, you can parse array to string then store.
Upvotes: 1