summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-12-06 17:19:41 -0500
committerEvan Prodromou <evan@status.net>2010-12-06 17:21:01 -0500
commit49757c79ee732cce179fe5f2d542dc93005943b5 (patch)
treeff60566d7971ed944f473ff651c9a9685325ee25
parenta33d1d6090557772465fbc401afb123a44f3925d (diff)
Config flag to disable router caching if needed
-rw-r--r--README12
-rw-r--r--lib/default.php2
-rw-r--r--lib/router.php20
3 files changed, 26 insertions, 8 deletions
diff --git a/README b/README
index b36d8b745..5731ab343 100644
--- a/README
+++ b/README
@@ -1540,6 +1540,18 @@ external: external links in notices. One of three values: 'sometimes',
nofollowed on profile, notice, and favorites page. Default is
'sometimes'.
+router
+------
+
+We use a router class for mapping URLs to code. This section controls
+how that router works.
+
+cache: whether to cache the router in memcache (or another caching
+ mechanism). Defaults to true, but may be set to false for
+ developers (who might be actively adding pages, so won't want the
+ router cached) or others who see strange behavior. You're unlikely
+ to need this unless you're a developer.
+
Plugins
=======
diff --git a/lib/default.php b/lib/default.php
index 6c8b03927..85d27f522 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -324,4 +324,6 @@ $default =
array('ssl_cafile' => false, // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt')
'curl' => false, // Use CURL backend for HTTP fetches if available. (If not, PHP's socket streams will be used.)
),
+ 'router' =>
+ array('cache' => true), // whether to cache the router object. Defaults to true, turn off for devel
);
diff --git a/lib/router.php b/lib/router.php
index 8d2fbf6cd..fb33125ab 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -127,15 +127,19 @@ class Router
function __construct()
{
if (empty($this->m)) {
- $k = self::cacheKey();
- $c = Cache::instance();
- $m = $c->get($k);
- if (!empty($m)) {
- $this->m = $m;
- } else {
+ if (!common_config('router', 'cache')) {
$this->m = $this->initialize();
- $c->set($k, $this->m);
- }
+ } else {
+ $k = self::cacheKey();
+ $c = Cache::instance();
+ $m = $c->get($k);
+ if (!empty($m)) {
+ $this->m = $m;
+ } else {
+ $this->m = $this->initialize();
+ $c->set($k, $this->m);
+ }
+ }
}
}