Commit 3f6faae3 authored by Robert May's avatar Robert May Committed by Stan Hu

Fix for empty keys on Redis#del

Prevents attempts to call Redis `del` with no arguments.
parent 59b731a5
...@@ -14,7 +14,10 @@ module Gitlab ...@@ -14,7 +14,10 @@ module Gitlab
"#{key}:set" "#{key}:set"
end end
# Returns the number of keys deleted by Redis
def expire(*keys) def expire(*keys)
return 0 if keys.empty?
with do |redis| with do |redis|
keys = keys.map { |key| cache_key(key) } keys = keys.map { |key| cache_key(key) }
unlink_or_delete(redis, keys) unlink_or_delete(redis, keys)
......
...@@ -88,6 +88,12 @@ describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do ...@@ -88,6 +88,12 @@ describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do
end end
end end
context 'no keys' do
let(:keys) { [] }
it { is_expected.to eq(0) }
end
context "unlink isn't supported" do context "unlink isn't supported" do
before do before do
allow_any_instance_of(Redis).to receive(:unlink) { raise ::Redis::CommandError } allow_any_instance_of(Redis).to receive(:unlink) { raise ::Redis::CommandError }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment