|
@@ -10,12 +10,12 @@ class AntCache
|
|
/**
|
|
/**
|
|
* Caches a value for a given cache key.
|
|
* Caches a value for a given cache key.
|
|
*
|
|
*
|
|
- * @param mixed $key The cache key to use for the cached value.
|
|
|
|
- * @param mixed $content The value to cache.
|
|
|
|
|
|
+ * @param string $key The cache key to use for the cached value.
|
|
|
|
+ * @param string $content The value to cache.
|
|
* @return bool True if the value was successfully cached, false otherwise.
|
|
* @return bool True if the value was successfully cached, false otherwise.
|
|
* @throws ParseException If there is an error parsing the AntCMS configuration file.
|
|
* @throws ParseException If there is an error parsing the AntCMS configuration file.
|
|
*/
|
|
*/
|
|
- public function setCache($key, $content)
|
|
|
|
|
|
+ public function setCache(string $key, string $content)
|
|
{
|
|
{
|
|
$cachePath = AntCachePath . DIRECTORY_SEPARATOR . "$key.cache";
|
|
$cachePath = AntCachePath . DIRECTORY_SEPARATOR . "$key.cache";
|
|
$config = AntConfig::currentConfig();
|
|
$config = AntConfig::currentConfig();
|
|
@@ -34,11 +34,11 @@ class AntCache
|
|
/**
|
|
/**
|
|
* Retrieves the cached value for a given cache key.
|
|
* Retrieves the cached value for a given cache key.
|
|
*
|
|
*
|
|
- * @param mixed $key The cache key used to retrieve the cached value.
|
|
|
|
|
|
+ * @param string $key The cache key used to retrieve the cached value.
|
|
* @return string|false The cached value, or false if there was an error loading it or if caching is disabled.
|
|
* @return string|false The cached value, or false if there was an error loading it or if caching is disabled.
|
|
* @throws ParseException If there is an error parsing the AntCMS configuration file.
|
|
* @throws ParseException If there is an error parsing the AntCMS configuration file.
|
|
*/
|
|
*/
|
|
- public function getCache($key)
|
|
|
|
|
|
+ public function getCache(string $key)
|
|
{
|
|
{
|
|
$cachePath = AntCachePath . DIRECTORY_SEPARATOR . "$key.cache";
|
|
$cachePath = AntCachePath . DIRECTORY_SEPARATOR . "$key.cache";
|
|
$config = AntConfig::currentConfig();
|
|
$config = AntConfig::currentConfig();
|
|
@@ -61,7 +61,7 @@ class AntCache
|
|
* @return bool True if the cache key has a corresponding cached value, false otherwise. Will also return false if caching is disabled.
|
|
* @return bool True if the cache key has a corresponding cached value, false otherwise. Will also return false if caching is disabled.
|
|
* @throws ParseException If there is an error parsing the AntCMS configuration file.
|
|
* @throws ParseException If there is an error parsing the AntCMS configuration file.
|
|
*/
|
|
*/
|
|
- public function isCached($key)
|
|
|
|
|
|
+ public function isCached(string $key)
|
|
{
|
|
{
|
|
$config = AntConfig::currentConfig();
|
|
$config = AntConfig::currentConfig();
|
|
if ($config['enableCache']) {
|
|
if ($config['enableCache']) {
|
|
@@ -76,11 +76,11 @@ class AntCache
|
|
* Generates a unique cache key for the associated content and a salt value.
|
|
* Generates a unique cache key for the associated content and a salt value.
|
|
* The salt is used to ensure that each cache key is unique to each component, even if multiple components are using the same source content but caching different results.
|
|
* The salt is used to ensure that each cache key is unique to each component, even if multiple components are using the same source content but caching different results.
|
|
*
|
|
*
|
|
- * @param mixed $content The content to generate a cache key for.
|
|
|
|
|
|
+ * @param string $content The content to generate a cache key for.
|
|
* @param string $salt An optional salt value to use in the cache key generation. Default is 'cache'.
|
|
* @param string $salt An optional salt value to use in the cache key generation. Default is 'cache'.
|
|
* @return string The generated cache key.
|
|
* @return string The generated cache key.
|
|
*/
|
|
*/
|
|
- public function createCacheKey($content, $salt = 'cache')
|
|
|
|
|
|
+ public function createCacheKey(string $content, string $salt = 'cache')
|
|
{
|
|
{
|
|
/**
|
|
/**
|
|
* If the server is modern enough to have xxh128, use that. It is really fast and still produces long hashes
|
|
* If the server is modern enough to have xxh128, use that. It is really fast and still produces long hashes
|