diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-12-04 16:47:15 +0100 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-12-04 16:47:15 +0100 |
commit | 2797e8dbec22f04a7eae8eff0e9c0351f7e511ad (patch) | |
tree | 90a1a934b7cca0d68b7e198bd97c7bddf168f1b1 | |
parent | 2d7426d94c43d4d3ce69c0688cb860aa605bdb51 (diff) | |
download | gitlab-ce-repository-exists-cache-short-ttl.tar.gz |
simplify encodingrepository-exists-cache-short-ttl
-rw-r--r-- | app/models/repository.rb | 5 |
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 |