Make caching a plugin system

This commit is contained in:
Evan Prodromou
2010-01-02 20:26:33 -10:00
parent 7b452e4f71
commit c5d23e27a6
2 changed files with 116 additions and 28 deletions

View File

@@ -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)