use Cache.hash instead of Cache.sanitize
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class Cache
|
||||
def self.get_multi(keys, prefix)
|
||||
sanitized_key_to_key_hash = keys.map do |key|
|
||||
["#{prefix}:#{Cache.sanitize(key)}", key]
|
||||
["#{prefix}:#{Cache.hash(key)}", key]
|
||||
end.to_h
|
||||
|
||||
sanitized_keys = sanitized_key_to_key_hash.keys
|
||||
|
||||
@@ -14,8 +14,8 @@ class TagAliasCorrection
|
||||
|
||||
def statistics_hash
|
||||
@statistics_hash ||= {
|
||||
"antecedent_cache" => Cache.get("ta:" + Cache.sanitize(tag_alias.antecedent_name)),
|
||||
"consequent_cache" => Cache.get("ta:" + Cache.sanitize(tag_alias.consequent_name)),
|
||||
"antecedent_cache" => Cache.get("ta:" + Cache.hash(tag_alias.antecedent_name)),
|
||||
"consequent_cache" => Cache.get("ta:" + Cache.hash(tag_alias.consequent_name)),
|
||||
"antecedent_count" => Tag.find_by_name(tag_alias.antecedent_name).try(:post_count),
|
||||
"consequent_count" => Tag.find_by_name(tag_alias.consequent_name).try(:post_count)
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ class TagCorrection
|
||||
|
||||
def statistics_hash
|
||||
@statistics_hash ||= {
|
||||
"category_cache" => Cache.get("tc:" + Cache.sanitize(tag.name)),
|
||||
"post_fast_count_cache" => Cache.get("pfc:" + Cache.sanitize(tag.name))
|
||||
"category_cache" => Cache.get("tc:" + Cache.hash(tag.name)),
|
||||
"post_fast_count_cache" => Cache.get("pfc:" + Cache.hash(tag.name))
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -1183,7 +1183,7 @@ class Post < ApplicationRecord
|
||||
tags = "#{tags} -status:deleted".strip
|
||||
end
|
||||
|
||||
"pfc:#{Cache.sanitize(tags)}"
|
||||
"pfc:#{Cache.hash(tags)}"
|
||||
end
|
||||
|
||||
def fast_count(tags = "", options = {})
|
||||
|
||||
@@ -99,7 +99,7 @@ class Tag < ApplicationRecord
|
||||
if options[:disable_caching]
|
||||
select_category_for(tag_name)
|
||||
else
|
||||
Cache.get("tc:#{Cache.sanitize(tag_name)}") do
|
||||
Cache.get("tc:#{Cache.hash(tag_name)}") do
|
||||
select_category_for(tag_name)
|
||||
end
|
||||
end
|
||||
@@ -146,7 +146,7 @@ class Tag < ApplicationRecord
|
||||
end
|
||||
|
||||
def update_category_cache
|
||||
Cache.put("tc:#{Cache.sanitize(name)}", category, 1.hour)
|
||||
Cache.put("tc:#{Cache.hash(name)}", category, 1.hour)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -752,7 +752,7 @@ class Tag < ApplicationRecord
|
||||
if post_count < COSINE_SIMILARITY_RELATED_TAG_THRESHOLD
|
||||
delay(:queue => "default").update_related
|
||||
elsif post_count >= COSINE_SIMILARITY_RELATED_TAG_THRESHOLD
|
||||
key = Cache.sanitize(name)
|
||||
key = Cache.hash(name)
|
||||
cache_check = Cache.get("urt:#{key}")
|
||||
|
||||
if cache_check
|
||||
|
||||
@@ -20,7 +20,7 @@ class TagAlias < TagRelationship
|
||||
|
||||
module ClassMethods
|
||||
def clear_cache_for(name)
|
||||
Cache.delete("ta:#{Cache.sanitize(name)}")
|
||||
Cache.delete("ta:#{Cache.hash(name)}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user