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
"#{key}:set"
end
# Returns the number of keys deleted by Redis
def expire(*keys)
return 0 if keys.empty?
with do |redis|
keys = keys.map { |key| cache_key(key) }
unlink_or_delete(redis, keys)
......
......@@ -88,6 +88,12 @@ describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do
end
end
context 'no keys' do
let(:keys) { [] }
it { is_expected.to eq(0) }
end
context "unlink isn't supported" do
before do
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