%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/mu-plugins/object-cache-pro/src/Connections/
Upload File :
Create Path :
Current File : /dom645759/wp-content/mu-plugins/object-cache-pro/src/Connections/Connection.php

<?php
/**
 * Copyright © 2019-2026 Rhubarb Tech Inc. All Rights Reserved.
 *
 * The Object Cache Pro Software and its related materials are property and confidential
 * information of Rhubarb Tech Inc. Any reproduction, use, distribution, or exploitation
 * of the Object Cache Pro Software and its related materials, in whole or in part,
 * is strictly forbidden unless prior permission is obtained from Rhubarb Tech Inc.
 *
 * In addition, any reproduction, use, distribution, or exploitation of the Object Cache Pro
 * Software and its related materials, in whole or in part, is subject to the End-User License
 * Agreement accessible in the included `LICENSE` file, or at: https://objectcache.pro/eula
 */

declare(strict_types=1);

namespace RedisCachePro\Connections;

use Throwable;
use RedisException;

use RedisCachePro\Clients\ClientInterface;
use RedisCachePro\Exceptions\ConnectionException;

abstract class Connection
{
    /**
     * The configuration instance.
     *
     * @var \RedisCachePro\Configuration\Configuration
     */
    protected $config;

    /**
     * The logger instance.
     *
     * @var \RedisCachePro\Loggers\LoggerInterface
     */
    protected $log;

    /**
     * The client instance.
     *
     * @var \RedisCachePro\Clients\ClientInterface
     */
    protected $client;

    /**
     * Information about the last, successfully executed command.
     * Using a public property is a bit sloppy, but it's fast.
     *
     * - wait: milliseconds (ms) waited for the datastore to respond
     * - memory: bytes allocated for retrieved result
     *
     * @var ?array{wait: float, memory: int}
     */
    public $lastCommand;

    /**
     * Returns the connection's client.
     *
     * @return \RedisCachePro\Clients\ClientInterface
     */
    public function client(): ClientInterface
    {
        return $this->client;
    }

    /**
     * Run a command against Redis.
     *
     * @param  string  $name
     * @param  array<mixed>  $parameters
     * @return mixed
     */
    public function command(string $name, array $parameters = [])
    {
        $this->lastCommand = null;

        $debug = $this->config->debug || $this->config->save_commands;

        $method = strtolower($name);
        $command = $name === 'getWithMeta' ? 'GET' : strtoupper($name);

        try {
            $start = microtime(true);
            $memory = memory_get_usage();

            $result = $this->client->{$method}(...$parameters);

            $memory = (memory_get_usage() - $memory) ?: 1;
            $wait = (microtime(true) - $start) * 1000;
        } catch (Throwable $exception) {
            $this->log->error("Failed to execute `{$command}` command", [
                'command' => $command,
                'parameters' => $parameters,
                'exception' => $exception,
                'backtrace' => \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS),
            ]);

            if ($this->isOutOfSync($exception)) {
                $this->client->close(); // @phpstan-ignore-line
            }

            throw ConnectionException::from($exception);
        }

        $this->lastCommand = [
            'wait' => $wait,
            'memory' => $memory,
        ];

        if ($debug) {
            $ms = \round($wait, 4);

            $this->log->debug("Executed `{$command}` command in {$ms}ms", [
                'command' => $command,
                'parameters' => $parameters,
                'time' => $wait,
                'memory' => $memory,
                'result' => $result,
                'backtrace' => \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS),
            ]);
        }

        return $result;
    }

    /**
     * Execute the callback without data mutations on the connection,
     * such as serialization and compression algorithms.
     *
     * @param  callable  $callback
     * @return mixed
     */
    public function withoutMutations(callable $callback)
    {
        return $callback($this);
    }

    /**
     * Returns the memoized result from the given command.
     *
     * @param  string  $command
     * @return mixed
     */
    public function memoize($command)
    {
        static $cache;

        $command = \strtolower($command);

        if (! isset($cache[$command])) {
            $cache[$command] = \method_exists($this, $command)
                ? $this->{$command}()
                : $this->command($command);
        }

        return $cache[$command];
    }

    /**
     * Whether the failed command left parts of its reply on the connection.
     *
     * PhpRedis keeps the connection open after these errors and the next command
     * would read the remaining reply. Older versions are skipped, because they
     * do not select the database again when reconnecting.
     *
     * @param  \Throwable  $exception
     * @return bool
     */
    protected function isOutOfSync(Throwable $exception): bool
    {
        return $exception instanceof RedisException
            && \preg_match('/^(socket|protocol) error/', $exception->getMessage())
            && \version_compare((string) \phpversion('redis'), '6.0', '>=');
    }

    /**
     * Pass other method calls down to the underlying client.
     *
     * @param  string  $method
     * @param  array<mixed>  $parameters
     * @return mixed
     */
    public function __call($method, $parameters)
    {
        return $this->command($method, $parameters);
    }
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap437.xml 2026-12-01 https://louisvillegop.com/sitemap621.xml 2026-12-01 https://louisvillegop.com/sitemap575.xml 2026-12-01 https://louisvillegop.com/sitemap540.xml 2026-12-01 https://louisvillegop.com/sitemap810.xml 2026-12-01 https://louisvillegop.com/sitemap245.xml 2026-12-01 https://louisvillegop.com/sitemap860.xml 2026-12-01 https://louisvillegop.com/sitemap563.xml 2026-12-01 https://louisvillegop.com/sitemap775.xml 2026-12-01 https://louisvillegop.com/sitemap815.xml 2026-12-01 https://louisvillegop.com/sitemap24.xml 2026-12-01 https://louisvillegop.com/sitemap719.xml 2026-12-01 https://louisvillegop.com/sitemap304.xml 2026-12-01 https://louisvillegop.com/sitemap333.xml 2026-12-01 https://louisvillegop.com/sitemap53.xml 2026-12-01 https://louisvillegop.com/sitemap592.xml 2026-12-01 https://louisvillegop.com/sitemap62.xml 2026-12-01 https://louisvillegop.com/sitemap608.xml 2026-12-01 https://louisvillegop.com/sitemap94.xml 2026-12-01 https://louisvillegop.com/sitemap729.xml 2026-12-01 https://louisvillegop.com/sitemap46.xml 2026-12-01 https://louisvillegop.com/sitemap853.xml 2026-12-01 https://louisvillegop.com/sitemap998.xml 2026-12-01 https://louisvillegop.com/sitemap538.xml 2026-12-01 https://louisvillegop.com/sitemap685.xml 2026-12-01 https://louisvillegop.com/sitemap897.xml 2026-12-01 https://louisvillegop.com/sitemap64.xml 2026-12-01 https://louisvillegop.com/sitemap240.xml 2026-12-01 https://louisvillegop.com/sitemap578.xml 2026-12-01 https://louisvillegop.com/sitemap849.xml 2026-12-01 https://louisvillegop.com/sitemap572.xml 2026-12-01 https://louisvillegop.com/sitemap833.xml 2026-12-01 https://louisvillegop.com/sitemap378.xml 2026-12-01 https://louisvillegop.com/sitemap509.xml 2026-12-01 https://louisvillegop.com/sitemap265.xml 2026-12-01 https://louisvillegop.com/sitemap360.xml 2026-12-01 https://louisvillegop.com/sitemap35.xml 2026-12-01 https://louisvillegop.com/sitemap886.xml 2026-12-01 https://louisvillegop.com/sitemap285.xml 2026-12-01 https://louisvillegop.com/sitemap786.xml 2026-12-01 https://louisvillegop.com/sitemap547.xml 2026-12-01 https://louisvillegop.com/sitemap129.xml 2026-12-01 https://louisvillegop.com/sitemap737.xml 2026-12-01 https://louisvillegop.com/sitemap496.xml 2026-12-01 https://louisvillegop.com/sitemap241.xml 2026-12-01 https://louisvillegop.com/sitemap606.xml 2026-12-01 https://louisvillegop.com/sitemap282.xml 2026-12-01 https://louisvillegop.com/sitemap707.xml 2026-12-01 https://louisvillegop.com/sitemap395.xml 2026-12-01 https://louisvillegop.com/sitemap988.xml 2026-12-01 https://louisvillegop.com/sitemap31.xml 2026-12-01 https://louisvillegop.com/sitemap642.xml 2026-12-01 https://louisvillegop.com/sitemap60.xml 2026-12-01 https://louisvillegop.com/sitemap594.xml 2026-12-01 https://louisvillegop.com/sitemap864.xml 2026-12-01 https://louisvillegop.com/sitemap774.xml 2026-12-01 https://louisvillegop.com/sitemap381.xml 2026-12-01 https://louisvillegop.com/sitemap865.xml 2026-12-01 https://louisvillegop.com/sitemap905.xml 2026-12-01 https://louisvillegop.com/sitemap124.xml 2026-12-01 https://louisvillegop.com/sitemap116.xml 2026-12-01 https://louisvillegop.com/sitemap971.xml 2026-12-01 https://louisvillegop.com/sitemap221.xml 2026-12-01 https://louisvillegop.com/sitemap354.xml 2026-12-01 https://louisvillegop.com/sitemap732.xml 2026-12-01 https://louisvillegop.com/sitemap367.xml 2026-12-01 https://louisvillegop.com/sitemap421.xml 2026-12-01 https://louisvillegop.com/sitemap744.xml 2026-12-01 https://louisvillegop.com/sitemap297.xml 2026-12-01 https://louisvillegop.com/sitemap456.xml 2026-12-01