Skip to content

Commit

Permalink
Merge pull request #24 from fp/erlang_r18_compat
Browse files Browse the repository at this point in the history
Erlang 18 compatibility
  • Loading branch information
Rolph de Ruiter committed Feb 23, 2016
2 parents a680201 + ccc8812 commit 279f120
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
protobuffs, velvet, goldrush
]}.

{erl_opts, [debug_info,
{erl_opts, [{platform_define, "17|18", 'namespace_types'},
debug_info,
{src_dirs, [src]},
{parse_transform, lager_transform}]}.
13 changes: 10 additions & 3 deletions src/erl_cache_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).

-ifdef(namespace_types).
-type stats_dict() :: dict:dict().
-else.
-type stats_dict() :: dict().
-endif.


-record(state, {
name::erl_cache:name(), %% The name of this cache instance
cache::ets:tid(), %% Holds cache
stats::dict() %% Statistics about cache hits
stats::stats_dict() %% Statistics about cache hits
}).

-record(cache_entry, {
Expand Down Expand Up @@ -270,12 +277,12 @@ is_error_value(F, Value) when is_function(F) ->
F(Value).

%% @private
-spec update_stats(hit|miss|overdue|evict|set, dict()) -> dict().
-spec update_stats(hit|miss|overdue|evict|set, stats_dict()) -> stats_dict().
update_stats(Stat, Stats) ->
update_stats(Stat, 1, Stats).

%% @private
-spec update_stats(hit|miss|overdue|evict|set, pos_integer(), dict()) -> dict().
-spec update_stats(hit|miss|overdue|evict|set, pos_integer(), stats_dict()) -> stats_dict().
update_stats(Stat, N, Stats) ->
dict:update_counter(total_ops, N, dict:update_counter(Stat, N, Stats)).

Expand Down

0 comments on commit 279f120

Please sign in to comment.