Weak hands cannot be planted, meager skills have no foundation. Shallow wisdom is futile, how can one hope for a good name?扰扰从役倦，屑屑身事微。少壮轻年月，迟暮惜光辉。
<html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><?php

namespace WP_Statistics\Traits;

/**
 * Trait to handle caching logic.
 * @doc https://github.com/wp-statistics/wp-statistics/wiki/ObjectCacheTrait.md
 */
trait ObjectCacheTrait
{
    /**
     * Cached data to prevent duplicate queries.
     *
     * @var array
     */
    private $cache = [];

    /**
     * Sets a value in the cache.
     *
     * @param string $key The cache key.
     * @param mixed $value The value to cache.
     *
     * @return void
     */
    public function setCache($key, $value)
    {
        $this->cache[$key] = $value;
    }

    /**
     * Gets a value from the cache.
     *
     * @param string $key The cache key.
     *
     * @return mixed|null The cached value or null if not set.
     */
    public function getCache($key, $default = null)
    {
        return $this->isCacheSet($key) ? $this->cache[$key] : $default;
    }

    /**
     * Checks if a cache key is set.
     *
     * @param string $key The cache key.
     *
     * @return bool True if the cache key is set, false otherwise.
     */
    public function isCacheSet($key)
    {
        return isset($this->cache[$key]);