Created
March 6, 2017 14:31
-
-
Save XANi/db74322ca9a17963e82434d311a722c0 to your computer and use it in GitHub Desktop.
dokuwiki cache patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/auth.php b/auth.php | |
index 33d7279..87c2ee2 100644 | |
--- a/auth.php | |
+++ b/auth.php | |
@@ -22,7 +22,7 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin { | |
/* @var array $_pattern User filter pattern */ | |
protected $_pattern = null; | |
- | |
+ protected $cache = null; | |
/** | |
* Constructor | |
*/ | |
@@ -35,7 +35,8 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin { | |
$this->success = false; | |
return; | |
} | |
- | |
+ $this->cache = new Memcached(); | |
+ $this->cache->addServer('127.0.0.1', 11211); | |
// Add the capabilities to change the password | |
$this->cando['modPass'] = $this->getConf('modPass'); | |
} | |
@@ -150,7 +151,17 @@ class auth_plugin_authldap extends DokuWiki_Auth_Plugin { | |
* @return array containing user data or false | |
*/ | |
public function getUserData($user, $requireGroups=true) { | |
- return $this->_getUserData($user); | |
+ $usercache = $this->cache->get("user_data::" . $user); | |
+ if ($usercache != null) { | |
+ return $usercache; | |
+ } | |
+ $userdata = $this->_getUserData($user); | |
+ if ($userdata == false) { | |
+ $this->cache->set("user_data::" . $user,$userdata,60); | |
+ } else { | |
+ $this->cache->set("user_data::" . $user,$userdata,7200); | |
+ } | |
+ return $userdata; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment