Skip to content

Instantly share code, notes, and snippets.

@XANi
Created March 6, 2017 14:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XANi/db74322ca9a17963e82434d311a722c0 to your computer and use it in GitHub Desktop.
Save XANi/db74322ca9a17963e82434d311a722c0 to your computer and use it in GitHub Desktop.
dokuwiki cache patch
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