diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-12-05 23:20:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-05 23:20:27 +0100 |
commit | d68868ca14d92b8a9a94cf8412c8aca570b566d4 (patch) | |
tree | 2ae3f98c5f330c6c21202b359f5f78153657c117 /app/models | |
parent | e20895f251d28b3631b1f5768302517a5b687b04 (diff) |
Lists redis clean-up (#5886)
* When list is deleted, remove feed from redis * Clean up list feeds of inactive users
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/list.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/list.rb b/app/models/list.rb index 5d7ba0065..910864b26 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -19,4 +19,23 @@ class List < ApplicationRecord has_many :accounts, through: :list_accounts validates :title, presence: true + + before_destroy :clean_feed_manager + + private + + def clean_feed_manager + reblog_key = FeedManager.instance.key(:list, id, 'reblogs') + reblogged_id_set = Redis.current.zrange(reblog_key, 0, -1) + + Redis.current.pipelined do + Redis.current.del(FeedManager.instance.key(:list, id)) + Redis.current.del(reblog_key) + + reblogged_id_set.each do |reblogged_id| + reblog_set_key = FeedManager.instance.key(:list, id, "reblogs:#{reblogged_id}") + Redis.current.del(reblog_set_key) + end + end + end end |