Skip to content

Commit 91927ca

Browse files
committed
cache: add cache size in bytes in information getter
Signed-off-by: Matteo Cafasso <[email protected]>
1 parent e916714 commit 91927ca

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/cache.ex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ defmodule RabbitMQ.MessageDeduplicationPlugin.Cache do
2323

2424
alias :os, as: Os
2525
alias :timer, as: Timer
26+
alias :erlang, as: Erlang
2627
alias :mnesia, as: Mnesia
2728

2829
## Client API
@@ -153,8 +154,14 @@ defmodule RabbitMQ.MessageDeduplicationPlugin.Cache do
153154

154155
# Return cache information: number of elements and max size
155156
def handle_call({:info, cache}, _from, state) do
156-
info = [size: cache_property(cache, :limit),
157-
entries: Mnesia.table_info(cache, :size)]
157+
info = [
158+
bytes: Mnesia.table_info(cache, :memory) * Erlang.system_info(:wordsize),
159+
entries: Mnesia.table_info(cache, :size)
160+
]
161+
info = case cache_property(cache, :limit) do
162+
number when is_integer(number) -> [size: number] ++ info
163+
nil -> info
164+
end
158165

159166
{:reply, info, state}
160167
end

0 commit comments

Comments
 (0)