@@ -18,14 +18,12 @@ class UnityGroup
1818 private UnitySQL $ SQL ;
1919 private UnityMailer $ MAILER ;
2020 private UnityWebhook $ WEBHOOK ;
21- private UnityRedis $ REDIS ;
2221
2322 public function __construct (
2423 string $ gid ,
2524 UnityLDAP $ LDAP ,
2625 UnitySQL $ SQL ,
2726 UnityMailer $ MAILER ,
28- UnityRedis $ REDIS ,
2927 UnityWebhook $ WEBHOOK ,
3028 ) {
3129 $ gid = trim ($ gid );
@@ -35,7 +33,6 @@ public function __construct(
3533 $ this ->LDAP = $ LDAP ;
3634 $ this ->SQL = $ SQL ;
3735 $ this ->MAILER = $ MAILER ;
38- $ this ->REDIS = $ REDIS ;
3936 $ this ->WEBHOOK = $ WEBHOOK ;
4037 }
4138
@@ -184,17 +181,6 @@ public function cancelGroupJoinRequest(UnityUser $user, bool $send_mail = true):
184181 // // now we delete the ldap entry
185182 // $this->entry->ensureExists();
186183 // $this->entry->delete();
187- // $default_value_getter = [$this->LDAP, "getSortedGroupsForRedis"];
188- // $this->REDIS->removeCacheArray("sorted_groups", "", $this->gid, $default_value_getter);
189- // foreach ($users as $user) {
190- // $this->REDIS->removeCacheArray(
191- // $user->uid,
192- // "groups",
193- // $this->gid,
194- // fn() => $this->getGroupMemberUIDs(true),
195- // );
196- // }
197- // // FIXME group not removed from user's groups array
198184
199185 // // send email to every user of the now deleted PI group
200186 // if ($send_mail) {
@@ -315,49 +301,34 @@ public function getRequests(): array
315301 $ this ->LDAP ,
316302 $ this ->SQL ,
317303 $ this ->MAILER ,
318- $ this ->REDIS ,
319304 $ this ->WEBHOOK ,
320305 );
321306 array_push ($ out , [$ user , $ request ["timestamp " ]]);
322307 }
323308 return $ out ;
324309 }
325310
326- public function getGroupMembers (bool $ ignorecache = false ): array
311+ public function getGroupMembers (): array
327312 {
328- $ members = $ this ->getGroupMemberUIDs ($ ignorecache );
313+ $ members = $ this ->getGroupMemberUIDs ();
329314 $ out = [];
330315 foreach ($ members as $ member ) {
331316 $ user_obj = new UnityUser (
332317 $ member ,
333318 $ this ->LDAP ,
334319 $ this ->SQL ,
335320 $ this ->MAILER ,
336- $ this ->REDIS ,
337321 $ this ->WEBHOOK ,
338322 );
339323 array_push ($ out , $ user_obj );
340324 }
341325 return $ out ;
342326 }
343327
344- public function getGroupMemberUIDs (bool $ ignorecache = false ): array
328+ public function getGroupMemberUIDs (): array
345329 {
346- if (!$ ignorecache ) {
347- $ cached_val = $ this ->REDIS ->getCache ($ this ->gid , "members " );
348- if (!is_null ($ cached_val )) {
349- $ members = $ cached_val ;
350- }
351- }
352- $ updatecache = false ;
353- if (!isset ($ members )) {
354- $ members = $ this ->entry ->getAttribute ("memberuid " );
355- $ updatecache = true ;
356- }
357- if (!$ ignorecache && $ updatecache ) {
358- sort ($ members );
359- $ this ->REDIS ->setCache ($ this ->gid , "members " , $ members );
360- }
330+ $ members = $ this ->entry ->getAttribute ("memberuid " );
331+ sort ($ members );
361332 return $ members ;
362333 }
363334
@@ -383,8 +354,6 @@ private function init(): void
383354 $ this ->entry ->setAttribute ("gidnumber " , strval ($ nextGID ));
384355 $ this ->entry ->setAttribute ("memberuid " , [$ owner ->uid ]);
385356 $ this ->entry ->write ();
386- $ default_value_getter = [$ this ->LDAP , "getSortedGroupsForRedis " ];
387- $ this ->REDIS ->appendCacheArray ("sorted_groups " , "" , $ this ->gid , $ default_value_getter );
388357 // TODO if we ever make this project based,
389358 // we need to update the cache here with the memberuid
390359 }
@@ -393,36 +362,12 @@ private function addUserToGroup(UnityUser $new_user): void
393362 {
394363 $ this ->entry ->appendAttribute ("memberuid " , $ new_user ->uid );
395364 $ this ->entry ->write ();
396- $ this ->REDIS ->appendCacheArray (
397- $ this ->gid ,
398- "members " ,
399- $ new_user ->uid ,
400- fn () => $ this ->getGroupMemberUIDs (true ),
401- );
402- $ this ->REDIS ->appendCacheArray (
403- $ new_user ->uid ,
404- "groups " ,
405- $ this ->gid ,
406- fn () => $ this ->LDAP ->getPIGroupGIDsWithMemberUID ($ new_user ->uid ),
407- );
408365 }
409366
410367 private function removeUserFromGroup (UnityUser $ old_user ): void
411368 {
412369 $ this ->entry ->removeAttributeEntryByValue ("memberuid " , $ old_user ->uid );
413370 $ this ->entry ->write ();
414- $ this ->REDIS ->removeCacheArray (
415- $ this ->gid ,
416- "members " ,
417- $ old_user ->uid ,
418- fn () => $ this ->getGroupMemberUIDs (true ),
419- );
420- $ this ->REDIS ->removeCacheArray (
421- $ old_user ->uid ,
422- "groups " ,
423- $ this ->gid ,
424- fn () => $ this ->LDAP ->getPIGroupGIDsWithMemberUID ($ old_user ->uid ),
425- );
426371 }
427372
428373 public function memberExists (UnityUser $ user ): bool
@@ -442,7 +387,6 @@ public function getOwner(): UnityUser
442387 $ this ->LDAP ,
443388 $ this ->SQL ,
444389 $ this ->MAILER ,
445- $ this ->REDIS ,
446390 $ this ->WEBHOOK ,
447391 );
448392 }
0 commit comments