1
0

Moved caching methods out of functions.inc.php into ContentCache class.

This commit is contained in:
2022-02-13 16:15:48 +01:00
parent bb98e38522
commit 50c89e2bad
5 changed files with 110 additions and 68 deletions

View File

@ -1387,57 +1387,5 @@ function serendipity_url_allowed($url) {
return true;
}
use voku\cache\Cache;
// Configure voku/simple-cache to use templates_c as directory for the opcache files, the fallback
// when Memcached and Redis are not used. Returns the configured cache object. Used internally by
// the other cache functions, you most likely never need to call this.
function serendipity_setupCache() {
$cacheManager = new \voku\cache\CacheAdapterAutoManager();
$cacheManager->addAdapter(
\voku\cache\AdapterOpCache::class,
static function () {
global $serendipity;
$cacheDir = $serendipity['serendipityPath'] . '/templates_c/simple_cache';
return $cacheDir;
}
);
$cacheManager->addAdapter(
\voku\cache\AdapterArray::class
);
$cache = new Cache(
null,
null,
false,
true,
false,
false,
false,
false,
'',
$cacheManager,
false
);
return $cache;
}
function serendipity_cleanCache() {
$cache = serendipity_setupCache();
return $cache->removeAll();
}
function serendipity_cacheItem($key, $item, $ttl = 3600) {
$cache = serendipity_setupCache();
return $cache->setItem($key, $item, $ttl);
}
function serendipity_getCacheItem($key) {
$cache = serendipity_setupCache();
return $cache->getItem($key);
}
define("serendipity_FUNCTIONS_LOADED", true);
/* vim: set sts=4 ts=4 expandtab : */