summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2017-11-28 17:14:02 +0100
committernsensfel <SpamShield0@noot-noot.org>2017-11-28 17:14:02 +0100
commitf539b7072c357339328d9bfd54f1f1ed51828586 (patch)
treeb6205dd79c78090831e812aceac177d2a9f35d28 /src/timed_caches_manager.erl
parent80358376b9300a0d73cb8b62dfa9fdd65240ca66 (diff)
Trying to tidy up this mess.
Diffstat (limited to 'src/timed_caches_manager.erl')
-rw-r--r--src/timed_caches_manager.erl141
1 files changed, 0 insertions, 141 deletions
diff --git a/src/timed_caches_manager.erl b/src/timed_caches_manager.erl
deleted file mode 100644
index ad66fbb..0000000
--- a/src/timed_caches_manager.erl
+++ /dev/null
@@ -1,141 +0,0 @@
--module(timed_caches_manager).
--behavior(gen_server).
-
-%%%% gen_server exports
--export(
- [
- init/1,
- handle_cast/2,
- handle_call/3,
- terminate/2,
- code_change/3,
- format_status/2,
- handle_info/2
- ]
-).
-
-%%%% actual interface
--export(
- [
- add_cache/3,
- inherit_cache/3,
- delete_cache/2,
- get_timeout/1
- ]
-)
-.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% LOCAL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%% Manager %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-delete_cache (DB) ->
- ets:delete(DB).
-
-add_cache (DB, none) ->
- io:format("~nTimed Caches Manager added a new cache. ~n"),
- ets:new(
- DB,
- [
- set,
- public,
- named_table,
- {keypos, 2},
- {read_concurrency, true},
- {heir, none}
- ]
- );
-add_cache (DB, Heir) ->
- io:format("~nTimed Caches Manager added a new cache. ~n"),
- ets:new(
- DB,
- [
- set,
- public,
- named_table,
- {keypos, 2},
- {read_concurrency, true},
- {heir, Heir, DB}
- ]
- ).
-
-inherit_cache (CacheList, DB, Heir) ->
- case lists:member(DB, CacheList) of
- true ->
- ets:setopts(DB, {heir, Heir, DB}),
- CacheList;
-
- false ->
- [DB|CacheList]
- end.
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%% gen_server
-init (CacheList) ->
- io:format("~nStarting Timed Caches Manager..."),
- {ok, CacheList}.
-
-handle_call ({delete, CacheName}, _Caller, State) ->
- {noreply, delete_cache(State, CacheName)};
-handle_call ({add, CacheName, Heir}, _Caller, State)->
- {noreply, add_cache(State, CacheName, Heir)};
-handle_call ({inherit, CacheName, Heir}, _Caller, State)->
- {noreply, inherit_cache(State, CacheName, Heir)};
-handle_call (terminate, _, State) ->
- {stop, normal, State}.
-
-handle_cast ({delete, CacheName}, State) ->
- {noreply, delete_cache(State, CacheName)};
-handle_cast ({add, CacheName, Heir}, State)->
- {noreply, add_cache(State, CacheName, Heir)};
-handle_cast ({inherit, CacheName, Heir}, State)->
- {noreply, inherit_cache(State, CacheName, Heir)};
-handle_cast (terminate, State) ->
- {stop, normal, State}.
-
-terminate (_Reason, []) ->
- ok;
-terminate (Reason, [CacheName|OtherCaches]) ->
- delete_cache(CacheName),
- terminate(Reason, OtherCaches).
-
-code_change (_, State, _) ->
- {ok, State}.
-
-format_status (_, [_, State]) ->
- [{data, [{"State", State}]}].
-
-handle_info(_, State) ->
- {noreply, State}.
-
-%%%% actual interface
-delete_cache (CacheList, DB) ->
- case lists:member(DB, CacheList) of
- true ->
- delete_cache(DB),
- lists:delete(DB, CacheList);
- false ->
- CacheList
- end.
-
-add_cache (CacheList, DB, Heir) ->
- case lists:member(DB, CacheList) of
- true when (Heir =:= none) ->
- CacheList;
-
- true ->
- ets:setopts(DB, {heir, Heir, DB}),
- CacheList;
-
- false ->
- add_cache(DB, Heir),
- [DB|CacheList]
- end.
-
-get_timeout(battlemap_db) ->
- 60000;
-get_timeout(_) ->
- 60000.