summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cache.rb')
-rw-r--r--lib/cache.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/cache.rb b/lib/cache.rb
index f635114..262003e 100644
--- a/lib/cache.rb
+++ b/lib/cache.rb
@@ -1,5 +1,7 @@
require 'date'
+# Caches the message count for each email
+# I guess this operation is/was expensive at some point.
class MessageCountCache
include Singleton
CACHE_SECONDS = 3600
@@ -27,16 +29,16 @@ class MessageCountCache
end
private
+
def update?
- if ((DateTime.now - @load_date) * 60 * 60 * 24).to_i > CACHE_SECONDS
- update!
- end
+ update! if ((DateTime.now - @load_date) * 60 * 60 * 24).to_i > CACHE_SECONDS
end
end
+# Caches the most recent messages displayed on the front page
class MostRecentMessagesCache
include Singleton
- CACHE_SECONDS=3600
+ CACHE_SECONDS = 3600
def initialize
update!
@@ -61,9 +63,8 @@ class MostRecentMessagesCache
end
private
+
def update?
- if ((DateTime.now - @load_date) * 60 * 60 * 24).to_i > CACHE_SECONDS
- update!
- end
+ update! if ((DateTime.now - @load_date) * 60 * 60 * 24).to_i > CACHE_SECONDS
end
-end \ No newline at end of file
+end