def object_by_id(id)
      if (ruby_object_id = @in_memory_objects[id])
        # We have the object in memory so we can just return it.
        begin
          object = ObjectSpace._id2ref(ruby_object_id)
          # Let's make sure the object is really the object we are looking
          # for. The GC might have recycled it already and the Ruby object ID
          # could now be used for another object.
          if object.is_a?(ObjectBase) && object._id == id
            return object
          end
        rescue RangeError => e
          # Due to a race condition the object can still be in the
          # @in_memory_objects list but has been collected already by the Ruby
          # GC. In that case we need to load it again. In this case the
          # _collect() call will happen much later, potentially after we have
          # registered a new object with the same ID.
          @in_memory_objects.delete(id)
        end
      end

      if (obj = @cache.object_by_id(id))
        PEROBS.log.fatal "Object #{id} with Ruby #{obj.object_id} is in cache but not in_memory"
      end

      # We don't have the object in memory. Let's find it in the storage.
      if @db.include?(id)
        # Great, object found. Read it into memory and return it.
        obj = ObjectBase::read(self, id)
        # Add the object to the in-memory storage list.
        @cache.cache_read(obj)

        return obj
      end

      # The requested object does not exist. Return nil.
      nil
    end
def object_by_id(id)
      if (ruby_object_id = @in_memory_objects[id])
        # We have the object in memory so we can just return it.
        begin
          object = ObjectSpace._id2ref(ruby_object_id)
          # Let's make sure the object is really the object we are looking
          # for. The GC might have recycled it already and the Ruby object ID
          # could now be used for another object.
          if object.is_a?(ObjectBase) && object._id == id
            return object
          end
        rescue RangeError => e
          # Due to a race condition the object can still be in the
          # @in_memory_objects list but has been collected already by the Ruby
          # GC. In that case we need to load it again. In this case the
          # _collect() call will happen much later, potentially after we have
          # registered a new object with the same ID.
          @in_memory_objects.delete(id)
        end
      end

      if (obj = @cache.object_by_id(id))
        PEROBS.log.fatal "Object #{id} with Ruby #{obj.object_id} is in cache but not in_memory"
      end

      # We don't have the object in memory. Let's find it in the storage.
      if @db.include?(id)
        # Great, object found. Read it into memory and return it.
        obj = ObjectBase::read(self, id)
        # Add the object to the in-memory storage list.
        @cache.cache_read(obj)

        return obj
      end

      # The requested object does not exist. Return nil.
      nil
    end
Return the object with the provided ID. This method is not part of the
 public API and should never be called by outside users. It's purely
 intended for internal use.