diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2016-07-04 13:57:15 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-07-04 13:57:15 +0200 |
commit | 6b4b337e533a7df17feeac770c4c8bfba1a3a293 (patch) | |
tree | 237f91a0ae9c2af2e5d2b77b9178f6b19d41d24d | |
parent | 59fc3ff45a98e305ad65069d31fc78081fa88dc6 (diff) | |
download | nextcloud-server-6b4b337e533a7df17feeac770c4c8bfba1a3a293.tar.gz nextcloud-server-6b4b337e533a7df17feeac770c4c8bfba1a3a293.zip |
Cap LDAP user cache (#25323)
-rw-r--r-- | apps/user_ldap/lib/User/Manager.php | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php index 55d7ac8a81c..767a2351aeb 100644 --- a/apps/user_ldap/lib/User/Manager.php +++ b/apps/user_ldap/lib/User/Manager.php @@ -25,6 +25,7 @@ namespace OCA\User_LDAP\User; +use OC\Cache\CappedMemoryCache; use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\FilesystemHelper; use OCP\IAvatarManager; @@ -62,14 +63,13 @@ class Manager { protected $avatarManager; /** - * array['byDN'] \OCA\User_LDAP\User\User[] - * ['byUid'] \OCA\User_LDAP\User\User[] - * @var array $users + * @var CappedMemoryCache $usersByDN */ - protected $users = array( - 'byDN' => array(), - 'byUid' => array(), - ); + protected $usersByDN; + /** + * @var CappedMemoryCache $usersByUid + */ + protected $usersByUid; /** * @param IConfig $ocConfig @@ -93,6 +93,8 @@ class Manager { $this->image = $image; $this->db = $db; $this->userManager = $userManager; + $this->usersByDN = new CappedMemoryCache(); + $this->usersByUid = new CappedMemoryCache(); } /** @@ -116,8 +118,8 @@ class Manager { $user = new User($uid, $dn, $this->access, $this->ocConfig, $this->ocFilesystem, clone $this->image, $this->ocLog, $this->avatarManager, $this->userManager); - $this->users['byDN'][$dn] = $user; - $this->users['byUid'][$uid] = $user; + $this->usersByDN[$dn] = $user; + $this->usersByUid[$uid] = $user; return $user; } @@ -219,10 +221,10 @@ class Manager { */ public function get($id) { $this->checkAccess(); - if(isset($this->users['byDN'][$id])) { - return $this->users['byDN'][$id]; - } else if(isset($this->users['byUid'][$id])) { - return $this->users['byUid'][$id]; + if(isset($this->usersByDN[$id])) { + return $this->usersByDN[$id]; + } else if(isset($this->usersByUid[$id])) { + return $this->usersByUid[$id]; } if($this->access->stringResemblesDN($id) ) { |