# Copyright (c) 2022 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