public function save(JobConfig $config)
    {
        $shmid = shm_attach($this->sysvKey, $this->shmSize, $this->perm);
        if ($shmid === false) {
            throw new \RuntimeException(
                'Failed to attach to the shared memory'
            );
        }

        // If the variable write fails, clear the memory and re-raise the exception
        try {
            $result = shm_put_var($shmid, self::VAR_KEY, $config);
        } catch (\Exception $e) {
            $this->clear();
            throw new \RuntimeException($e->getMessage());
        } finally {
            shm_detach($shmid);
        }
        return $result;
    }