Redis fixes

This commit is contained in:
Fosco Marotto 2021-01-16 14:38:01 -05:00
parent 8d48c3ce3d
commit 1214b0664c
3 changed files with 16 additions and 9 deletions

View File

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

View File

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

View File

@ -101,7 +101,11 @@ class AccountConversation < ApplicationRecord
end
def subscribed_to_timeline?
Redis.current.exists?("subscribed:#{streaming_channel}")
exists = false
Redis.current.with do |conn|
exists = conn.exists?("subscribed:#{streaming_channel}")
end
exists
end
def streaming_channel