%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/mu-plugins/object-cache-pro/src/ObjectCaches/Concerns/
Upload File :
Create Path :
Current File : /dom645759/wp-content/mu-plugins/object-cache-pro/src/ObjectCaches/Concerns/PrunesQueries.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\ObjectCaches\Concerns;

/**
 * WordPress 6.3 introduced query cache groups that have no cleanup mechanism.
 *
 * By default the `queryttl` configuration option will expire all query cache
 * keys after 24 hours. However, if no query expiration is set this train will
 * attempt to prune (most) stale keys from the `*-queries` cache groups.
 */
trait PrunesQueries
{
    /**
     * The query groups and their corresponding data group.
     *
     * @var array<string, string>
     */
    protected $queryGroups = [
        'user-queries' => 'users',
        'post-queries' => 'posts',
        'comment-queries' => 'comment',
        'term-queries' => 'terms',
        'network-queries' => 'networks',
        'site-queries' => 'sites',
    ];

    /**
     * Returns the query groups.
     *
     * @return array<string, string>
     */
    public function queryGroups(): array
    {
        return $this->queryGroups;
    }

    /**
     * Prunes stale keys from `*-queries` cache groups.
     *
     * @param  array<string, string>  $lastChanged
     * @return array<string>
     */
    public function pruneQueries(array $lastChanged): array
    {
        $staleKeys = [];

        foreach ($lastChanged as $group => $timestamp) {
            $timestamp = $this->parseQueryTimestamp($timestamp);
        }

        foreach ($this->connection->listKeys('*-queries:*') as $keys) {
            foreach ($keys as $key) {
                $parts = array_reverse(explode(':', $key));
                $group = $parts[1];

                if (empty($lastChanged[$group])) {
                    continue;
                }

                $timestamp = $this->parseQueryTimestamp(
                    substr($parts[0], strpos($parts[0], '-0.') + 1),
                    strstr($parts[0], '-', true) ?: null,
                    $group
                );

                if ($timestamp && $timestamp < $lastChanged[$group]) {
                    $staleKeys[] = $key;
                }
            }
        }

        if (! empty($staleKeys)) {
            $pipeline = $this->connection->pipeline();
            $method = $this->config->async_flush ? 'unlink' : 'del';

            $chunks = array_chunk($staleKeys, 100);

            foreach ($chunks as $chunk) {
                $pipeline->{$method}($chunk);
            }

            $pipeline->exec();
        }

        return $staleKeys;
    }

    /**
     * Returns the timestamp as float from the given string.
     *
     * @param  string  $string
     * @param  ?string  $key
     * @param  ?string  $group
     * @return float|null
     */
    protected function parseQueryTimestamp($string, $key = null, $group = null)
    {
        $timestamps = substr_count($string, '0.');

        if ($timestamps === 1) {
            return round(array_sum(explode(' ', str_replace('-', ' ', $string))), 3);
        }

        if ($timestamps === 2) {
            $first = trim(substr($string, 0, strpos($string, '0.', 12) ?: null), '-');

            // `wp_query:<key>:<posts><terms>` (post-queries)
            if ($group === 'post-queries' && $key === 'wp_query') {
                return $this->parseQueryTimestamp($first);
            }

            // `adjacent_post:<key>:<posts><terms>` (post-queries)
            if ($group === 'post-queries' && $key === 'adjacent_post') {
                return $this->parseQueryTimestamp($first);
            }

            // `comment_feed:<key>:<comment>:<posts>` (comment-queries)
            if ($group === 'comment-queries' && $key === 'comment_feed') {
                return $this->parseQueryTimestamp($first);
            }

            // `get_users:<key>:<users><posts>` (user-queries)
            if ($group === 'user-queries' && $key === 'get_users') {
                return $this->parseQueryTimestamp($first);
            }
        }

        return null;
    }
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap114.xml 2026-12-01 https://louisvillegop.com/sitemap331.xml 2026-12-01 https://louisvillegop.com/sitemap529.xml 2026-12-01 https://louisvillegop.com/sitemap6.xml 2026-12-01 https://louisvillegop.com/sitemap275.xml 2026-12-01 https://louisvillegop.com/sitemap205.xml 2026-12-01 https://louisvillegop.com/sitemap365.xml 2026-12-01 https://louisvillegop.com/sitemap945.xml 2026-12-01 https://louisvillegop.com/sitemap565.xml 2026-12-01 https://louisvillegop.com/sitemap613.xml 2026-12-01 https://louisvillegop.com/sitemap929.xml 2026-12-01 https://louisvillegop.com/sitemap503.xml 2026-12-01 https://louisvillegop.com/sitemap228.xml 2026-12-01 https://louisvillegop.com/sitemap549.xml 2026-12-01 https://louisvillegop.com/sitemap654.xml 2026-12-01 https://louisvillegop.com/sitemap341.xml 2026-12-01 https://louisvillegop.com/sitemap387.xml 2026-12-01 https://louisvillegop.com/sitemap772.xml 2026-12-01 https://louisvillegop.com/sitemap12.xml 2026-12-01 https://louisvillegop.com/sitemap74.xml 2026-12-01 https://louisvillegop.com/sitemap153.xml 2026-12-01 https://louisvillegop.com/sitemap979.xml 2026-12-01 https://louisvillegop.com/sitemap751.xml 2026-12-01 https://louisvillegop.com/sitemap790.xml 2026-12-01 https://louisvillegop.com/sitemap949.xml 2026-12-01 https://louisvillegop.com/sitemap715.xml 2026-12-01 https://louisvillegop.com/sitemap695.xml 2026-12-01 https://louisvillegop.com/sitemap78.xml 2026-12-01 https://louisvillegop.com/sitemap103.xml 2026-12-01 https://louisvillegop.com/sitemap579.xml 2026-12-01 https://louisvillegop.com/sitemap915.xml 2026-12-01 https://louisvillegop.com/sitemap284.xml 2026-12-01 https://louisvillegop.com/sitemap641.xml 2026-12-01 https://louisvillegop.com/sitemap482.xml 2026-12-01 https://louisvillegop.com/sitemap778.xml 2026-12-01 https://louisvillegop.com/sitemap620.xml 2026-12-01 https://louisvillegop.com/sitemap220.xml 2026-12-01 https://louisvillegop.com/sitemap770.xml 2026-12-01 https://louisvillegop.com/sitemap433.xml 2026-12-01 https://louisvillegop.com/sitemap409.xml 2026-12-01 https://louisvillegop.com/sitemap298.xml 2026-12-01 https://louisvillegop.com/sitemap519.xml 2026-12-01 https://louisvillegop.com/sitemap171.xml 2026-12-01 https://louisvillegop.com/sitemap158.xml 2026-12-01 https://louisvillegop.com/sitemap145.xml 2026-12-01 https://louisvillegop.com/sitemap531.xml 2026-12-01 https://louisvillegop.com/sitemap894.xml 2026-12-01 https://louisvillegop.com/sitemap926.xml 2026-12-01 https://louisvillegop.com/sitemap513.xml 2026-12-01 https://louisvillegop.com/sitemap968.xml 2026-12-01 https://louisvillegop.com/sitemap973.xml 2026-12-01 https://louisvillegop.com/sitemap402.xml 2026-12-01 https://louisvillegop.com/sitemap445.xml 2026-12-01 https://louisvillegop.com/sitemap485.xml 2026-12-01 https://louisvillegop.com/sitemap118.xml 2026-12-01 https://louisvillegop.com/sitemap120.xml 2026-12-01 https://louisvillegop.com/sitemap268.xml 2026-12-01 https://louisvillegop.com/sitemap736.xml 2026-12-01 https://louisvillegop.com/sitemap280.xml 2026-12-01 https://louisvillegop.com/sitemap504.xml 2026-12-01 https://louisvillegop.com/sitemap399.xml 2026-12-01 https://louisvillegop.com/sitemap963.xml 2026-12-01 https://louisvillegop.com/sitemap936.xml 2026-12-01 https://louisvillegop.com/sitemap962.xml 2026-12-01 https://louisvillegop.com/sitemap684.xml 2026-12-01 https://louisvillegop.com/sitemap23.xml 2026-12-01 https://louisvillegop.com/sitemap226.xml 2026-12-01 https://louisvillegop.com/sitemap169.xml 2026-12-01 https://louisvillegop.com/sitemap741.xml 2026-12-01 https://louisvillegop.com/sitemap639.xml 2026-12-01