/** * @param string $id * @param string $payload * @return int * @throws StorageException */ public function write(string $id, string $payload) : int { $write = $this->disk->write($id . ".sess", $payload, \Comely\IO\Filesystem\Disk::WRITE_FLOCK); if (!$write) { throw StorageException::writeError(__METHOD__, 'Failed'); } return $write; }
/** * @param string $id * @param string $payload * @return int * @throws StorageException */ public function write(string $id, string $payload) : int { $bytes = strlen($payload); $update = $this->db->table(self::SCHEMA_TABLE)->find("id=:id", ["id" => $id])->update(["payload" => $payload, "time" => time()]); if ($update !== 1 || $this->db->lastQuery->error !== null) { throw StorageException::writeError(__METHOD__, $this->db->lastQuery->error ?? 'Failed'); } return $bytes; }
/** * @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; }