def METHOD_NAME(self, key: int, new_value: bytes) -> bool:
    old_value, offset = self._find_item(key)
    if not old_value:
        raise RuntimeError("Norcow: key not found")
    if len(old_value) != len(new_value):
        raise RuntimeError(
            "Norcow: replace works only with items of the same length"
        )
    self._write(offset, key, new_value)