tag change notices: use cache instead of using redis directly.

This commit is contained in:
evazion
2019-08-22 23:24:17 -05:00
parent dfe2b831a3
commit 70e0d2fac2
4 changed files with 18 additions and 28 deletions

View File

@@ -1,18 +1,13 @@
module TagChangeNoticeService
extend self
def redis_client
::Redis.new(url: Danbooru.config.redis_url)
end
def get_forum_topic_id(tag)
redis_client.get("tcn:#{tag}")
Cache.get("tcn:#{tag}")
end
def update_cache(affected_tags, forum_topic_id)
rc = redis_client
affected_tags.each do |tag|
rc.setex("tcn:#{tag}", 1.week, forum_topic_id)
Cache.put("tcn:#{tag}", forum_topic_id, 1.week)
end
end
end