add ability to get list of all registered hashes from sessions
This commit is contained in:
parent
9b03d7e482
commit
08a3df4c1a
|
@ -73,6 +73,10 @@ defmodule Floof.SessionManager do
|
|||
GenServer.call(__MODULE__, {:peek, key}, :infinity)
|
||||
end
|
||||
|
||||
def get_hashes() do
|
||||
GenServer.call(__MODULE__, :get_hashes, :infinity)
|
||||
end
|
||||
|
||||
def drop(key, subkeys) do
|
||||
GenServer.cast(__MODULE__, {:drop, key, subkeys})
|
||||
end
|
||||
|
@ -117,6 +121,21 @@ defmodule Floof.SessionManager do
|
|||
end, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_call(:get_hashes, _, state) do
|
||||
ret =
|
||||
case :dets.match(state.dets_file, {'_', '$2'}) do
|
||||
{:error, e} ->
|
||||
Logger.error("garbage collection error: #{inspect(e)}")
|
||||
:error
|
||||
|
||||
keys ->
|
||||
{:ok, Enum.map(keys, fn [x] -> x end)}
|
||||
end
|
||||
|
||||
{:reply, ret, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_cast({:modify_subscription, key, handler}, state) do
|
||||
{_, subs2} =
|
||||
|
|
Loading…
Reference in a new issue