mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Implement a faster Discourse.cache
This is a bottom up rewrite of Discourse cache to support faster performance and a limited surface area. ActiveSupport::Cache::Store accepts many options we do not use, this partial implementation only picks the bits out that we do use and want to support. Additionally params are named which avoids typos such as "expires_at" vs "expires_in" This also moves a few spots in Discourse to use Discourse.cache over setex Performance of setex and Discourse.cache.write is similar.
This commit is contained in:
@@ -112,7 +112,7 @@ class EmailController < ApplicationController
|
||||
else
|
||||
|
||||
key = "unsub_#{SecureRandom.hex}"
|
||||
$redis.setex key, 1.hour, user.email
|
||||
Discourse.cache.write key, user.email, expires_in: 1.hour
|
||||
|
||||
url = path("/email/unsubscribed?key=#{key}")
|
||||
if topic
|
||||
@@ -125,7 +125,7 @@ class EmailController < ApplicationController
|
||||
end
|
||||
|
||||
def unsubscribed
|
||||
@email = $redis.get(params[:key])
|
||||
@email = Discourse.cache.read(params[:key])
|
||||
@topic_id = params[:topic_id]
|
||||
user = User.find_by_email(@email)
|
||||
raise Discourse::NotFound unless user
|
||||
|
||||
Reference in New Issue
Block a user