예제 #1
1
 /**
  * @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();
 }
예제 #2
0
	/**
	 * 清空数据
	 */
	public function clearAll() {
		try {
			return $this->_redis->flushAll();
		} catch (Exception $e) {
			$this->_error = $e->getMessage();
			return false;
		}
	}
예제 #3
0
 /**
  * 删除指定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);
     }
 }
예제 #4
0
파일: Cache.php 프로젝트: sebst3r/nZEDb
 /**
  * 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();
         }
     }
 }
예제 #5
0
 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:');
 }
예제 #6
0
 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.'));
     }
 }
예제 #7
0
 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";
 }
예제 #8
0
 /**
  * 删除指定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);
     }
 }
예제 #9
0
 /**
  * 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;
         }
     }
 }
예제 #10
0
 /**
  * Remove all items from the cache (flush it).
  *
  * @return void
  */
 function deleteAll()
 {
     $this->connection->flushAll();
 }
예제 #11
0
 /**
  * Deletes all cache entries
  *
  * @return bool
  */
 public function clear()
 {
     return $this->cache->flushAll();
 }
예제 #12
0
 public function testflushAll()
 {
     $this->redis->set('x', 'y');
     $this->assertTrue($this->redis->flushAll());
     $this->assertTrue($this->redis->getKeys('*') === array());
 }
예제 #13
0
 public function clear()
 {
     $this->redis->flushAll();
 }
예제 #14
0
파일: Redis.php 프로젝트: icambridge/hoard
 public function flush()
 {
     $this->redis->flushAll();
 }
예제 #15
0
<?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');
예제 #16
0
 /**
  * {@inheritdoc}
  */
 protected function doFlush()
 {
     return $this->_redis->flushAll();
 }
예제 #17
0
 function it_flushes_cache(\Redis $redis)
 {
     $redis->flushAll();
     $this->flush();
 }