本文整理汇总了PHP中Redis::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::delete方法的具体用法?PHP Redis::delete怎么用?PHP Redis::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redis
的用法示例。
在下文中一共展示了Redis::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
public function clear($prefix = '')
{
$prefix = $this->getNamespace() . $prefix . '*';
$it = null;
self::$cache->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY);
while ($keys = self::$cache->scan($it, $prefix)) {
self::$cache->delete($keys);
}
return true;
}
示例2: testLoadStatusEmpty
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);
}
示例3: delete
/**
* 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;
}
示例4: delete
/**
* {@inheritDoc}
*/
public function delete($storageName, $key)
{
$key = $this->getKeyName($key);
if ($this->client->exists($key)) {
$this->client->delete($key);
}
}
示例5: testExists
public function testExists()
{
$this->redis->delete('key');
$this->assertFalse($this->redis->exists('key'));
$this->redis->set('key', 'val');
$this->assertEquals(True, $this->redis->exists('key'));
}
示例6: delete
/**
* Delete cache object (or entire namespace if $name is null)
*
* This method will throw only logical exceptions.
* In case of failures, it will return a boolean false.
*
* @param string $name Name for cache element
*
* @return bool
* @throws \Comodojo\Exception\CacheException
*/
public function delete($name = null)
{
if (!$this->isEnabled()) {
return false;
}
$this->resetErrorState();
try {
$namespace = $this->getNamespaceKey();
if ($namespace === false) {
return true;
}
if (empty($name)) {
$this->instance->delete($this->getNamespace());
} else {
$this->instance->delete($namespace . "-" . md5($name));
}
} catch (CacheException $ce) {
throw $ce;
} catch (RedisException $re) {
$this->raiseError("Server unreachable (PhpRedis), exiting gracefully", array("RESULTCODE" => $re->getCode(), "RESULTMESSAGE" => $re->getMessage()));
$this->setErrorState();
return false;
}
return true;
}
示例7: deleteMulti
/**
* Removes multiple items from Redis.
*
* @param array $keys of items to be removed
*
* @return bool true on success, also if memcached has been disabled
*/
public function deleteMulti(array $keys)
{
$keys2 = array();
foreach ($keys as $key) {
$keys2[] = md5($this->uniqId . '_' . $key);
}
return $this->redis->delete($keys2);
}
示例8: clear
/**
* 删除缓存
* @param sting $cache_id
* @return bool
*/
public function clear ($cache_id) {
try {
return $this->_redis->delete($cache_id);
} catch (Exception $e) {
$this->_error = $e->getMessage();
return false;
}
}
示例9: destroy
/**
* 摧毁SESSION
*
* @param int $id key
*
* @return bool true/false
*/
public function destroy($id)
{
$id = 'sess_' . $id;
if ($this->redis->exists($id)) {
return $this->redis->delete($id);
}
return true;
}
示例10: testsGetMembers
public function testsGetMembers()
{
$this->redis->delete('set');
$this->redis->sAdd('set', 'val');
$this->redis->sAdd('set', 'val2');
$this->redis->sAdd('set', 'val3');
$array = array('val', 'val2', 'val3');
$this->assertEquals($array, $this->redis->sGetMembers('set'));
}
示例11: delete
/**
* 删除指定key的缓存,若$key===true则表示删除全部
*
* @param string $key
*/
public function delete($key)
{
$this->_connect();
if ($key === true) {
return $this->_redis->flushAll();
} else {
$keys = func_get_args();
return $this->_redis->delete($keys);
}
}
示例12: testHashes
public function testHashes()
{
$this->redis->delete('h', 'key');
$this->assertTrue(0 === $this->redis->hLen('h'));
$this->assertTrue(TRUE === $this->redis->hSet('h', 'a', 'a-value'));
$this->assertTrue(1 === $this->redis->hLen('h'));
$this->assertTrue(TRUE === $this->redis->hSet('h', 'b', 'b-value'));
$this->assertTrue(2 === $this->redis->hLen('h'));
$this->assertTrue('a-value' === $this->redis->hGet('h', 'a'));
// simple get
$this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
// simple get
$this->assertTrue(FALSE === $this->redis->hSet('h', 'a', 'another-value'));
// replacement
$this->assertTrue('another-value' === $this->redis->hGet('h', 'a'));
// get the new value
$this->assertTrue('b-value' === $this->redis->hGet('h', 'b'));
// simple get
$this->assertTrue(FALSE === $this->redis->hGet('h', 'c'));
// unknown hash member
$this->assertTrue(FALSE === $this->redis->hGet('key', 'c'));
// unknownkey
// hDel
$this->assertTrue(TRUE === $this->redis->hDel('h', 'a'));
// TRUE on success
$this->assertTrue(FALSE === $this->redis->hDel('h', 'a'));
// FALSE on failure
$this->redis->delete('h');
$this->redis->hSet('h', 'x', 'a');
$this->redis->hSet('h', 'y', 'b');
// keys
$keys = $this->redis->hKeys('h');
$this->assertTrue($keys === array('x', 'y') || $keys === array('y', 'x'));
// values
$values = $this->redis->hVals('h');
$this->assertTrue($values === array('a', 'b') || $values === array('b', 'a'));
// keys + values
$all = $this->redis->hGetAll('h');
$this->assertTrue($all === array('x' => 'a', 'y' => 'b') || $all === array('y' => 'b', 'x' => 'a'));
// hExists
$this->assertTrue(TRUE === $this->redis->hExists('h', 'x'));
$this->assertTrue(TRUE === $this->redis->hExists('h', 'y'));
$this->assertTrue(FALSE === $this->redis->hExists('h', 'w'));
$this->redis->delete('h');
$this->assertTrue(FALSE === $this->redis->hExists('h', 'x'));
// hIncrBy
/*
$this->redis->delete('h');
$this->assertTrue(2.5 === $this->redis->hIncrBy('h', 2.5, 'x'));
$this->assertTrue(3.5 === $this->redis->hIncrBy('h', 1, 'x'));
$this->redis->hSet('h', 'y', 'not-a-number');
$this->assertTrue(FALSE === $this->redis->hIncrBy('h', 1, 'y'));
*/
}
示例13: delete
/**
* Delete from cache
*
* @param string Cache key
* @return bool
*/
public function delete($key)
{
if ($this->_redis->delete($key) !== 1) {
return FALSE;
}
if (isset($this->_serialized[$key])) {
$this->_serialized[$key] = NULL;
$this->_redis->sRemove('_ci_redis_serialized', $key);
}
return TRUE;
}
示例14: delete
/**
* Delete from cache.
*
* @param string $key Cache key
*
* @return bool
*/
public function delete($key)
{
if ($this->_redis->delete($key) !== 1) {
return false;
}
if (isset($this->_serialized[$key])) {
$this->_serialized[$key] = null;
$this->_redis->sRemove('_ci_redis_serialized', $key);
}
return true;
}
示例15: reset
/**
* Resets the Temporal object to its initial value
*
* @return int Returns the initial value
*/
public function reset()
{
Assertion::notNull(self::$redis, "Redis connection hasn't been set");
// Remove each individual key
$items = self::$redis->sMembers($this->identifier);
foreach ($items as $i) {
self::$redis->delete($i);
}
// Remove the set and check its emptiness
self::$redis->delete($this->identifier);
Assertion::count(self::$redis->sMembers($this->identifier), 0);
return $this->initialNumber;
}