Skip to content

Commit

Permalink
apcu cache for full list users
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander1000 authored and Aleksandr Dankovtsev committed Jan 9, 2025
1 parent 5f481ce commit 73950fa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Controller/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ class EditorController extends Controller {
*/
private $avatarManager;

private const CACHE_KEY_ALL_LDAP_USERS = 'all_mention_ldap_users';

// @todo: probably configure via configs
private const CACHE_KEY_LDAP_USERS_TTL = 3600;

/**
* @param string $AppName - application name
* @param IRequest $request - request object
Expand Down Expand Up @@ -413,6 +418,11 @@ public function users($fileId, $operationType = null) {
}
}
} else {
if (apcu_exists(self::CACHE_KEY_ALL_LDAP_USERS)) {
$result = apcu_fetch(self::CACHE_KEY_ALL_LDAP_USERS);
return $result;
}

$users = $this->userManager->search("");
$all = true;
}
Expand Down Expand Up @@ -442,6 +452,10 @@ public function users($fileId, $operationType = null) {
}
}

if ($all) {
apcu_store(self::CACHE_KEY_ALL_LDAP_USERS, $result, self::CACHE_KEY_ALL_LDAP_USERS_TTL);
}

return $result;
}

Expand Down

0 comments on commit 73950fa

Please sign in to comment.