/** * @param int|string $sessionId * * @return bool */ public function destroy($sessionId) { $key = $this->keyPrefix . $sessionId; $startTime = microtime(true); $result = $this->connection->delete($key); $this->newRelicApi->addCustomMetric(self::METRIC_SESSION_DELETE_TIME, microtime(true) - $startTime); return true; }
/** * Deletes cache entry by key * * @param string $key * @return bool */ public function delete($key) { try { return (bool) $this->cache->delete($this->prepareKey($key)); } catch (\CouchbaseException $e) { return false; } }
/** * Utility function that waits for bucket creation. * Bucket creation is async, for the time being, we need to poll until * it is there. * @param Couchbase $cb Couchbase client library object. * @param constant Expected memcached result code. */ function _waitForBucket($cb, $resultCode = Memcached::RES_SUCCESS) { // var_dump("--waitForBucket"); do { $cb->set("f", 1); usleep(500000); // 1/2 second // var_dump($cb->getResultMessage()); } while ($cb->getResultCode() !== $resultCode); $cb->delete("f"); // var_dump("--done waiting"); }
private function clearCouchbase(\Couchbase $cb) { $cb->delete('oauth_authorization_codes-new-openid-code'); $cb->delete('oauth_access_tokens-newtoken'); $cb->delete('oauth_authorization_codes-newcode'); $cb->delete('oauth_refresh_tokens-refreshtoken'); }
if ($result) { echo "\n--------------\n"; echo "Add succeeded"; } else { echo "\n--------------\n"; echo "Add failed: key exists"; } // success $result = $cb->replace("mytest", 2); echo "\n--------------\n"; echo "Get mytest: "; echo $cb->get("mytest"); // try to replace a key that does not exist $result = $cb->add("mytest4", 2); if ($result) { echo "\n--------------\n"; echo "Replace succeeded"; } else { echo "\n--------------\n"; echo "Replace failed: key does not exist"; } $cb->delete("mytest"); $result = $cb->delete("mytest3"); if ($result) { echo "\n--------------\n"; echo "Delete succeeded"; } else { echo "\n--------------\n"; echo "Delete failed: key does not exist"; } echo "--------------------------------------------------------------------------\n";
echo "Set Counter to 0\n"; $cb->set("counter", 0); echo "Get counter: "; echo $cb->get("counter"); echo "\n"; $cb->increment("counter"); echo "Get counter: "; echo $cb->get("counter"); echo "\n"; echo "Increment by 10\n"; $cb->increment("counter", 10); echo "Get counter: "; echo $cb->get("counter"); echo "\n"; echo "\nDelete the counter\n"; $cb->delete("counter"); echo "\nInit the value to 10\n"; // create an set an initial $cb->increment("counter", 1, true, 0, 10); echo "Get counter: "; echo $cb->get("counter"); echo "\n"; // does not decrease below 0 $cb->set("counter", 0); $cb->decrement("counter"); echo "Get counter: "; echo $cb->get("counter"); echo "\n"; // set to max value $cb->set("counter", -1); $cb->decrement("counter");
/** * {@inheritDoc} */ public function delete($storageName, $key) { $this->client->delete($key); }
public function destroy($id) { $sId = $this->getSid($id); $result = $this->_cb->delete($sId); return $result; }
/** * Unlock key, locked by method 'lock_key' * @param KeyAutoUnlocker $auto_unlocker * @return bool */ public function unlock_key(KeyAutoUnlocker $auto_unlocker) { $key = $auto_unlocker->getKey(); $auto_unlocker->revoke(); return $this->Couchbase->delete($this->lock_key_prefix . $key); }
/** * Delete a Document from Couchbase. * * @param Document $document */ public function delete(Document $document) { $this->connection->delete($document->getKey()); }