allow a configured base for cache keys

This commit is contained in:
Evan Prodromou 2009-06-15 16:09:40 -07:00
parent 177e4adf40
commit fd290fc3f9
3 changed files with 15 additions and 1 deletions

7
README
View File

@ -1106,6 +1106,13 @@ database data in memcached <http://www.danga.com/memcached/>.
enabled: Set to true to enable. Default false. enabled: Set to true to enable. Default false.
server: a string with the hostname of the memcached server. Can also server: a string with the hostname of the memcached server. Can also
be an array of hostnames, if you've got more than one server. be an array of hostnames, if you've got more than one server.
base: memcached uses key-value pairs to store data. We build long,
funny-looking keys to make sure we don't have any conflicts. The
base of the key is usually a simplified version of the site name
(like "Identi.ca" => "identica"), but you can overwrite this if
you need to. You can safely ignore it if you only have one
Laconica site using your memcached server.
port: Port to connect to; defaults to 11211.
sphinx sphinx
------ ------

View File

@ -152,6 +152,7 @@ $config =
'memcached' => 'memcached' =>
array('enabled' => false, array('enabled' => false,
'server' => 'localhost', 'server' => 'localhost',
'base' => null,
'port' => 11211), 'port' => 11211),
'ping' => 'ping' =>
array('notify' => array()), array('notify' => array()),

View File

@ -1322,7 +1322,13 @@ function common_session_token()
function common_cache_key($extra) function common_cache_key($extra)
{ {
return 'laconica:' . common_keyize(common_config('site', 'name')) . ':' . $extra; $base_key = common_config('memcached', 'base');
if (empty($base_key)) {
$base_key = common_keyize(common_config('site', 'name'));
}
return 'laconica:' . $base_key . ':' . $extra;
} }
function common_keyize($str) function common_keyize($str)