def cache_write(obj)
      # This is just a safety check. It can probably be disabled in the future
      # to increase performance.
      if obj.respond_to?(:is_poxreference?)
        # If this condition triggers, we have a bug in the library.
        PEROBS.log.fatal "POXReference objects should never be cached"
      end

      if @transaction_stack.empty?
        # We are not in transaction mode.
        idx = index(obj)
        if (old_obj = @writes[idx]) && old_obj._id != obj._id
          # There is another old object using this cache slot. Before we can
          # re-use the slot, we need to sync it to the permanent storage.
          old_obj._sync
        end
        @writes[idx] = obj
      else
        # When a transaction is active, we don't have a write cache. The read
        # cache is used to speed up access to recently used objects.
        cache_read(obj)
        # Push the reference of the modified object into the write buffer for
        # this transaction level.
        unless @transaction_stack.last.include?(obj._id)
          @transaction_stack.last << obj._id
          @transaction_objects[obj._id] = obj
        end
      end
    end
def cache_write(obj)
      # This is just a safety check. It can probably be disabled in the future
      # to increase performance.
      if obj.respond_to?(:is_poxreference?)
        # If this condition triggers, we have a bug in the library.
        PEROBS.log.fatal "POXReference objects should never be cached"
      end

      if @transaction_stack.empty?
        # We are not in transaction mode.
        idx = index(obj)
        if (old_obj = @writes[idx]) && old_obj._id != obj._id
          # There is another old object using this cache slot. Before we can
          # re-use the slot, we need to sync it to the permanent storage.
          old_obj._sync
        end
        @writes[idx] = obj
      else
        # When a transaction is active, we don't have a write cache. The read
        # cache is used to speed up access to recently used objects.
        cache_read(obj)
        # Push the reference of the modified object into the write buffer for
        # this transaction level.
        unless @transaction_stack.last.include?(obj._id)
          @transaction_stack.last << obj._id
          @transaction_objects[obj._id] = obj
        end
      end
    end
Add a PEROBS::Object to the write cache.
 @param obj [PEROBS::ObjectBase]