protected function writeToBigStorageIfNeeded($id, &$value)
    {
        if (!$this->bigStorage) {
            return false;
        }

        if (is_string($value) && strlen($value) <= $this->maxMainStorageBytes) {
            return false;
        }

        try {
            $this->bigStorage[$id] = $value;
            return true;
        } catch (\Exception $e) {
            $msg = "Data of id #$id (type:" . Type::of($value) . ") couldnt be written to big storage";
            $e = new DataIntegrityException($msg, 0, $e);
            $this->callOnListeners('error', [$e]);
        }

        return false;

    }