aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2009-07-30 21:00:44 +0000
committerChristophe Romain <christophe.romain@process-one.net>2009-07-30 21:00:44 +0000
commit31d6fe3c7d73219fe49f77f3eb180308de189d07 (patch)
tree4a630ecc483539651a6e443466d4623afb41e514
parentfix configuration result (EJAB-995) (diff)
do not store item when persist_item false but send_last_published_item and last_item_cache enabled
SVN Revision: 2411
-rw-r--r--src/mod_pubsub/mod_pubsub.erl35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl
index a216c76f2..87a343600 100644
--- a/src/mod_pubsub/mod_pubsub.erl
+++ b/src/mod_pubsub/mod_pubsub.erl
@@ -3173,8 +3173,13 @@ max_items(Options) ->
end;
false ->
case get_option(Options, send_last_published_item) of
- never -> 0;
- _ -> 1
+ never ->
+ 0;
+ _ ->
+ case is_last_item_cache_enabled(Host) of
+ true -> 0;
+ false -> 1
+ end
end
end.
@@ -3389,29 +3394,31 @@ set_xoption([_ | Opts], NewOpts) ->
%%%% last item cache handling
+is_last_item_cache_enabled(Host) ->
+ case ets:lookup(gen_mod:get_module_proc(Host, config), last_item_cache) of
+ [{last_item_cache, true}] -> true;
+ _ false
+ end.
+
set_cached_item({_, ServerHost, _}, NodeId, ItemId, Payload) ->
set_cached_item(ServerHost, NodeId, ItemId, Payload);
set_cached_item(Host, NodeId, ItemId, Payload) ->
- case ets:lookup(gen_mod:get_module_proc(Host, config), last_item_cache) of
- [{last_item_cache, true}] ->
- ets:insert(gen_mod:get_module_proc(Host, last_items), {NodeId, {ItemId, Payload}});
- _ ->
- ok
+ case is_last_item_cache_enabled(Host) of
+ true -> ets:insert(gen_mod:get_module_proc(Host, last_items), {NodeId, {ItemId, Payload}});
+ _ -> ok
end.
unset_cached_item({_, ServerHost, _}, NodeId) ->
unset_cached_item(ServerHost, NodeId);
unset_cached_item(Host, NodeId) ->
- case ets:lookup(gen_mod:get_module_proc(Host, config), last_item_cache) of
- [{last_item_cache, true}] ->
- ets:delete(gen_mod:get_module_proc(Host, last_items), NodeId);
- _ ->
- ok
+ case is_last_item_cache_enabled(Host) of
+ true -> ets:delete(gen_mod:get_module_proc(Host, last_items), NodeId);
+ _ -> ok
end.
get_cached_item({_, ServerHost, _}, NodeId) ->
get_cached_item(ServerHost, NodeId);
get_cached_item(Host, NodeId) ->
- case ets:lookup(gen_mod:get_module_proc(Host, config), last_item_cache) of
- [{last_item_cache, true}] ->
+ case is_last_item_cache_enabled(Host) of
+ true ->
case ets:lookup(gen_mod:get_module_proc(Host, last_items), NodeId) of
[{NodeId, {ItemId, Payload}}] ->
#pubsub_item{itemid = {ItemId, NodeId}, payload = Payload};