Class: Fluent::EventRouter::MatchCache
- Inherits:
-
Object
- Object
- Fluent::EventRouter::MatchCache
- Defined in:
- lib/fluent/event_router.rb
Constant Summary collapse
- MATCH_CACHE_SIZE =
1024
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize ⇒ MatchCache
constructor
A new instance of MatchCache.
Constructor Details
#initialize ⇒ MatchCache
Returns a new instance of MatchCache.
120 121 122 123 124 |
# File 'lib/fluent/event_router.rb', line 120 def initialize super @map = {} @keys = [] end |
Instance Method Details
#get(key) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/fluent/event_router.rb', line 126 def get(key) if collector = @map[key] return collector end collector = @map[key] = yield if @keys.size >= MATCH_CACHE_SIZE # expire the oldest key @map.delete @keys.shift end @keys << key collector end |