summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/user_ldap.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2012-07-26 16:11:23 +0200
committerArthur Schiwon <blizzz@owncloud.com>2012-07-26 16:11:32 +0200
commit6c92a85d49822dba180fe949d211db60c5b40d51 (patch)
tree1a1eed9ddaf006b91122cb7b61ceebe9ba83182e /apps/user_ldap/user_ldap.php
parente0121ea75e85db681b4c7e50aa73b0b519c4d989 (diff)
downloadnextcloud-server-6c92a85d49822dba180fe949d211db60c5b40d51.tar.gz
nextcloud-server-6c92a85d49822dba180fe949d211db60c5b40d51.zip
LDAP: use OC_Cache to cache results from LDAP. Default is set to 10 min. Should improve performance especially when LDAP users use the sync client, because userExists checks with the LDAP server are reduced.
Diffstat (limited to 'apps/user_ldap/user_ldap.php')
-rw-r--r--apps/user_ldap/user_ldap.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 61f84047f1e..57b2ef489ba 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -27,9 +27,6 @@ namespace OCA\user_ldap;
class USER_LDAP extends lib\Access implements \OCP\UserInterface {
- // cache getUsers()
- protected $_users = null;
-
private function updateQuota($dn) {
$quota = null;
if(!empty($this->connection->ldapQuotaDefault)) {
@@ -97,11 +94,13 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
* Get a list of all users.
*/
public function getUsers(){
- if(is_null($this->_users)) {
+ $ldap_users = $this->connection->getFromCache('getUsers');
+ if(is_null($ldap_users)) {
$ldap_users = $this->fetchListOfUsers($this->connection->ldapUserFilter, array($this->connection->ldapUserDisplayName, 'dn'));
- $this->_users = $this->ownCloudUserNames($ldap_users);
+ $ldap_users = $this->ownCloudUserNames($ldap_users);
+ $this->connection->writeToCache('getUsers', $ldap_users);
}
- return $this->_users;
+ return $ldap_users;
}
/**
@@ -110,18 +109,25 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface {
* @return boolean
*/
public function userExists($uid){
+ if($this->connection->isCached('userExists'.$uid)) {
+ return $this->connection->getFromCache('userExists'.$uid);
+ }
+
//getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking.
$dn = $this->username2dn($uid);
if(!$dn) {
+ $this->connection->writeToCache('userExists'.$uid, false);
return false;
}
//if user really still exists, we will be able to read his cn
$cn = $this->readAttribute($dn, 'cn');
if(!$cn || empty($cn)) {
+ $this->connection->writeToCache('userExists'.$uid, false);
return false;
}
+ $this->connection->writeToCache('userExists'.$uid, true);
return true;
}