diff options
author | ThibG <thib@sitedethib.com> | 2020-12-23 14:33:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-23 14:33:47 +0100 |
commit | 225c934a1b66e2fcbedbda7936666c1ca3c9a04b (patch) | |
tree | d71a57d5f5b6bd864ec11cc1c914a6c3b30ba612 /app/lib/feed_manager.rb | |
parent | 81f4c550b2ed305f39f344d10289b38625f70bf7 (diff) | |
parent | 537afa00f35dbaa98cbff284683317b411104a82 (diff) |
Merge pull request #1481 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/lib/feed_manager.rb')
-rw-r--r-- | app/lib/feed_manager.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index ebd25b398..ddd975c5f 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -279,6 +279,36 @@ class FeedManager end end + # Completely clear multiple feeds at once + # @param [Symbol] type + # @param [Array<Integer>] ids + # @return [void] + def clean_feeds!(type, ids) + reblogged_id_sets = {} + + redis.pipelined do + ids.each do |feed_id| + redis.del(key(type, feed_id)) + reblog_key = key(type, feed_id, 'reblogs') + # We collect a future for this: we don't block while getting + # it, but we can iterate over it later. + reblogged_id_sets[feed_id] = redis.zrange(reblog_key, 0, -1) + redis.del(reblog_key) + end + end + + # Remove all of the reblog tracking keys we just removed the + # references to. + redis.pipelined do + reblogged_id_sets.each do |feed_id, future| + future.value.each do |reblogged_id| + reblog_set_key = key(type, feed_id, "reblogs:#{reblogged_id}") + redis.del(reblog_set_key) + end + end + end + end + private # Trim a feed to maximum size by removing older items |