'How to update Redis list item?
I'm currently researching high scalable web site architectures,nearly all of the articles i've read say that Redis is very good choice for a timeline(facebook,twitter like) architecture.So let's suppose that I'm building a new social network and I want to save last 500 feeds of each user with Redis,I'm just curious about what will happen when a user delete a feed which is in last 500 feeds? I couldn't find any information about updating Redis list item,if there is no such a thing in Redis how can it be a very good choice?
Solution 1:[1]
Using the Lset command will allow you to update a list item: https://redis.io/commands/lset
Solution 2:[2]
Instead of a list, a better redis structure to use would be the sorted set, assuming you want to maintain ordering of the last 500 feeds.
To add new entry, you can use the command ZADD user_id:feeds time_in_epoch feed_id. The time_in_epoch would be score for sorting the set & will maintaining a ordering on the feeds.
To delete a feed for a user, ZREM user_id:feeds feed_id.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Keith Holliday |
| Solution 2 | zodvik |
