Skip to content

Commit

Permalink
Use a capped memory cache for the user/group cache
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rullzer authored and DeepDiver1975 committed May 30, 2016
1 parent 985063a commit dc4fd43
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/user_ldap/lib/Group_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,20 @@

namespace OCA\User_LDAP;

use OC\Cache\CappedMemoryCache;

class Group_LDAP extends BackendUtility implements \OCP\GroupInterface {
protected $enabled = false;

/**
* @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);
Expand All @@ -57,6 +58,9 @@ public function __construct(Access $access) {
if(!empty($filter) && !empty($gassoc)) {
$this->enabled = true;
}

$this->cachedGroupMembers = new CappedMemoryCache();
$this->cachedGroupsByMember = new CappedMemoryCache();
}

/**
Expand Down

0 comments on commit dc4fd43

Please sign in to comment.