[redis] More connection pooling changes

This commit is contained in:
Fosco Marotto
2021-01-17 17:36:20 -05:00
parent d2d381eb90
commit 002441af1f
11 changed files with 89 additions and 49 deletions

View File

@@ -10,11 +10,16 @@ class VerifiedSuggestions
def set(account_ids)
return if account_ids.nil? || account_ids.empty?
redis.setex(KEY, EXPIRE_AFTER, account_ids)
redis.with do |conn|
conn.setex(KEY, EXPIRE_AFTER, account_ids)
end
end
def get(account_id)
account_ids = redis.get(KEY)
account_ids = []
redis.with do |conn|
account_ids = conn.get(KEY)
end
if account_ids.nil? || account_ids.empty?
account_ids = Account.searchable
@@ -24,7 +29,7 @@ class VerifiedSuggestions
.local
.limit(MAX_ITEMS)
.pluck(:id)
set(account_ids) if account_ids.nil? || account_ids.empty?
else
account_ids = JSON.parse(account_ids)