Sha256: feb04f1f9dea5a3af987089c24f051b3a46d4ef7f22cb269a2a3eba725dadb3c
Contents?: true
Size: 624 Bytes
Versions: 10
Compression:
Stored size: 624 Bytes
Contents
# frozen_string_literal: true module ElasticAPM module Util # @api private class LruCache def initialize(max_size = 512) @max_size = max_size @data = {} end def [](key) found = true value = @data.delete(key) { found = false } found ? @data[key] = value : nil end def []=(key, val) @data.delete(key) @data[key] = val return unless @data.length > @max_size @data.delete(@data.first[0]) end def length @data.length end def to_a @data.to_a end end end end
Version data entries
10 entries across 10 versions & 1 rubygems