Sha256: ee7795422a53d3bfd959779325daaf9d454fe13f1037d7b2cc9f938d6183b8b2
Contents?: true
Size: 576 Bytes
Versions: 1
Compression:
Stored size: 576 Bytes
Contents
# frozen_string_literal: true require 'thread' module JMESPath class CachingParser def initialize(options = {}) @parser = options[:parser] || Parser.new(options) @mutex = Mutex.new @cache = {} end def parse(expression) if cached = @cache[expression] cached else cache_expression(expression) end end private def cache_expression(expression) @mutex.synchronize do @cache.clear if @cache.size > 1000 @cache[expression] = @parser.parse(expression) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jmespath-1.6.2 | lib/jmespath/caching_parser.rb |