Unregistering user

If I create client and cache, then connect user… The question is when I disconnect the user and then connect the user back, do I need to create client and cache again?

Thanks for your inquiry, the team will get back to you asap :pray:t2:

Hello @Addy

To help us answer you, could you clarify these two points:

1 Are you using one of our sdks?
2a. if yes which one?
2b. if no, could you give more context around what you’re trying to accomplish?

Thank you,

Hi @Julien yes, it’s Amity ts sdk.

It is not mandatory to create new cache all the time, although here some reflexions which might help you :

The cache data is attached to the client instance. you can easily find this under the client.cache property. It is made this way so that disposing of a client would dispose of its cache as well.

Knowing this, if the user you’re trying to reconnect is the same user than before, it’s better to reuse the client instance which will have the old cache data inside. in most cases it will end up with better UX since objects will be faster to load. Note that you still have full control over this, and if you feel necessary to empty the cache, you can use the clearCache() function.

If the user you are reconnecting is a different user than before, it’s most beneficial to create a new client and create new cache as well. By doing like this you will make sure data fetched by the old user is not accessible to new user (which could be better for data privacy reasons), and you will have opportunity to keep the old client instance and its cache in case you want to reconnect it later.

I hope it helps,