public function write($id, $data)
    {
        $key = $this->getSessionKey($id);
        $record = $this->packRecord($data);
        return $this->writeDataToCache($key, $record)->then(
            function() use ($id) {
                $this->keys[$id] = time();
                return $this->read($id);
            },
            function($error = null) use ($id) {
                $message = sprintf('Failed to write session data for "%s"', $id);
                throw new SessionException($message, 0, $error);
            }
        );
    }