本文整理汇总了PHP中Predis\Client::pipeline方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::pipeline方法的具体用法?PHP Client::pipeline怎么用?PHP Client::pipeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::pipeline方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: markUserOnline
public function markUserOnline($pageKey, $userIdent)
{
$thisMinute = floor(time() / 60) * 60;
$key = $this->makeUsersOnlineKey($pageKey, $thisMinute);
$this->redis->pipeline(function (Pipeline $p) use($key, $userIdent) {
$p->sadd($key, $userIdent);
$p->expire($key, self::ONLINE_MINUTES * 60);
});
}
示例2: multiPut
/**
* @param string $queueName
* @param array $workloads
*/
public function multiPut($queueName, array $workloads)
{
$pipeline = $this->predis->pipeline();
foreach ($workloads as $workload) {
/** @noinspection PhpUndefinedMethodInspection */
$pipeline->lpush($queueName, serialize($workload));
}
$pipeline->execute();
}
示例3: set
public function set($keyValue)
{
$pipe = $this->redis->pipeline();
foreach ($keyValue as $key => $value) {
if (!is_null($value)) {
$value = json_encode($value);
$pipe->setex($key, 86400, $value);
// 缓存 1 天
}
}
return $pipe->execute();
}
示例4: updateValues
/**
*
*/
private function updateValues()
{
$this->registeredStates = $this->redis->smembers(self::STATE_MACHINE_NAMESPACE . 'registry');
if (count($this->registeredStates) > 0) {
$currentValueRedisKeys = array_map([$this, 'buildCurrentKey'], $this->registeredStates);
$previousValueRedisKeys = array_map([$this, 'buildPreviousKey'], $this->registeredStates);
list($currentValues, $previousValues) = $this->redis->pipeline(function (Pipeline $pipe) use($currentValueRedisKeys, $previousValueRedisKeys) {
$pipe->mget($currentValueRedisKeys);
$pipe->mget($previousValueRedisKeys);
});
$this->currentValues = array_combine($this->registeredStates, $currentValues);
$this->previousValues = array_combine($this->registeredStates, $previousValues);
}
}
示例5: setMany
/**
* Inserts many items in the cache.
*
* @param array $values
* @param int $minutes
*
* @return mixed
*/
public function setMany(array $values, int $minutes)
{
$this->predis->pipeline(function ($pipe) use($values, $minutes) {
foreach ($values as $key => $value) {
$value = is_numeric($value) ? $value : serialize($value);
$pipe->setex($this->prefix . $key, 60 * $minutes, $value);
}
});
}
示例6: remClear
/**
* Clear the entire cache.
*/
public static function remClear()
{
$keys = self::remAllKeys();
self::$_redis->pipeline(function ($pipe) use($keys) {
foreach ($keys as $key) {
Rem::remDeleteKey($key, $pipe);
}
});
}
示例7: storePosts
/**
* Batch store
*/
public function storePosts()
{
if (!$this->isValid()) {
return false;
}
try {
// would break this up i.e. only pipeline 5000 at a time
$this->storage->pipeline(function ($pipe) {
foreach ($this->rawpost->getData() as $data) {
$postback = [];
$postback['method'] = $this->rawpost->getMethod();
$postback['url'] = $this->rawpost->getUrl();
$postback['data'] = $data;
$pipe->lpush('job-queue', json_encode($postback));
}
});
} catch (\Exception $e) {
$this->error = $e->getMessage();
return false;
}
return true;
}
示例8: testPipelineWithArrayAndCallableExecutesPipelineWithOptions
/**
* @group disconnected
*/
public function testPipelineWithArrayAndCallableExecutesPipelineWithOptions()
{
$executor = $this->getMock('Predis\\Pipeline\\PipelineExecutorInterface');
$options = array('executor' => $executor);
$test = $this;
$mockCallback = function ($pipeline) use($executor, $test) {
$reflection = new \ReflectionProperty($pipeline, 'executor');
$reflection->setAccessible(true);
$test->assertSame($executor, $reflection->getValue($pipeline));
};
$callable = $this->getMock('stdClass', array('__invoke'));
$callable->expects($this->once())->method('__invoke')->with($this->isInstanceOf('Predis\\Pipeline\\PipelineContext'))->will($this->returnCallback($mockCallback));
$client = new Client();
$client->pipeline($options, $callable);
}
示例9: createPipeline
public function createPipeline()
{
return $this->redis->pipeline();
}
示例10: testPipelineWithCallableExecutesPipeline
/**
* @group disconnected
*/
public function testPipelineWithCallableExecutesPipeline()
{
$callable = $this->getMock('stdClass', array('__invoke'));
$callable->expects($this->once())->method('__invoke')->with($this->isInstanceOf('Predis\\Pipeline\\Pipeline'));
$client = new Client();
$client->pipeline($callable);
}