perf: 增加原生缓存

This commit is contained in:
Ying
2023-06-19 14:36:07 +08:00
parent 2b8f874450
commit 331d7b0582
1486 changed files with 105475 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<?php
namespace Illuminate\Redis\Connections;
use Closure;
use Illuminate\Contracts\Redis\Connection as ConnectionContract;
/**
* @mixin \Predis\Client
*/
class PredisConnection extends Connection implements ConnectionContract
{
/**
* The Predis client.
*
* @var \Predis\Client
*/
protected $client;
/**
* Create a new Predis connection.
*
* @param \Predis\Client $client
* @return void
*/
public function __construct($client)
{
$this->client = $client;
}
/**
* Subscribe to a set of given channels for messages.
*
* @param array|string $channels
* @param \Closure $callback
* @param string $method
* @return void
*/
public function createSubscription($channels, Closure $callback, $method = 'subscribe')
{
$loop = $this->pubSubLoop();
$loop->{$method}(...array_values((array) $channels));
foreach ($loop as $message) {
if ($message->kind === 'message' || $message->kind === 'pmessage') {
$callback($message->payload, $message->channel);
}
}
unset($loop);
}
}