Skip to content

Commit 8491519

Browse files
committed
cache user/group exists
1 parent a1679de commit 8491519

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

resources/lib/UnityGroup.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ public function getPIUID()
6262
*
6363
* @return bool true if yes, false if no
6464
*/
65-
public function exists()
65+
public function exists($ignorecache = false)
6666
{
67+
if (!$ignorecache) {
68+
$cached_pi_groups = $this->REDIS->getCache("sorted_pi_groups", "");
69+
return in_array($this->getPIUID(), $cached_pi_groups);
70+
}
6771
return $this->getLDAPPiGroup()->exists();
6872
}
6973

resources/lib/UnityUser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,14 @@ public function getLDAPGroup()
154154
return $this->LDAP->getGroupEntry($this->uid);
155155
}
156156

157-
public function exists()
157+
public function exists($ignorecache = false)
158158
{
159+
if (!$ignorecache) {
160+
$cached_val = $this->REDIS->getCache($this->uid, "cn");
161+
if (!is_null($cached_val)) {
162+
return true;
163+
}
164+
}
159165
return $this->getLDAPUser()->exists() && $this->getLDAPGroup()->exists();
160166
}
161167

0 commit comments

Comments
 (0)