Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding ttl and delete api #37

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: delete key
  • Loading branch information
Sola-Aremu 'Pelumi committed Oct 26, 2024
commit 38072ca44727a09c6b28222217968c63ac6ca41d
8 changes: 4 additions & 4 deletions lib/groot/storage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ defmodule Groot.Storage do
def handle_call({:delete, key}, _from, data) do
registers = Map.delete(data.registers, key)
:ets.delete(data.table, key)
GenServer.abcast(__MODULE__, {:propagate_delete, registers[key]})
GenServer.abcast(__MODULE__, {:propagate_delete, key})

{:reply, :ok, %{data | registers: registers}}
end
Expand Down Expand Up @@ -103,9 +103,9 @@ defmodule Groot.Storage do
{:noreply, %{data | registers: new_registers}}
end

def handle_cast({:propagate_delete, reg}, data) do
registers = Map.delete(data.registers, reg.key)
:ets.delete(data.table, reg.key)
def handle_cast({:propagate_delete, key}, data) do
registers = Map.delete(data.registers, key)
:ets.delete(data.table, key)
{:noreply, %{data | registers: registers}}
end

Expand Down