Skip to content

Commit

Permalink
Local adapter improvement: purge expired keys when cleanup runs
Browse files Browse the repository at this point in the history
  • Loading branch information
cabol committed Jan 29, 2023
1 parent 8b32464 commit 6da0b54
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/nebulex/adapters/local/generation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ defmodule Nebulex.Adapters.Local.Generation do
# State
defstruct [
:cache,
:name,
:telemetry,
:telemetry_prefix,
:meta_tab,
Expand Down Expand Up @@ -402,6 +403,8 @@ defmodule Nebulex.Adapters.Local.Generation do
defp maybe_cleanup(
info,
%__MODULE__{
cache: cache,
name: name,
gc_cleanup_ref: cleanup_ref,
gc_cleanup_min_timeout: min_timeout,
gc_cleanup_max_timeout: max_timeout,
Expand All @@ -414,6 +417,9 @@ defmodule Nebulex.Adapters.Local.Generation do
# Create a new generation
:ok = new_gen(state)

# Purge expired entries
_ = cache.delete_all(:expired, dynamic_cache: name)

# Reset the heartbeat timer
heartbeat_ref = start_timer(gc_interval, heartbeat_ref)

Expand Down

0 comments on commit 6da0b54

Please sign in to comment.