Skip to content

Commit

Permalink
fix: lift restriction on purge buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
abbudao committed Jan 9, 2024
1 parent f6f70bc commit 2a4bc25
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 63 deletions.
106 changes: 53 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.73-slim-buster AS build
FROM rust:1.75-slim-buster AS build
ARG CPU_TARGET
WORKDIR /app
COPY . /app
Expand Down
21 changes: 12 additions & 9 deletions src/cache/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,18 +373,21 @@ impl CachePurgeVariant {
match *self {
CachePurgeVariant::Bucket | CachePurgeVariant::Auth => {
r#"
local count = redis.call('SCARD', ARGV[3])
local targets = {}
local cursor = "0"
local targets = {}
local result
if count <= 1000 then
for _, tag in pairs(redis.call('SMEMBERS', ARGV[3])) do
table.insert(targets, ARGV[1] .. ":" .. ARGV[2] .. ":c:" .. tag)
end
end
repeat
result = redis.call('SSCAN', ARGV[3], cursor)
cursor = result[1]
for _, tag in ipairs(result[2]) do
table.insert(targets, ARGV[1] .. ":" .. ARGV[2] .. ":c:" .. tag)
end
until cursor == "0"
table.insert(targets, ARGV[3])
table.insert(targets, ARGV[3])
redis.call('DEL', unpack(targets))
redis.call('UNLINK', unpack(targets))
"#
}
}
Expand Down

0 comments on commit 2a4bc25

Please sign in to comment.