Class: LogStash::Filters::Cache
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::Cache
- Defined in:
- lib/logstash/filters/cache.rb
Overview
This filter provide a cache where you can store data.
Constant Summary collapse
- @@cachetab =
This filter needs to keep state.
Hash.new
Instance Method Summary collapse
Instance Method Details
#filter(event) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/logstash/filters/cache.rb', line 45 def filter(event) if @get event[@field] = @@cachetab[@key] if event[@field] == nil event["tags"] ||= [] event["tags"] << "cache_miss" unless event["tags"].include?("cache_miss") else # filter_matched should go in the last line of our successful code filter_matched(event) end else @@cachetab[@key]= event.sprintf(@value) # filter_matched should go in the last line of our successful code filter_matched(event) end end |
#register ⇒ Object
39 40 41 42 |
# File 'lib/logstash/filters/cache.rb', line 39 def register # Nothing @threadsafe = false end |