I try to implement twitter like activity feed. It seems like many people suggest to keep activities (e.g., tweet) in main database and activity IDs in Redis. For example
mysql.insert(activity)
for f in followers
redis.lpush("feed" + f.id, activity.id)
When a user deletes the activity, a simple solution is to delete activity from every followers.
mysql.delete(activity)
for f in followers
redis.lrem("feed" + f.id, 1, activity.id)
The problem is that if a user deletes an activity just after the creation, the above code blocks might run in parallel. In some case, deleting block might run earlier than inserting block and activity ID is not deleted Redis. How can I reliably delete activities?
Aucun commentaire:
Enregistrer un commentaire