class Fluent::EventRouter::MatchCache

Constants

MATCH_CACHE_SIZE

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/event_router.rb, line 113
def initialize
  super
  @map = {}
  @keys = []
end

Public Instance Methods

get(key) { || ... } click to toggle source
# File lib/fluent/event_router.rb, line 119
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