]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use a capped memory cache for the user/group cache
authorRoeland Jago Douma <rullzer@owncloud.com>
Fri, 27 May 2016 08:32:19 +0000 (10:32 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 30 May 2016 08:57:14 +0000 (10:57 +0200)
For #24403
When upgrading huge installations this can lead to memory problems as
the cache will only grow and grow.

Capping this memory will make sure we don't run out while during normal
operation still basically cache everything.

apps/user_ldap/lib/Group_LDAP.php

index 27bbcfffd69a5e769c742de393885c58e7daf1e6..7c12613f34d23ff4755580008a561a0eacaff51e 100644 (file)
@@ -36,6 +36,7 @@
 
 namespace OCA\User_LDAP;
 
+use OC\Cache\CappedMemoryCache;
 
 class Group_LDAP extends BackendUtility implements \OCP\GroupInterface {
        protected $enabled = false;
@@ -43,12 +44,12 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface {
        /**
         * @var string[] $cachedGroupMembers array of users with gid as key
         */
-       protected $cachedGroupMembers = array();
+       protected $cachedGroupMembers;
 
        /**
         * @var string[] $cachedGroupsByMember array of groups with uid as key
         */
-       protected $cachedGroupsByMember = array();
+       protected $cachedGroupsByMember;
 
        public function __construct(Access $access) {
                parent::__construct($access);
@@ -57,6 +58,9 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface {
                if(!empty($filter) && !empty($gassoc)) {
                        $this->enabled = true;
                }
+
+               $this->cachedGroupMembers = new CappedMemoryCache();
+               $this->cachedGroupsByMember = new CappedMemoryCache();
        }
 
        /**