# Total calls being made with user storage SPI (v15.0.0)

**URL:** <https://forum.keycloak.org/t/total-calls-being-made-with-user-storage-spi-v15-0-0/11291>\
**Category:** Extending the server\
**Created:** [October 2, 2021, 10:27pm UTC](https://forum.keycloak.org/t/total-calls-being-made-with-user-storage-spi-v15-0-0/11291 "2021-10-02T22:27:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![diginomad](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@diginomad](https://forum.keycloak.org/u/diginomad)\
**Post date:** [October 2, 2021, 10:27pm UTC](https://forum.keycloak.org/t/total-calls-being-made-with-user-storage-spi-v15-0-0/11291/1 "2021-10-02T22:27:32Z")

</div>

Hi, i have integrated keycloak to connect to an external storage using user storage SPI.  
However , i have noticed that during login, the **getUserByUsername** method from the **UserLookupProvider** interface is called 5 times (which seems not normal ?)

The flow which i run is a oauth 2.0 browser based login after which i successfully get a access & refresh token.  
Using Keycloak 15.0.0 docker image with mysql as database for keycloak & postgresql for user storage SPI.

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [October 3, 2021, 10:51am UTC](https://forum.keycloak.org/t/total-calls-being-made-with-user-storage-spi-v15-0-0/11291/2 "2021-10-03T10:51:57Z")

</div>

If you look through the Authenticators in the normal “Browser” flow, several of them call that method. So, while it doesn’t seem “normal” or even necessary, that’s how it currently works. The native user storage SPI has an intermediate distributed caching layer (Infinispan), so making multiple calls like this is relatively inexpensive.

---

<div class="post-metadata">

**Author:** ![diginomad](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@diginomad](https://forum.keycloak.org/u/diginomad)\
**Post date:** [October 3, 2021, 2:50pm UTC](https://forum.keycloak.org/t/total-calls-being-made-with-user-storage-spi-v15-0-0/11291/3 "2021-10-03T14:50:20Z")

</div>

Thanks for your response .  
Long shot, but is it possible to load the user into the cache during 1st call ?  
(Kind of keycloak would treat it like its an internal user maybe)

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [October 3, 2021, 3:13pm UTC](https://forum.keycloak.org/t/total-calls-being-made-with-user-storage-spi-v15-0-0/11291/4 "2021-10-03T15:13:33Z")

</div>

> [@diginomad](#):
>
> Long shot, but is it possible to load the user into the cache during 1st call ?

I’m not familiar enough with the Keycloak internals around the `UserLookupProvider`, but I suppose you could use the `UserCacheSession` in front of your own `UserLookupProvider` in the same way it’s being used in Keycloak to cache requests from `JpaUserProvider`. Take a look at the code.
