本文整理匯總了PHP中Predis\Client::getOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::getOptions方法的具體用法?PHP Client::getOptions怎麽用?PHP Client::getOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Predis\Client
的用法示例。
在下文中一共展示了Client::getOptions方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getTextsByUser
/**
* @param $hostUid
* @param $key
* @return null|UserText
*/
public function getTextsByUser($hostUid, $cached = true)
{
if ($cached) {
$pattern = $this->buildKey($hostUid, '*', '*');
$prefix = $this->redis->getOptions()->prefix;
$redisKeys = array_map(function ($redisKey) use($prefix) {
if (substr($redisKey, 0, strlen($prefix)) == $prefix) {
$redisKey = substr($redisKey, strlen($prefix));
}
return $redisKey;
}, $this->redis->keys($pattern));
if (count($redisKeys) > 0) {
$result = array_combine($redisKeys, $this->redis->mget($redisKeys));
foreach ($result as $redisKey => $text) {
list(, , $userId, , $key, $lang) = explode(':', $redisKey);
$this->texts[$userId][$key][$lang] = $text;
}
}
}
if (!$cached || !isset($this->texts[$hostUid]) || !$this->texts[$hostUid]) {
$this->texts[$hostUid] = $this->getTextsByHostFromMysql($hostUid);
$mset = [];
foreach ($this->texts[$hostUid] as $key => $langs) {
foreach ($langs as $lang => $text) {
$mset[$this->buildKey($hostUid, $key, $lang)] = $text;
}
}
if ($mset) {
$this->redis->mset($mset);
}
}
return $this->texts[$hostUid];
}
示例2: getKeys
/**
* @param $queueName
*/
private function getKeys($queueName, $useCache = false)
{
if (empty($this->keys) || !$useCache) {
$this->keys = $this->redis->keys($this->getKeyPrefix($queueName) . '*');
}
$prefix = (string) $this->redis->getOptions()->prefix;
$this->keys = array_map(function ($key) use($prefix) {
return preg_replace('/^' . $prefix . '/', '', $key);
}, $this->keys);
return $this->keys;
}
示例3: purge
/**
* {@inheritdoc}
*/
protected function purge()
{
try {
$this->client->transaction(function ($tx) {
$keyPrefix = $this->client->getOptions()->prefix;
foreach (new \Predis\Collection\Iterator\Keyspace($this->client, '*') as $key) {
$tx->del(substr($key, strlen($keyPrefix)));
}
});
} catch (\Predis\Transaction\AbortedMultiExecException $e) {
return false;
}
return true;
}
示例4: getParametersAndOptions
protected function getParametersAndOptions(Client $client)
{
$parameters = $client->getConnection()->getParameters();
$options = $client->getOptions();
return array($parameters, $options);
}
示例5: findSidsInRedis
/**
* @return array
*/
public function findSidsInRedis()
{
$prefix = (string) $this->redis->getOptions()->prefix;
$pattern = $this->getKey('');
$prefixWithPattern = $prefix . $pattern;
$keys = $this->redis->keys($pattern . '*');
$sids = array_map(function ($key) use($prefixWithPattern) {
return str_replace($prefixWithPattern, '', $key);
}, $keys);
return $sids;
}
示例6: testConstructorWithNullAndNullArguments
/**
* @group disconnected
*/
public function testConstructorWithNullAndNullArguments()
{
$client = new Client(null, null);
$connection = $client->getConnection();
$this->assertInstanceOf('Predis\\Connection\\SingleConnectionInterface', $connection);
$parameters = $connection->getParameters();
$this->assertSame($parameters->host, '127.0.0.1');
$this->assertSame($parameters->port, 6379);
$options = $client->getOptions();
$this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion());
$this->assertFalse($client->isConnected());
}
示例7: getKeys
public function getKeys($pattern = '*')
{
$prefix = null;
if ($this->client->getOptions()->__isset("prefix")) {
$prefix = $this->client->getOptions()->__get("prefix")->getPrefix();
}
$keys = $this->client->keys($pattern);
if ($prefix) {
if (is_array($keys)) {
for ($i = 0; $i < count($keys); $i++) {
$keys[$i] = str_replace($prefix, '', $keys[$i]);
}
} else {
$keys = str_replace($prefix, '', $keys);
}
}
return $keys;
}
示例8: testCreateClientWithConnectionFromAggregatedConnection
/**
* @group disconnected
*/
public function testCreateClientWithConnectionFromAggregatedConnection()
{
$client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('prefix' => 'pfx:'));
$this->assertInstanceOf('Predis\\Connection\\ClusterConnectionInterface', $cluster = $client->getConnection());
$this->assertInstanceOf('Predis\\Connection\\SingleConnectionInterface', $node01 = $client->getConnectionById('node01'));
$this->assertInstanceOf('Predis\\Connection\\SingleConnectionInterface', $node02 = $client->getConnectionById('node02'));
$clientNode02 = $client->getClientFor('node02');
$this->assertInstanceOf('Predis\\Client', $clientNode02);
$this->assertSame($node02, $clientNode02->getConnection());
$this->assertSame($client->getOptions(), $clientNode02->getOptions());
}