MM-21209: Use the LRU cache for UserStore.Get call too (#13456)

* MM-21209: Use the LRU cache for UserStore.Get call too

We already have userProfileByIdsCache to store the user profiles by Id.
It just wasn't being used for the (*UserStore).Get method. We add a wrapper
method in LocalCacheUserStore to intercept that call and check for the
presence of the user Id in the cache.

There is no need to add any code for invalidation as all of that is already
present.

* Fix nil check for rootstore

* Fix TestUserStore test

Added an invalidate call. The invalidation was being done
from the app level. Hence we have to do it manually here for the test.
Этот коммит содержится в:
Agniva De Sarker
2019-12-30 22:52:31 +05:30
коммит произвёл Christopher Speller
родитель 803a58f991
Коммит 1e28ad4a73
5 изменённых файлов: 66 добавлений и 3 удалений

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

@@ -61,7 +61,11 @@ func (s *Server) RunOldAppInitialization() error {
if s.FakeApp().Srv.newStore == nil {
s.FakeApp().Srv.newStore = func() store.Store {
return store.NewTimerLayer(localcachelayer.NewLocalCacheLayer(sqlstore.NewSqlSupplier(s.FakeApp().Config().SqlSettings, s.Metrics), s.Metrics, s.Cluster), s.Metrics)
return store.NewTimerLayer(
localcachelayer.NewLocalCacheLayer(
sqlstore.NewSqlSupplier(s.FakeApp().Config().SqlSettings, s.Metrics),
s.Metrics, s.Cluster),
s.Metrics)
}
}