Skip to content

Commit e379310

Browse files
committed
issue #91, cache: rename internal variable names
There was a useless and confusing internal renaming :size -> :limit and :ttl -> :default_ttl. Signed-off-by: Matteo Cafasso <[email protected]>
1 parent 9aebcb0 commit e379310

File tree

1 file changed

+6
-6
lines changed
  • lib/rabbitmq_message_deduplication

1 file changed

+6
-6
lines changed

lib/rabbitmq_message_deduplication/cache.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defmodule RabbitMQMessageDeduplication.Cache do
2020
alias :erlang, as: Erlang
2121
alias :mnesia, as: Mnesia
2222

23-
@options [:persistence, :limit, :default_ttl]
23+
@options [:persistence, :size, :ttl]
2424
@cache_wait_time Application.get_env(:rabbitmq_message_deduplication, :cache_wait_time)
2525

2626
@doc """
@@ -134,7 +134,7 @@ defmodule RabbitMQMessageDeduplication.Cache do
134134
bytes = words * Erlang.system_info(:wordsize)
135135
nodes = Mnesia.table_info(cache, cache_property(cache, :persistence))
136136

137-
case cache_property(cache, :limit) do
137+
case cache_property(cache, :size) do
138138
nil -> [entries: entries, bytes: bytes, nodes: nodes]
139139
size -> [entries: entries, bytes: bytes, nodes: nodes, size: size]
140140
end
@@ -176,8 +176,8 @@ defmodule RabbitMQMessageDeduplication.Cache do
176176
{:index, [:expiration]},
177177
{:user_properties, [{:distributed, distributed},
178178
{:persistence, persistence},
179-
{:limit, Keyword.get(options, :size)},
180-
{:default_ttl, Keyword.get(options, :ttl)}]}]
179+
{:size, Keyword.get(options, :size)},
180+
{:ttl, Keyword.get(options, :ttl)}]}]
181181

182182
case Mnesia.create_table(cache, options) do
183183
{:atomic, :ok} -> wait_for_cache(cache)
@@ -217,12 +217,12 @@ defmodule RabbitMQMessageDeduplication.Cache do
217217

218218
# True if the cache is full, false otherwise.
219219
defp cache_full?(cache) do
220-
Mnesia.table_info(cache, :size) >= cache_property(cache, :limit)
220+
Mnesia.table_info(cache, :size) >= cache_property(cache, :size)
221221
end
222222

223223
# Calculate the expiration given a TTL or the cache default TTL
224224
defp entry_expiration(cache, ttl) do
225-
default = cache_property(cache, :default_ttl)
225+
default = cache_property(cache, :ttl)
226226

227227
cond do
228228
ttl != nil -> Os.system_time(:millisecond) + ttl

0 commit comments

Comments
 (0)