Esempio n. 1
0
 /**
  * @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;
 }
Esempio n. 2
0
 /**
  * @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;
 }
Esempio n. 3
0
 /**
  * @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;
 }