本文整理汇总了PHP中Predis\Client::flushdb方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::flushdb方法的具体用法?PHP Client::flushdb怎么用?PHP Client::flushdb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::flushdb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanup
/**
* 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());
}
}
示例2: getClient
/**
* 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;
}
示例3: setupFeature
/** @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;
}
}
示例4: setUp
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);
}
示例5: clear
/**
* {@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;
}
示例6: setUp
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();
}
示例7: getClient
/**
* 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;
}
示例8: doFlush
/**
* {@inheritdoc}
*/
protected function doFlush()
{
return (bool) $this->redis->flushdb();
}
示例9: getClient
/**
* 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;
}
示例10: clearAll
public function clearAll()
{
$this->redis->flushdb();
}
示例11: createClient
/**
* 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;
}
示例12: clear
/**
* @inheritdoc
*/
public function clear()
{
return $this->predis->flushdb();
}
示例13: flushAll
public function flushAll()
{
$this->redis->flushdb();
}
示例14: Client
<?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();
}
示例15: setUp
protected function setUp()
{
$this->client = $this->createClient();
$this->redis_client = new \Predis\Client();
$this->redis_client->flushdb();
}