public function tsli_save_post($post_ID, $post, $update) { $memcache = new Memcached(); $memcache->addServer('127.0.0.1', 11211); foreach ($post as $key => $value) { $memcache->delete(md5(json_encode(array("field" => $key, "id" => $post_ID, "type" => "tsli")))); $memcache->delete(md5(json_encode(array("field" => $key, "slug" => $post->post_name, "type" => "tsli")))); } $memcache->delete(md5(json_encode(array("type" => "tsli", "slug" => $post->post_name)))); $memcache->delete(md5(json_encode(array("type" => "tsli", "id" => $post_ID)))); }
/** * Delete an item from the cache * * @param string $key cache key */ public function Delete($key) { if (empty($key)) { return; } $this->memcache->delete($key); }
/** * @param string $name */ public function invalidate($name) { if (!$this->memcached instanceof \Memcached) { $this->connect(); } $this->memcached->delete($name); }
/** * 解锁 * @param unknown $key */ public function release($key) { $key = $this->prefix . $key; if ($this->memcached->get($key) === $this->Identifier) { $this->memcached->delete($key); } }
/** * Release lock * * @param string $name name of lock * @return bool */ public function releaseLock($name) { if (isset($this->keys[$name]) && $this->memcache->delete($name)) { unset($this->keys[$name]); return true; } return false; }
function delete($key) { $key = str_replace('\\', '/', $key); if (!$this->memcached->delete($key)) { $message = sprintf('Memcache::delete() with key "%s" failed', $key); \ManiaLib\Utils\Logger::error($message); } }
public function getCounter() { $memcached = new \Memcached(); $memcached->addServer($GLOBALS['settings']['memcached']['host'], $GLOBALS['settings']['memcached']['port']); $memcached->delete('prefix/counter/value'); $memcached->delete('prefix/counter/value2'); return new \Cachet\Counter\Memcache($memcached, 'prefix'); }
public function testLoadStatusEmpty() { $this->_connection->delete('EjsmontCircuitBreakerAAAbbb'); $this->assertEquals("", $this->_adapter->loadStatus('GGG', '')); $this->assertEquals("", $this->_adapter->loadStatus('AAA', 'bbb')); $this->_adapter->saveStatus('B', 'bbb', ""); $this->assertEquals("", $this->_adapter->loadStatus('A', 'bbb'), 6); $this->assertEquals("", $this->_adapter->loadStatus('B', 'bbb'), 7); }
/** * {@inheritdoc} */ protected function deleteArrayDataFromStorage(array $keys) { $deleted = true; foreach ($keys as $key) { if ($this->memcached->delete($key) === false) { $deleted = false; } } return $deleted; }
public function delete($key) { $this->memcachedObj->delete($key); $resultCode = $this->memcachedObj->getResultCode(); if ($resultCode != \Memcached::RES_SUCCESS && $resultCode != \Memcached::RES_NOTFOUND) { throw new StorageException('[STORAGE] "' . $this->getStorageName() . '::delete" failed for key "' . $key . '"!' . ' StorageRespCode: ' . $resultCode); } unset($this->casArray[$key]); return $resultCode; }
/** * {@inheritdoc} */ protected function doDelete($key, array $options = array()) { $this->client->delete($this->getKey($key, $options)); switch (true) { case $this->isSuccess(): return new CacheResponse(true, true, true); case $this->isNotFound(): return new CacheResponse(false, false, true, CacheResponse::RESOURCE_NOT_FOUND); } /* If everything failed we're dealing with a backend (connection) error. */ return new CacheResponse(false, false, false, CacheResponse::CONNECTION_ERROR); }
/** * 批量设置键值(当键名不存在时);<br> * 只有当键值全部设置成功时,才返回true,否则返回false并尝试回滚 * @param array $sets 键值数组 * @return boolean 是否成功 */ public function mSetNX($sets) { try { $keys = []; $status = true; foreach ($sets as $key => $value) { $status = $this->handler->add($key, self::setValue($value)); if ($status) { $keys[] = $key; } else { break; } } //如果失败,尝试回滚,但不保证成功 if (!$status) { foreach ($keys as $key) { $this->handler->delete($key); } } return $status; } catch (Exception $ex) { self::exception($ex); //连接状态置为false $this->isConnected = false; } return false; }
/** * Remove a cache record directly. This method is implemented by the cache * drivers and used in Doctrine_Cache_Driver::delete() * * @param string $id cache id * @return boolean true if no problem */ protected function _doDelete($id) { if (false == $this->_memcached->getOption(Memcached::OPT_BINARY_PROTOCOL)) { $id = str_replace(' ', '_', $id); } return $this->_memcached->delete($id); }
public function process() { $id = $this->get('id'); $state = (string) $this->get('state'); if (!$this->is_moderator()) { throw new ErrorApi(ErrorApi::INSUFFICIENT_RIGHTS); } if (empty($id) || empty($state)) { throw new ErrorApi(ErrorApi::MISSING_INPUT); } $state = Meta::parse($state); if (empty($state)) { throw new ErrorApi(ErrorApi::INCORRECT_INPUT); } $this->db->update('art', array('sortdate' => $this->db->unix_to_date()), $id); $this->remove_meta(Meta::ART, $id, Meta::STATE, Meta::STATE_APPROVED); $this->remove_meta(Meta::ART, $id, Meta::STATE, Meta::STATE_UNAPPROVED); $this->remove_meta(Meta::ART, $id, Meta::STATE, Meta::STATE_DISAPPROVED); $this->remove_meta(Meta::ART, $id, Meta::STATE, Meta::STATE_DELETED); $this->add_meta(Meta::ART, $id, Meta::STATE, $state); $cache = new \Memcached("access_checker"); $cache->addServer("localhost", 11211); $cache->delete('is_pic_safe_' . $this->db->get_field('art', 'md5', $id)); $this->set_success(true); }
/** * Delete data tied to a key on the cache server. * * @param string $key Key we can use to retrieve the data. * * @return bool True if deleted, false if not. * @access public */ public function delete($key) { if ($this->connected === true && $this->ping() === true) { return (bool) $this->server->delete($key); } return false; }
/** * delete * * @param mixed $identifier identifier to delete the entry for * * @return boolean */ public function delete($identifier = null) { if (!$identifier) { throw new \InvalidArgumentException('identifier is a required argument'); } return $this->memcached->delete($this->fileName($identifier)); }
/** * destroy of the session * * @param string $sessionId * @return bool * */ function destroy($sessionId) { $this->memcache->delete($sessionId); $this->memcache->delete('db-' . $sessionId); sql_remove_sess_by_id($sessionId); return true; }
public function test_MemcachedLock_Exceptions() { $key = static::TEST_KEY; $MemcachedLock = new MemcachedLock(static::$Memcached, $key, MemcachedLock::FLAG_USE_SELF_EXPIRE_SYNC); $this->assertSame(true, $MemcachedLock->acquire(2)); $this->assertSame(true, $MemcachedLock->isLocked()); static::$Memcached->delete($key); try { $MemcachedLock->release(); $this->assertFalse('Expect LostLockException'); } catch (\Exception $Ex) { $this->assertInstanceOf(LostLockException::class, $Ex); } $this->assertSame(false, $MemcachedLock->isLocked()); $this->assertSame(true, $MemcachedLock->acquire(2)); $this->assertSame(true, $MemcachedLock->isLocked()); static::$Memcached->delete($key); $this->assertSame(false, $MemcachedLock->isExists()); try { $MemcachedLock->isLocked(); $this->assertFalse('Expect LostLockException'); } catch (\Exception $Ex) { $this->assertInstanceOf(LostLockException::class, $Ex); } }
protected function _delete(VO $vo) { if (!$this->memcached) { return true; } return $this->memcached->delete($this->getMemcachedCompleteKey($vo->getId())); }
/** * Remove an item. * * Options: * - namespace <string> optional * - The namespace to use (Default: namespace of object) * - ignore_missing_items <boolean> optional * - Throw exception on missing item or return false * * @param string $key * @param array $options * @return boolean * @throws Exception * * @triggers removeItem.pre(PreEvent) * @triggers removeItem.post(PostEvent) * @triggers removeItem.exception(ExceptionEvent) */ public function removeItem($key, array $options = array()) { $baseOptions = $this->getOptions(); if (!$baseOptions->getWritable()) { return false; } $this->normalizeOptions($options); $this->normalizeKey($key); $args = new ArrayObject(array('key' => &$key, 'value' => &$value, 'options' => &$options)); try { $eventRs = $this->triggerPre(__FUNCTION__, $args); if ($eventRs->stopped()) { return $eventRs->last(); } $internalKey = $options['namespace'] . $baseOptions->getNamespaceSeparator() . $key; $result = $this->memcached->delete($internalKey); if ($result === false) { if (!$options['ignore_missing_items']) { throw new Exception\ItemNotFoundException("Key '{$internalKey}' not found"); } } $result = true; return $this->triggerPost(__FUNCTION__, $args, $result); } catch (\Exception $e) { return $this->triggerException(__FUNCTION__, $args, $e); } }
/** * @see Cache::_delete() */ protected function _delete($key) { if (!$this->is_connected) { return false; } return $this->memcached->delete($key); }
/** * Delete an entry * @param string $key */ public function delete($key) { if ($this->enabled === false) { return; } $this->memcached->delete($key); }
/** * Delete data from cache * * @param array $keys array of keys to delete * @return boolean true on success */ protected function delete(array $keys) { foreach ($keys as $key) { $this->memcacheObj->delete(sha1($key)); } return true; }
public function clear($prefix = '') { $prefix = $this->getNamespace() . $prefix; $allKeys = self::$cache->getAllKeys(); if ($allKeys === false) { // newer Memcached doesn't like getAllKeys(), flush everything self::$cache->flush(); return true; } $keys = array(); $prefixLength = strlen($prefix); foreach ($allKeys as $key) { if (substr($key, 0, $prefixLength) === $prefix) { $keys[] = $key; } } if (method_exists(self::$cache, 'deleteMulti')) { self::$cache->deleteMulti($keys); } else { foreach ($keys as $key) { self::$cache->delete($key); } } return true; }
/** * {@inheritdoc} */ public function flush() : StorageInterface { if ($keys = $this->memcached->get($this->prefix)) { $this->memcached->delete($this->prefix); $this->memcached->deleteMulti(explode('|', $keys)); } return $this; }
/** * Deletes a value from the cache by its key * * @param int|string $keyName * @return boolean */ public function delete($keyName) { if ($keyName === null) { $keyName = $this->_lastKey; } $keyName = $this->_addPrefix($keyName); $this->_backend->delete($keyName); }
function __construct() { $memc = new Memcached(); $memc->addServer('localhost', '11211'); $memc->delete('callback_test'); var_dump($memc->get('callback_test', array($this, 'ReadThrough'))); var_dump($memc->get('callback_test')); }
/** * Remove values from cache * * @param array $keys list of keys to delete * * @return boolean true on success, false on failure */ protected function delete(array $keys) { foreach ($keys as $k) { $k = sha1($k); $this->memcached->delete($k); } return true; }
/** * Destroy a session. * Expects a session id. * @param string $sessionId * @return boolean */ public function destroy($sessionId = '') { if ($sessionId !== '') { $this->_memcached->delete($this->_key($sessionId)); } return true; }
public function delete($key) { $key = $this->prefix . $key; $this->store->delete($key); $this->removeFromIndex($key); return $this; }