Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

Commit

Permalink
Merge pull request #83 from Shopify/make-scrub-iterative
Browse files Browse the repository at this point in the history
Make scrub be iterative instead of recursive so it does not throw a stack level too deep error for big experiments
  • Loading branch information
juanxo authored Dec 10, 2020
2 parents b168b5d + cd0a1be commit 972bc05
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/verdict/storage/redis_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ def scope_key(scope)
end

def scrub(scope, cursor: 0)
cursor, results = redis.with do |conn|
conn.hscan(scope_key(scope), cursor, count: PAGE_SIZE)
end
loop do
cursor, results = redis.with do |conn|
conn.hscan(scope_key(scope), cursor, count: PAGE_SIZE)
end

results.map(&:first).each do |key|
remove(scope, key)
end
results.map(&:first).each do |key|
remove(scope, key)
end

scrub(scope, cursor: cursor) unless cursor.to_i.zero?
break if cursor.to_i.zero?
end
end
end
end
Expand Down

0 comments on commit 972bc05

Please sign in to comment.