Caching object with Keycloak

Hello community !
I need help.
I have to expose 2 resources in my IDP.(/resource1 and /resource2).
In the first call, i need to store some data in cache and will be stored in the second call.
How can i save my object in session? There’s an example?