diff options
author | Brion Vibber <brion@pobox.com> | 2010-03-30 12:19:25 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-03-30 12:20:46 -0700 |
commit | f19b95d9b7daa82e73ca2ebf23ca55712de73107 (patch) | |
tree | 0a421992eba3d2b2e98971664156020d8d02c4a5 /plugins | |
parent | 804182e0fea025b80282b45a1c3205e39a63e3d6 (diff) |
Shared cache key option for Geonames plugin, lets multi-instance sites share their cached geoname lookups.
Example:
unset($config['plugins']['default']['Geonames']);
addPlugin('Geonames', array('cachePrefix' => 'statusnet:shared'));
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/GeonamesPlugin.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/GeonamesPlugin.php b/plugins/GeonamesPlugin.php index 589462ed9..f018e2694 100644 --- a/plugins/GeonamesPlugin.php +++ b/plugins/GeonamesPlugin.php @@ -55,6 +55,8 @@ class GeonamesPlugin extends Plugin public $username = null; public $token = null; public $expiry = 7776000; // 90-day expiry + public $cachePrefix = null; // Optional shared memcache prefix override + // to share lookups between local instances. /** * convert a name into a Location object @@ -408,9 +410,14 @@ class GeonamesPlugin extends Plugin function cacheKey($attrs) { - return common_cache_key('geonames:'. - implode(',', array_keys($attrs)) . ':'. - common_keyize(implode(',', array_values($attrs)))); + $key = 'geonames:' . + implode(',', array_keys($attrs)) . ':'. + common_keyize(implode(',', array_values($attrs))); + if ($this->cachePrefix) { + return $this->cachePrefix . ':' . $key; + } else { + return common_cache_key($key); + } } function wsUrl($method, $params) |