summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2009-09-03 11:45:49 +0100
committerMatthew Sackman <matthew@lshift.net>2009-09-03 11:45:49 +0100
commitc3d1000a4db4a6148715ccb795306d98bc8923e9 (patch)
tree9ff83911d5b40083d82d85b4e79fa10d49448b11
parente51355478f8ae924cc6df1dc021790b67601fc1e (diff)
downloadrabbitmq-server-git-c3d1000a4db4a6148715ccb795306d98bc8923e9.tar.gz
commented on purpose of cache
-rw-r--r--src/rabbit_disk_queue.erl11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rabbit_disk_queue.erl b/src/rabbit_disk_queue.erl
index 63df5cc5d1..3914e93365 100644
--- a/src/rabbit_disk_queue.erl
+++ b/src/rabbit_disk_queue.erl
@@ -705,6 +705,17 @@ to_ram_disk_mode(State = #dqstate { operation_mode = disk_only,
%% message cache helper functions
%%----------------------------------------------------------------------------
+%% The purpose of the cache is not especially performance, though it
+%% can help there too. The main purpose is to ensure that individual
+%% messages that are sent to multiple queues, and then to disk, are
+%% read back as the same binary object rather than multiples of
+%% identical binary objects. This prevents memory explosion.
+%%
+%% We limit the cache in size. If we didn't, then we could have two
+%% queues coming off the same exchange, receiving the same millions of
+%% messages, then one queue gets drained, which would pull the entire
+%% queue into the cache, which would potentially explode memory.
+
remove_cache_entry(MsgId, #dqstate { message_cache = Cache }) ->
true = ets:delete(Cache, MsgId),
ok.