/** * Delete all the keys in the Redis database * * @throws ModuleException */ public function cleanup() { try { $this->driver->flushdb(); } catch (\Exception $e) { throw new ModuleException(__CLASS__, $e->getMessage()); } }
/** * Returns a new client instance. * * @return Client */ protected function getClient() { $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'iterable_multibulk' => true, 'read_write_timeout' => 2); $client = new Client($parameters, REDIS_SERVER_VERSION); $client->connect(); $client->select(REDIS_SERVER_DBNUM); $client->flushdb(); return $client; }
/** @BeforeFeature */ public static function setupFeature(FeatureEvent $event) { try { $redis = new Client('tcp://127.0.0.1:6379'); $redis->select(15); $redis->flushdb(); } catch (\Exception $e) { echo "Redis Server is needed to test features!" . PHP_EOL; throw $e; } }
public function setUp() { if (!class_exists('Predis\\Client')) { $this->markTestSkipped('The ' . __CLASS__ . ' requires Predis to be available'); } try { $client = new Client(); $client->connect(); $client->flushdb(); } catch (ConnectionException $e) { $this->markTestSkipped('The ' . __CLASS__ . ' requires the use of a Redis Server'); } $this->storage = new RedisStorage($client); }
/** * {@inheritdoc} */ public function clear($key = null) { if (is_null($key)) { $this->redis->flushdb(); return true; } $keyString = $this->makeKeyString($key, true); $keyReal = $this->makeKeyString($key); $this->redis->incr($keyString); // increment index for children items $this->redis->del($keyReal); // remove direct item. $this->keyCache = array(); return true; }
public function setUp() { if (!class_exists('\\Predis\\Client', true)) { $this->markTestSkipped('PRedis is not installed'); } $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); // setup the default timeout (avoid max execution time) socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 1, 'usec' => 0)); $result = @socket_connect($socket, '127.0.0.1', 6379); if (!$result) { $this->markTestSkipped('Redis is not running'); } socket_close($socket); $client = new Client(array('host' => '127.0.0.1', 'port' => 6379, 'database' => 42)); $client->flushdb(); }
/** * Returns a new client instance. * * @param Boolean $connect Flush selected database before returning the client. * @return Client */ protected function getClient($flushdb = true) { $profile = $this->getProfile(); if (!$profile->supportsCommand($id = $this->getExpectedId())) { $this->markTestSkipped("The profile {$profile->getVersion()} does not support command {$id}"); } $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT); $options = array('profile' => $profile); $client = new Client($parameters, $options); $client->connect(); $client->select(REDIS_SERVER_DBNUM); if ($flushdb) { $client->flushdb(); } return $client; }
/** * {@inheritdoc} */ protected function doFlush() { return (bool) $this->redis->flushdb(); }
/** * Returns a new client instance. * * @return Client */ protected function getClient() { $parameters = $this->getParameters(array('read_write_timeout' => 2)); $protocol = new TextProtocolProcessor(); $protocol->useIterableMultibulk(true); $connection = new CompositeStreamConnection($parameters, $protocol); $client = new Client($connection); $client->connect(); $client->flushdb(); return $client; }
public function clearAll() { $this->redis->flushdb(); }
/** * Returns a new client instance. * * @param array $parameters Additional connection parameters. * @param array $options Additional client options. * @param bool $flushdb Flush selected database before returning the client. * @return Client */ protected function createClient(array $parameters = null, array $options = null, $flushdb = true) { $parameters = array_merge($this->getDefaultParametersArray(), $parameters ?: array()); $options = array_merge(array('profile' => $this->getProfile()), $options ?: array()); $client = new Client($parameters, $options); $client->connect(); if ($flushdb) { $client->flushdb(); } return $client; }
/** * @inheritdoc */ public function clear() { return $this->predis->flushdb(); }
public function flushAll() { $this->redis->flushdb(); }
<?php use Bravo3\Orm\Drivers\Filesystem\FilesystemDriver; use Bravo3\Orm\Drivers\Filesystem\Io\NativeIoDriver; use Bravo3\Orm\Mappers\Annotation\AnnotationMapper; use Bravo3\Orm\Mappers\Portation\MapWriterInterface; use Bravo3\Orm\Mappers\Yaml\YamlMapWriter; use Bravo3\Orm\Services\EntityLocator; use Bravo3\Orm\Services\EntityManager; use Bravo3\Properties\Conf; use Predis\Client; require __DIR__ . '/../vendor/autoload.php'; Conf::init(__DIR__ . '/config/', 'parameters.yml'); $redis = new Client(['host' => Conf::get('parameters.redis_host'), 'port' => Conf::get('parameters.redis_port'), 'database' => Conf::get('parameters.redis_database')]); $redis->flushdb(); // Solely for portation (reading metadata) - will never do anything $em = EntityManager::build(new FilesystemDriver(new NativeIoDriver('/dev/null')), new AnnotationMapper()); $locator = new EntityLocator($em); $entities = $locator->locateEntities(__DIR__ . '/Bravo3/Orm/Tests/Entities', 'Bravo3\\Orm\\Tests\\Entities'); /** @var MapWriterInterface[] $porters */ $porters = [new YamlMapWriter(__DIR__ . '/Bravo3/Orm/Tests/Resources/mappings.yml')]; foreach ($porters as $porter) { $porter->setInputManager($em); foreach ($entities as $class_name) { $porter->compileMetadataForEntity($class_name); } $porter->flush(); }
protected function setUp() { $this->client = $this->createClient(); $this->redis_client = new \Predis\Client(); $this->redis_client->flushdb(); }
/** * {@inheritdoc} */ protected function doFlush() { $response = $this->client->flushdb(); return $response === true || $response == 'OK'; }
public function tearDown() { parent::tearDown(); $this->redis->flushdb(); }
/** * Deletes all item in the cache. * * @return void */ public function flush() { $this->predis->flushdb(); }
/** * Returns a client instance connected to the specified Redis * server instance to perform integration tests. * * @param array Additional connection parameters. * @param array Additional client options. * @return Client client instance. */ protected function getClient(array $parameters = array(), array $options = array()) { $parameters = array_merge(array('scheme' => 'tcp', 'host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'database' => REDIS_SERVER_DBNUM), $parameters); $options = array_merge(array('profile' => REDIS_SERVER_VERSION), $options); $client = new Client($parameters, $options); $client->connect(); $client->flushdb(); return $client; }
/** * Remove *all* values from cache * * @return boolean true on success, false on failure */ protected function purge() { $this->redis->flushdb(); }
public function tearDown() { $this->redis->flushdb(); \Mockery::close(); }
/** * ### Deletes the redis cache * * @return bool */ public function flush() { $this->conn->flushdb(); return true; }
public function flush() { $this->flushIndex(); $this->store->flushdb(); return $this; }