/** * @param string $id * @param string $payload * @return int * @throws StorageException */ public function write(string $id, string $payload) : int { $bytes = strlen($payload); $write = $this->cache->set("sess_" . $id, $payload); if (!$write) { $error = !empty($this->cache->lastError()) ? $this->cache->lastError() : 'Failed'; throw StorageException::writeError(__METHOD__, $error); } return $bytes; }
/** * @param string $key * @param $object * @return bool */ public function set(string $key, $object) : bool { if (!is_object($object)) { return false; } $this->repo->push($object, $key); if ($this->cache) { try { $this->cache->set($key, clone $object); } catch (CacheException $e) { trigger_error($e->getParsed(), E_USER_WARNING); } } return true; }