diff --git a/resources/lib/UnityGroup.php b/resources/lib/UnityGroup.php index d1616225..be94bb4e 100644 --- a/resources/lib/UnityGroup.php +++ b/resources/lib/UnityGroup.php @@ -62,8 +62,14 @@ public function getPIUID() * * @return bool true if yes, false if no */ - public function exists() + public function exists(bool $ignorecache = false): bool { + if (!$ignorecache) { + $cached_pi_groups = $this->REDIS->getCache("sorted_pi_groups", ""); + if (!is_null($cached_pi_groups)) { + return in_array($this->getPIUID(), $cached_pi_groups); + } + } return $this->getLDAPPiGroup()->exists(); } diff --git a/resources/lib/UnityUser.php b/resources/lib/UnityUser.php index 4f88eac6..3df33d6f 100644 --- a/resources/lib/UnityUser.php +++ b/resources/lib/UnityUser.php @@ -154,8 +154,14 @@ public function getLDAPGroup() return $this->LDAP->getGroupEntry($this->uid); } - public function exists() + public function exists(bool $ignorecache = false): bool { + if (!$ignorecache) { + $cached_users = $this->REDIS->getCache("sorted_users", ""); + if (!is_null($cached_users)) { + return in_array($this->uid, $cached_users); + } + } return $this->getLDAPUser()->exists() && $this->getLDAPGroup()->exists(); }