summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2017-12-04 16:47:15 +0100
committerJacob Vosmaer <jacob@gitlab.com>2017-12-04 16:47:15 +0100
commit2797e8dbec22f04a7eae8eff0e9c0351f7e511ad (patch)
tree90a1a934b7cca0d68b7e198bd97c7bddf168f1b1
parent2d7426d94c43d4d3ce69c0688cb860aa605bdb51 (diff)
downloadgitlab-ce-repository-exists-cache-short-ttl.tar.gz
-rw-r--r--app/models/repository.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 0707412829d..999db3aa313 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -507,9 +507,10 @@ class Repository
# (via Rails.cache). A false negative from 'exists?' has a severe impact
# on user experience. By using a shorter expiry time we limit the impact
# of such a fault.
- Gitlab::Redis::Cache.with { |redis| redis.set(exists_cache_key, [@exists].to_json, ex: EXISTS_CACHE_TTL) }
+ encoded_value = @exists ? '1' : '0'
+ Gitlab::Redis::Cache.with { |redis| redis.set(exists_cache_key, encoded_value, ex: EXISTS_CACHE_TTL) }
else
- @exists = JSON.parse(redis_value).first
+ @exists = redis_value == '1'
end
@exists