Make caching a plugin system
This commit is contained in:
31
lib/util.php
31
lib/util.php
@@ -1384,42 +1384,17 @@ function common_session_token()
|
||||
|
||||
function common_cache_key($extra)
|
||||
{
|
||||
$base_key = common_config('memcached', 'base');
|
||||
|
||||
if (empty($base_key)) {
|
||||
$base_key = common_keyize(common_config('site', 'name'));
|
||||
}
|
||||
|
||||
return 'statusnet:' . $base_key . ':' . $extra;
|
||||
return Cache::key($extra);
|
||||
}
|
||||
|
||||
function common_keyize($str)
|
||||
{
|
||||
$str = strtolower($str);
|
||||
$str = preg_replace('/\s/', '_', $str);
|
||||
return $str;
|
||||
return Cache::keyize($str);
|
||||
}
|
||||
|
||||
function common_memcache()
|
||||
{
|
||||
static $cache = null;
|
||||
if (!common_config('memcached', 'enabled')) {
|
||||
return null;
|
||||
} else {
|
||||
if (!$cache) {
|
||||
$cache = new Memcache();
|
||||
$servers = common_config('memcached', 'server');
|
||||
if (is_array($servers)) {
|
||||
foreach($servers as $server) {
|
||||
$cache->addServer($server);
|
||||
}
|
||||
} else {
|
||||
$cache->addServer($servers);
|
||||
}
|
||||
$cache->setCompressThreshold(20000, 0.2);
|
||||
}
|
||||
return $cache;
|
||||
}
|
||||
return Cache::instance();
|
||||
}
|
||||
|
||||
function common_license_terms($uri)
|
||||
|
Reference in New Issue
Block a user