Update fetch_groups_service.rb redis

This commit is contained in:
admin 2021-01-16 18:50:11 +00:00
parent 3344afbb3d
commit 8a3ed8d921

View File

@ -4,13 +4,19 @@ class FetchGroupsService < BaseService
def call(type)
if type == "featured"
body = Redis.current.get("groups:featuredgroups")
body = Redis.current.with do |conn|
conn.get("groups:featuredgroups")
end
if body.nil? || !body || body.empty?
@groupIds = Group.where(is_featured: true, is_archived: false).limit(150).all.pluck(:id)
Redis.current.set("groups:featuredgroups", @groupIds.join(","))
Redis.current.expire("groups:featuredgroups", 6.hours.seconds)
Redis.current.with do |conn|
conn.set("groups:featuredgroups", @groupIds.join(","))
end
Redis.current.with do |conn|
conn.expire("groups:featuredgroups", 6.hours.seconds)
end
@groupIds
else