Sha256: 82b9b280b407f42cc2b2ae55612c8be0d1234131511829f303def01e2fad7567

Contents?: true

Size: 848 Bytes

Versions: 18

Compression:

Stored size: 848 Bytes

Contents

# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module Contrast
  module Utils
    module Assess
      # keep track of object properties and events data
      class ObjectStore
        def initialize capacity = 500
          @capacity = capacity
          @cache = {}
        end

        def get
          @cache
        end

        def [] key
          @cache[key]
        end

        def delete key
          @cache.delete(key)
        end

        # We would keep object ids with capacity.
        # If a reference is kept to an object only by it's id,
        # It would be CG-ted safely.
        def []= key, value
          @cache[key] = value
          @cache.shift if @cache.length > @capacity
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.6.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.5.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.4.1 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.4.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.3.2 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.3.1 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.3.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.2.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.1.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-7.0.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-6.15.3 lib/contrast/utils/assess/object_store.rb
contrast-agent-6.15.2 lib/contrast/utils/assess/object_store.rb
contrast-agent-6.15.1 lib/contrast/utils/assess/object_store.rb
contrast-agent-6.15.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-6.14.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-6.13.0 lib/contrast/utils/assess/object_store.rb
contrast-agent-6.12.0 lib/contrast/utils/assess/object_store.rb