lib/fluent/plugin/parser.rb
# TODO: new cache mechanism using format string
new cache mechanism using format string
new cache mechanism using format string
def parse(value)
          unless value.is_a?(String)
            raise ParserError, "value must be string: #{value}"
          end
          if @cache1_key == value
            return @cache1_time
          elsif @cache2_key == value
            return @cache2_time
          else
            begin
              time = @parser.call(value)
            rescue => e
              raise ParserError, "invalid time format: value = #{value}, error_class = #{e.class.name}, error = #{e.message}"
            end
            @cache1_key = @cache2_key
            @cache1_time = @cache2_time
            @cache2_key = value
            @cache2_time = time
            return time
          end
        end
def parse ( value ) unless value . is_a? ( String ) raise ParserError , "value must be string: #{value}" end if @cache1_key == value return @cache1_time elsif @cache2_key == value return @cache2_time else begin time = @parser . call ( value ) rescue => e raise ParserError , "invalid time format: value = #{value}, error_class = #{e.class.name}, error = #{e.message}" end @cache1_key = @cache2_key @cache1_time = @cache2_time @cache2_key = value @cache2_time = time return time end end
TODO: new cache mechanism using format string
TODO : new cache mechanism using format string
value
<not_specific>