Server : LiteSpeed
System : Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64
User : gazetufm ( 1431)
PHP Version : 8.1.35
Disable Function : NONE
Directory :  /home2/gazetufm/dumoshi.com/wp-content/plugins/wp-statistics/src/Traits/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: TransientCacheTrait.php

Path: //home2/gazetufm/dumoshi.com/wp-content/plugins/wp-statistics/src/Traits/TransientCacheTrait.php

Size: 1.43 KB

Permissions: 0644

<?php

namespace WP_Statistics\Traits;

/**
 * Trait to handle caching logic.
 * @doc https://github.com/wp-statistics/wp-statistics/wiki/TransientCacheTrait.md
 */
trait TransientCacheTrait
{
    /**
     * Get the cache key for the given input.
     *
     * @param string $input
     *
     * @return string
     */
    public function getCacheKey($input)
    {
        $hash = substr(md5($input), 0, 10);
        return sprintf('wp_statistics_cache_%s', $hash);
    }

    /**
     * Get the cached result for the given input.
     *
     * @param string $input
     *
     * @return mixed
     */
    public function getCachedResult($input)
    {
        $cacheKey = $this->getCacheKey($input);
        return get_transient($cacheKey);
    }

    /**
     * Set the cached result for the given input.
     *
     * @param string $input
     * @param mixed $result
     * @param int $expiration Expiration time for the cache in seconds.
     *
     * @return bool
     */
    public function setCachedResult($input, $result, $expiration = DAY_IN_SECONDS)
    {
        $cacheKey = $this->getCacheKey($input);
        return set_transient($cacheKey, $result, $expiration);
    }

    /**
     * Clear the cached result for the given input.
     *
     * @param string $input
     *
     * @return bool
     */
    protected function clearCachedResult($input)
    {
        $cacheKey = $this->getCacheKey($input);
        return delete_transient($cacheKey);
    }
}

← Back to Directory Edit File 🔒 Chmod

WP File Manager