Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
94aa74cf
Commit
94aa74cf
authored
Jun 24, 2021
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable writing set cache keys in new format
- Keep expiry in old format too
parent
b9bd0a86
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
16 deletions
+15
-16
lib/gitlab/reactive_cache_set_cache.rb
lib/gitlab/reactive_cache_set_cache.rb
+3
-2
lib/gitlab/repository_set_cache.rb
lib/gitlab/repository_set_cache.rb
+3
-3
lib/gitlab/set_cache.rb
lib/gitlab/set_cache.rb
+4
-4
spec/lib/gitlab/repository_set_cache_spec.rb
spec/lib/gitlab/repository_set_cache_spec.rb
+5
-5
spec/tasks/cache/clear/redis_spec.rb
spec/tasks/cache/clear/redis_spec.rb
+0
-2
No files found.
lib/gitlab/reactive_cache_set_cache.rb
View file @
94aa74cf
...
...
@@ -10,11 +10,12 @@ module Gitlab
@expires_in
=
expires_in
end
def
cache_key
(
key
)
# NOTE Remove as part of #331319
def
old_cache_key
(
key
)
"
#{
cache_namespace
}
:
#{
key
}
:set"
end
def
new_
cache_key
(
key
)
def
cache_key
(
key
)
super
(
key
)
end
...
...
lib/gitlab/repository_set_cache.rb
View file @
94aa74cf
...
...
@@ -13,12 +13,12 @@ module Gitlab
@expires_in
=
expires_in
end
def
cache_key
(
type
)
# NOTE Remove as part of #331319
def
old_cache_key
(
type
)
"
#{
type
}
:
#{
namespace
}
:set"
end
# NOTE Remove as part of #331319
def
new_cache_key
(
type
)
def
cache_key
(
type
)
super
(
"
#{
type
}
:
#{
namespace
}
"
)
end
...
...
lib/gitlab/set_cache.rb
View file @
94aa74cf
...
...
@@ -10,12 +10,12 @@ module Gitlab
@expires_in
=
expires_in
end
def
cache_key
(
key
)
# NOTE Remove as part of https://gitlab.com/gitlab-org/gitlab/-/issues/331319
def
old_cache_key
(
key
)
"
#{
key
}
:set"
end
# NOTE Remove as part of https://gitlab.com/gitlab-org/gitlab/-/issues/331319
def
new_cache_key
(
key
)
def
cache_key
(
key
)
"
#{
cache_namespace
}
:
#{
key
}
:set"
end
...
...
@@ -25,7 +25,7 @@ module Gitlab
with
do
|
redis
|
keys_to_expire
=
keys
.
map
{
|
key
|
cache_key
(
key
)
}
keys_to_expire
+=
keys
.
map
{
|
key
|
new
_cache_key
(
key
)
}
# NOTE Remove as part of #331319
keys_to_expire
+=
keys
.
map
{
|
key
|
old
_cache_key
(
key
)
}
# NOTE Remove as part of #331319
Gitlab
::
Instrumentation
::
RedisClusterValidator
.
allow_cross_slot_commands
do
redis
.
unlink
(
*
keys_to_expire
)
...
...
spec/lib/gitlab/repository_set_cache_spec.rb
View file @
94aa74cf
...
...
@@ -15,7 +15,7 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do
shared_examples
'cache_key examples'
do
it
'includes the namespace'
do
is_expected
.
to
eq
(
"foo:
#{
namespace
}
:set"
)
is_expected
.
to
eq
(
"
#{
gitlab_cache_namespace
}
:
foo:
#{
namespace
}
:set"
)
end
context
'with a given namespace'
do
...
...
@@ -23,7 +23,7 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do
let
(
:cache
)
{
described_class
.
new
(
repository
,
extra_namespace:
extra_namespace
)
}
it
'includes the full namespace'
do
is_expected
.
to
eq
(
"foo:
#{
namespace
}
:
#{
extra_namespace
}
:set"
)
is_expected
.
to
eq
(
"
#{
gitlab_cache_namespace
}
:
foo:
#{
namespace
}
:
#{
extra_namespace
}
:set"
)
end
end
end
...
...
@@ -60,7 +60,7 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do
write_cache
redis_keys
=
Gitlab
::
Redis
::
Cache
.
with
{
|
redis
|
redis
.
scan
(
0
,
match:
"*"
)
}.
last
expect
(
redis_keys
).
to
include
(
"branch_names:
#{
namespace
}
:set"
)
expect
(
redis_keys
).
to
include
(
"
#{
gitlab_cache_namespace
}
:
branch_names:
#{
namespace
}
:set"
)
expect
(
cache
.
fetch
(
'branch_names'
)).
to
contain_exactly
(
'main'
)
end
...
...
@@ -95,8 +95,8 @@ RSpec.describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do
expect
(
cache
.
read
(
:foo
)).
to
be_empty
end
it
'expires the
new
key format'
do
expect_any_instance_of
(
Redis
).
to
receive
(
:unlink
).
with
(
cache
.
cache_key
(
:foo
),
cache
.
new
_cache_key
(
:foo
))
# rubocop:disable RSpec/AnyInstanceOf
it
'expires the
old
key format'
do
expect_any_instance_of
(
Redis
).
to
receive
(
:unlink
).
with
(
cache
.
cache_key
(
:foo
),
cache
.
old
_cache_key
(
:foo
))
# rubocop:disable RSpec/AnyInstanceOf
subject
end
...
...
spec/tasks/cache/clear/redis_spec.rb
View file @
94aa74cf
...
...
@@ -36,8 +36,6 @@ RSpec.describe 'clearing redis cache', :clean_gitlab_redis_cache, :silence_stdou
let
(
:cache
)
{
Gitlab
::
RepositorySetCache
.
new
(
repository
)
}
before
do
pending
"Enable as part of https://gitlab.com/gitlab-org/gitlab/-/issues/331319"
cache
.
write
(
:foo
,
[
:bar
])
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment