Revert "Merge tag 'v2.10.6'"

This reverts commit 122ea4ab9e, reversing
changes made to c54a11e250.
This commit is contained in:
2024-02-16 23:06:09 -06:00
parent 122ea4ab9e
commit 6c08ee9675
521 changed files with 12363 additions and 14503 deletions

View File

@@ -10,8 +10,8 @@ class EventTracingCache implements CacheInterface
{
private CacheInterface $engine;
private \EventTracer $tracer;
private int $hits = 0;
private int $misses = 0;
private int $hits=0;
private int $misses=0;
public function __construct(CacheInterface $engine, \EventTracer $tracer)
{
@@ -19,7 +19,7 @@ class EventTracingCache implements CacheInterface
$this->tracer = $tracer;
}
public function get($key, $default = null)
public function get($key, $default=null)
{
if ($key === "__etc_cache_hits") {
return $this->hits;
@@ -29,7 +29,7 @@ class EventTracingCache implements CacheInterface
}
$sentinel = "__etc_sentinel";
$this->tracer->begin("Cache Get", ["key" => $key]);
$this->tracer->begin("Cache Get", ["key"=>$key]);
$val = $this->engine->get($key, $sentinel);
if ($val != $sentinel) {
$res = "hit";
@@ -39,13 +39,13 @@ class EventTracingCache implements CacheInterface
$val = $default;
$this->misses++;
}
$this->tracer->end(null, ["result" => $res]);
$this->tracer->end(null, ["result"=>$res]);
return $val;
}
public function set($key, $value, $ttl = null)
{
$this->tracer->begin("Cache Set", ["key" => $key, "ttl" => $ttl]);
$this->tracer->begin("Cache Set", ["key"=>$key, "ttl"=>$ttl]);
$val = $this->engine->set($key, $value, $ttl);
$this->tracer->end();
return $val;
@@ -53,7 +53,7 @@ class EventTracingCache implements CacheInterface
public function delete($key)
{
$this->tracer->begin("Cache Delete", ["key" => $key]);
$this->tracer->begin("Cache Delete", ["key"=>$key]);
$val = $this->engine->delete($key);
$this->tracer->end();
return $val;
@@ -67,11 +67,6 @@ class EventTracingCache implements CacheInterface
return $val;
}
/**
* @param string[] $keys
* @param mixed $default
* @return iterable<mixed>
*/
public function getMultiple($keys, $default = null)
{
$this->tracer->begin("Cache Get Multiple", ["keys" => $keys]);
@@ -80,9 +75,6 @@ class EventTracingCache implements CacheInterface
return $val;
}
/**
* @param array<string, mixed> $values
*/
public function setMultiple($values, $ttl = null)
{
$this->tracer->begin("Cache Set Multiple", ["keys" => array_keys($values)]);
@@ -91,9 +83,6 @@ class EventTracingCache implements CacheInterface
return $val;
}
/**
* @param string[] $keys
*/
public function deleteMultiple($keys)
{
$this->tracer->begin("Cache Delete Multiple", ["keys" => $keys]);
@@ -104,35 +93,33 @@ class EventTracingCache implements CacheInterface
public function has($key)
{
$this->tracer->begin("Cache Has", ["key" => $key]);
$this->tracer->begin("Cache Has", ["key"=>$key]);
$val = $this->engine->has($key);
$this->tracer->end(null, ["exists" => $val]);
$this->tracer->end(null, ["exists"=>$val]);
return $val;
}
}
function loadCache(?string $dsn): CacheInterface
{
$matches = [];
$c = null;
if ($dsn && !isset($_GET['DISABLE_CACHE'])) {
$url = parse_url($dsn);
if($url) {
if ($url['scheme'] == "memcached" || $url['scheme'] == "memcache") {
$memcache = new \Memcached();
$memcache->addServer($url['host'], $url['port']);
$c = new \Sabre\Cache\Memcached($memcache);
} elseif ($url['scheme'] == "apc") {
$c = new \Sabre\Cache\Apcu();
} elseif ($url['scheme'] == "redis") {
$redis = new \Predis\Client([
'scheme' => 'tcp',
'host' => $url['host'] ?? "127.0.0.1",
'port' => $url['port'] ?? 6379,
'username' => $url['user'] ?? null,
'password' => $url['pass'] ?? null,
], ['prefix' => 'shm:']);
$c = new \Naroga\RedisCache\Redis($redis);
}
if ($dsn && preg_match("#(.*)://(.*)#", $dsn, $matches) && !isset($_GET['DISABLE_CACHE'])) {
if ($matches[1] == "memcached" || $matches[1] == "memcache") {
$hp = explode(":", $matches[2]);
$memcache = new \Memcached();
$memcache->addServer($hp[0], (int)$hp[1]);
$c = new \Sabre\Cache\Memcached($memcache);
} elseif ($matches[1] == "apc") {
$c = new \Sabre\Cache\Apcu();
} elseif ($matches[1] == "redis") {
$hp = explode(":", $matches[2]);
$redis = new \Predis\Client([
'scheme' => 'tcp',
'host' => $hp[0],
'port' => (int)$hp[1]
], ['prefix' => 'shm:']);
$c = new \Naroga\RedisCache\Redis($redis);
}
}
if(is_null($c)) {