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
def show
tags = ""
Redis.current.with do |conn|
tags = conn.get("admin_trending_hashtags") || ""
end

View File

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

View File

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