Want to maintain a list of users through Redis.
1.redis provides list, set, hash map, which data structure to choose, save a PHP user object appropriate?
2. How do I maintain a user list with Redis? can be increased and reduced, can be viewed in quantity.
Reply content:
Want to maintain a list of users through Redis.
1.redis provides list, set, hash map, which data structure to choose, save a PHP user object appropriate?
2. How do I maintain a user list with Redis? can be increased and reduced, can be viewed in quantity.
If it is unordered, use set to store the user's unique ID, for example, SADD users {id}
and then use a hash map to store the user's various properties, such as HSET user_{id} name "Tom"
. So you can see the number of users in set, and then add and subtract in the set, the synchronization operation of the corresponding user in the hash line