aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-05-15 15:17:45 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-05-15 15:17:45 +0900
commitca68e4237e2b67c495c82d406859f5c98a8430f6 (patch)
treeb96a2b8e1c1438fb78dc05e643da046ff6cd73c1
parente3193c650bd0c971f73c09e6debced03d7cd936a (diff)
downloadaclog-ca68e4237e2b67c495c82d406859f5c98a8430f6.tar.gz
collector-proxy: fix caching
-rw-r--r--collector_proxy/lib/event_channel.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/collector_proxy/lib/event_channel.rb b/collector_proxy/lib/event_channel.rb
index 5c394c2..55fdebd 100644
--- a/collector_proxy/lib/event_channel.rb
+++ b/collector_proxy/lib/event_channel.rb
@@ -2,7 +2,7 @@ class EventChannel
class << self
def setup
return if @dalli
- @dalli = Dalli::Client.new(Settings.memcached, namespace: "aclog-collector-proxy:")
+ @dalli = Dalli::Client.new(Settings.memcached, namespace: "aclog-collector-proxy")
@queue = []
@subscribers = {}
end
@@ -10,11 +10,13 @@ class EventChannel
def push(data)
raise ScriptError, "Call EventChannel.setup first" unless @dalli
if id = data[:identifier]
- if @dalli.get(id)
- CollectorProxy.logger.debug("UniqueChannel") { "Duplicate event: #{id}" }
+ key, val = id.split("#", 2)
+ cur = @dalli.get(key)
+ if cur && (!val || (cur <=> val) > -1)
+ CollectorProxy.logger.debug("UniqueChannel") { "Duplicate event: #{key}" }
return
else
- @dalli.set(id, true)
+ @dalli.set(key, val || true)
end
end
if @subscribers.size > 0