MM-57084: Use cache for GetAllProfiles (#26391)

UserStore.GetAllProfiles is a very frequent call. We cache it
when there are no options passed which is the default case.

https://mattermost.atlassian.net/browse/MM-57084

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2024-03-11 10:34:20 +05:30
коммит произвёл GitHub
родитель 4fda7e6f34
Коммит bca5ab9a1f
7 изменённых файлов: 118 добавлений и 3 удалений

Просмотреть файл

@@ -263,9 +263,15 @@ func (a *App) createUserOrGuest(c request.CTX, user *model.User, guest bool) (*m
}
}
if user.EmailVerified {
a.InvalidateCacheForUser(ruser.Id)
// We always invalidate the user because we actually need to invalidate
// in case the user's EmailVerified is true, but we also always need to invalidate
// the GetAllProfiles cache.
// To have a proper fix would mean duplicating the invalidation of GetAllProfiles
// everywhere else. Therefore, to keep things simple we always invalidate both caches here.
// The performance penalty for invalidating the UserById cache is nil because the user was just created.
a.InvalidateCacheForUser(ruser.Id)
if user.EmailVerified {
nUser, err := a.ch.srv.userService.GetUser(ruser.Id)
if err != nil {
var nfErr *store.ErrNotFound