redis fixes

This commit is contained in:
Fosco Marotto 2021-01-16 14:43:11 -05:00
parent 1214b0664c
commit 2cdce808a3
3 changed files with 22 additions and 17 deletions

View File

@ -3,6 +3,7 @@
class Api::V1::TrendingHashtagsController < EmptyController class Api::V1::TrendingHashtagsController < EmptyController
def show def show
tags = ""
Redis.current.with do |conn| Redis.current.with do |conn|
tags = conn.get("admin_trending_hashtags") || "" tags = conn.get("admin_trending_hashtags") || ""
end end

View File

@ -114,16 +114,18 @@ class Group < ApplicationRecord
end end
def clean_feed_manager def clean_feed_manager
Redis.current.with do |conn|
reblog_key = FeedManager.instance.key(:group, id, 'reblogs') reblog_key = FeedManager.instance.key(:group, id, 'reblogs')
reblogged_id_set = Redis.current.zrange(reblog_key, 0, -1) reblogged_id_set = conn.zrange(reblog_key, 0, -1)
Redis.current.pipelined do conn.pipelined do
Redis.current.del(FeedManager.instance.key(:group, id)) conn.del(FeedManager.instance.key(:group, id))
Redis.current.del(reblog_key) conn.del(reblog_key)
reblogged_id_set.each do |reblogged_id| reblogged_id_set.each do |reblogged_id|
reblog_set_key = FeedManager.instance.key(:group, id, "reblogs:#{reblogged_id}") reblog_set_key = FeedManager.instance.key(:group, id, "reblogs:#{reblogged_id}")
Redis.current.del(reblog_set_key) conn.del(reblog_set_key)
end
end end
end end
end end

View File

@ -31,16 +31,18 @@ class List < ApplicationRecord
private private
def clean_feed_manager def clean_feed_manager
Redis.current.with do |conn|
reblog_key = FeedManager.instance.key(:list, id, 'reblogs') reblog_key = FeedManager.instance.key(:list, id, 'reblogs')
reblogged_id_set = Redis.current.zrange(reblog_key, 0, -1) reblogged_id_set = conn.zrange(reblog_key, 0, -1)
Redis.current.pipelined do conn.pipelined do
Redis.current.del(FeedManager.instance.key(:list, id)) conn.del(FeedManager.instance.key(:list, id))
Redis.current.del(reblog_key) conn.del(reblog_key)
reblogged_id_set.each do |reblogged_id| reblogged_id_set.each do |reblogged_id|
reblog_set_key = FeedManager.instance.key(:list, id, "reblogs:#{reblogged_id}") reblog_set_key = FeedManager.instance.key(:list, id, "reblogs:#{reblogged_id}")
Redis.current.del(reblog_set_key) conn.del(reblog_set_key)
end
end end
end end
end end