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
commit2aa8b3cb17bff0efef36e8a7c236593d94e4fef4 (patch)
tree9ff83911d5b40083d82d85b4e79fa10d49448b11
parent8e23734c4bcee46e7d8770d99ff2634c63d06230 (diff)
downloadrabbitmq-server-2aa8b3cb17bff0efef36e8a7c236593d94e4fef4.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 63df5cc5..3914e933 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.