diff --git a/app/logical/cache.rb b/app/logical/cache.rb index 44ce01dd1..329824bdf 100644 --- a/app/logical/cache.rb +++ b/app/logical/cache.rb @@ -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 diff --git a/app/logical/tag_alias_correction.rb b/app/logical/tag_alias_correction.rb index 5ce1c7a6f..11d6a8844 100644 --- a/app/logical/tag_alias_correction.rb +++ b/app/logical/tag_alias_correction.rb @@ -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) } diff --git a/app/logical/tag_correction.rb b/app/logical/tag_correction.rb index 618457b32..292dfecd5 100644 --- a/app/logical/tag_correction.rb +++ b/app/logical/tag_correction.rb @@ -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 diff --git a/app/models/post.rb b/app/models/post.rb index 8e512059e..e269e48ba 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 = {}) diff --git a/app/models/tag.rb b/app/models/tag.rb index d23cc1729..f87f139f8 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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 diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index 3a2a728e4..86c6b82cb 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -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