Skip to content

Commit

Permalink
Improve memory store cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
julik committed Mar 20, 2024
1 parent 9662a33 commit 047c9f0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/pecorino/adapters/memory_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,16 @@ def blocked_until(key:)
def prune
now_monotonic = get_mono_time

@blocks.delete_if do |key, blocked_until_monotonic|
@blocks.keys.each do |key|
@lock.with(key) do
blocked_until_monotonic < now_monotonic
@blocks.delete(key) if @blocks[key] && @blocks[key] < now_monotonic
end
end

@buckets.delete_if do |key, (_level, expire_at_monotonic)|
@buckets.keys.each do |key|
@lock.with(key) do
expire_at_monotonic < now_monotonic
_level, expire_at_monotonic = @buckets[key]
@buckets.delete(key) if expire_at_monotonic && expire_at_monotonic < now_monotonic
end
end
end
Expand Down

0 comments on commit 047c9f0

Please sign in to comment.