/** * @requires extension redis */ protected function setUp() { if (!extension_loaded('redis')) { $this->markTestSkipped('redis extension not installed'); } $this->redis = new \Redis(); if (false === @$this->redis->connect('127.0.0.1')) { unset($this->redis); $this->markTestSkipped('Could not connect to Redis instance'); } $this->redis->flushAll(); parent::setUp(); }
/** * 清空数据 */ public function clearAll() { try { return $this->_redis->flushAll(); } catch (Exception $e) { $this->_error = $e->getMessage(); return false; } }
/** * 删除指定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); } }
/** * Flush all data from the cache server? */ public function flush() { if ($this->connected === true && $this->ping() === true) { if ($this->isRedis === true) { $this->server->flushAll(); } else { $this->server->flush(); } } }
public static function setUpBeforeClass() { if (!extension_loaded('redis')) { static::$cache = null; return; } $redis = new \Redis(); $redis->connect('127.0.0.1'); $redis->select(1); $redis->flushAll(); static::$cache = new \Cachalot\RedisCache($redis, 'cachalot-test:'); }
public function connectRedis($host, $port, $db) { // Cache in Redis $cacheRedis = new Redis(); $cacheRedis->connect($host, $port); $cacheRedis->select($db); $cacheResult = $cacheRedis->flushAll(); if ($cacheResult == 1) { Mage::getSingleton('core/session')->addSuccess(Mage::helper('gaugeinteractive_redis')->__('Redis has been flushed.')); } else { Mage::getSingleton('core/session')->addError(Mage::helper('gaugeinteractive_redis')->__('An error occurred when flushing Redis.')); } }
function my_onStart($serv) { $redis = new Redis(); $redis->pconnect('127.0.0.1', 6379); $redis->flushAll(); $work_arr = array(); for ($i = 0; $i < $serv->setting['task_worker_num']; $i++) { $redis->lpush('free', $i); $work_arr[] = $i; } echo "MasterPid={$serv->master_pid}|Manager_pid={$serv->manager_pid}\n"; echo "Server: start.Swoole version is [" . SWOOLE_VERSION . "]\n"; }
/** * 删除指定key的缓存 * * 若 `$key===true` 则表示删除全部 * * // 支持下面的方式 * $this->delete('abc'); * $this->delete('abc', 'abc2'); * $this->delete(['abc', 'abc2']); * * // 删除全部 * $this->delete(true); * // 也可使用 * $this->delete_all(); * * @param string|array|true $key */ public function delete($key) { $this->_connect(); if (true === $key) { return $this->_redis->flushAll(); } else { if (is_array($key)) { $keys = $key; } else { $keys = func_get_args(); } return $this->_redis->delete($keys); } }
/** * Flush all data from the cache server? */ public function flush() { if ($this->ping()) { switch (NN_CACHE_TYPE) { case self::TYPE_REDIS: $this->server->flushAll(); break; case self::TYPE_MEMCACHED: $this->server->flush(); break; case self::TYPE_APC: apc_clear_cache("user"); apc_clear_cache(); break; } } }
/** * Remove all items from the cache (flush it). * * @return void */ function deleteAll() { $this->connection->flushAll(); }
/** * Deletes all cache entries * * @return bool */ public function clear() { return $this->cache->flushAll(); }
public function testflushAll() { $this->redis->set('x', 'y'); $this->assertTrue($this->redis->flushAll()); $this->assertTrue($this->redis->getKeys('*') === array()); }
public function clear() { $this->redis->flushAll(); }
public function flush() { $this->redis->flushAll(); }
<?php // change the following paths if necessary require_once 'inc/tags/lib/Loader.class.php'; WF_Loader::registerAutoload(); require_once "inc/tags/TagArticles.inc.php"; require_once "inc/tags/Tag.inc.php"; require_once "inc/tags/ArticleTags.inc.php"; require_once "inc/tags/ArticleMini.inc.php"; require_once "inc/tags/TagsKey.inc.php"; require_once "inc/tags/TagSite.inc.php"; require __DIR__ . '/fixtures/util.func.php'; $conf = (require __DIR__ . '/config/test.conf.php'); define("ROOT_DIR", __DIR__); WF_Registry::set('logger', new WF_Logger()); $instance = WF_Db::instance($conf['db']); WF_Registry::set('db', $instance); unset($instance); WF_DbTestCase::setBasePath(ROOT_DIR . "/fixtures"); WF_Event::bind('addArticleTag', array(TagArticles::model(), 'onAddArticleTag')); WF_Event::bind('removeArticleTag', array(TagArticles::model(), 'onRemoveArticleTag')); $redis = new Redis(); $redis_config = $conf['redis']; $redis->connect($redis_config['host'], $redis_config['port']); $redis->flushAll(); WF_Registry::set('cache', $redis); WF_Registry::set('redis', $redis); WF_Config::set('tagitem_use_cache', true); TagSite::refresh(__DIR__ . '/data/sites.dat'); $id = TagSite::getSiteId('news');
/** * {@inheritdoc} */ protected function doFlush() { return $this->_redis->flushAll(); }
function it_flushes_cache(\Redis $redis) { $redis->flushAll(); $this->flush(); }