Skip to content

Commit

Permalink
When list is deleted, remove feed from redis
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Dec 5, 2017
1 parent 82884ac commit 175a588
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/models/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = Redis.current.key(:list, id, 'reblogs')
reblogged_id_set = Redis.current.zrange(reblog_key, 0, -1)

redis.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

0 comments on commit 175a588

Please sign in to comment.