Redis how to store associative array? Set or Hash or List?

后端 未结 3 1833
孤独总比滥情好
孤独总比滥情好 2021-01-30 04:24

I\'m a bit confused with all the available storing options of Redis. I want to do something simple and I don\'t want to over engineer it. I\'m working with phpredis

3条回答
  •  一整个雨季
    2021-01-30 05:02

    In PHP you can just do

    $redis->set($key, json_encode($value));
    

    Then

    $value = json_decode($redis->get($key));
    

    Or use whatever serialization technique you prefer. JSON encode/decode was performant enough for me not to care.

提交回复
热议问题