当前位置: 首页>>代码示例>>PHP>>正文


PHP Redis::delete方法代码示例

本文整理汇总了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;
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:10,代码来源:redis.php

示例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);
 }
开发者ID:bicatu,项目名称:php-circuit-breaker,代码行数:9,代码来源:RedisAdapterTest.php

示例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;
 }
开发者ID:sebst3r,项目名称:nZEDb,代码行数:15,代码来源:Cache.php

示例4: delete

 /**
  * {@inheritDoc}
  */
 public function delete($storageName, $key)
 {
     $key = $this->getKeyName($key);
     if ($this->client->exists($key)) {
         $this->client->delete($key);
     }
 }
开发者ID:nicktacular,项目名称:KeyValueStore,代码行数:10,代码来源:RedisStorage.php

示例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'));
 }
开发者ID:Asin065x,项目名称:php-hiredis,代码行数:7,代码来源:TestRedis.php

示例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;
 }
开发者ID:comodojo,项目名称:cache,代码行数:36,代码来源:PhpRedisCache.php

示例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);
 }
开发者ID:plugh3,项目名称:eve-trade1-perl,代码行数:15,代码来源:RedisWrapper.php

示例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;
		}
	}
开发者ID:neil-chen,项目名称:NeilChen,代码行数:13,代码来源:RedisCache.class.php

示例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;
 }
开发者ID:3032441712,项目名称:person,代码行数:15,代码来源:Data.php

示例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'));
 }
开发者ID:hieutrieu,项目名称:phpredis,代码行数:9,代码来源:TestRedis.php

示例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);
     }
 }
开发者ID:xiaodin1,项目名称:myqee,代码行数:15,代码来源:redis.class.php

示例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'));
     */
 }
开发者ID:korsunivan,项目名称:phpredis,代码行数:55,代码来源:TestRedis.php

示例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;
 }
开发者ID:dhamodhar,项目名称:mysmartportal,代码行数:17,代码来源:Cache_redis.php

示例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;
 }
开发者ID:recca0120,项目名称:laraigniter,代码行数:18,代码来源:Cache_redis.php

示例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;
 }
开发者ID:3nr1c,项目名称:temporal,代码行数:18,代码来源:Temporal.php


注:本文中的Redis::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。