Server IP : 66.29.132.122 / Your IP : 3.139.239.41 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/opt/puppetlabs/puppet/lib/ruby/vendor_gems/gems/multi_json-1.15.0/lib/multi_json/ |
Upload File : |
module MultiJson module OptionsCache extend self def reset @dump_cache = {} @load_cache = {} end def fetch(type, key, &block) cache = instance_variable_get("@#{type}_cache") cache.key?(key) ? cache[key] : write(cache, key, &block) end private # Normally MultiJson is used with a few option sets for both dump/load # methods. When options are generated dynamically though, every call would # cause a cache miss and the cache would grow indefinitely. To prevent # this, we just reset the cache every time the number of keys outgrows # 1000. MAX_CACHE_SIZE = 1000 def write(cache, key) cache.clear if cache.length >= MAX_CACHE_SIZE cache[key] = yield end end end