Flagsmith / flagsmith-js-client

Javascript Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at https://www.flagsmith.com/

Home Page:https://www.flagsmith.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Caching with multiple instance doesn't work

ldemesla opened this issue · comments

Hey,

I'm using Flagsmith with two instances, created using the createFlagsmithContext. I have noticed that caching is not working properly when you are running two instances. Indeed, if you look at the local storage you will see that the values from both instance are cached against the same key and are overriding each other.

Reproduction case:

communitiesFlag.init({
  environmentID: 'env-1',
  api: FLAGSMITH_API,
  cacheFlags: true,
  cacheOptions: {
    skipAPI: true,
    ttl: 1000 * 60 * 5,
  },
});

usersFlags.init({
  environmentID: 'env-2',
  api: FLAGSMITH_API,
  cacheFlags: true,
  cacheOptions: {
    skipAPI: true,
    ttl: 1000 * 60 * 5,
  },
});

usersFlags.identify('1')
communitiesFlag.identify('2')

Check in the local storage of your browser and you will see that only one of the identity has been cached

Thanks for this @ldemesla, we will look into it and get back to you as soon as possible.

Thank you @ldemesla! we will soon start working on this issue, and keep you posted about the progress.

@kyle-ssg @novakzaballa what's the status here?

Hi @ldemesla, just to leave an update and let you know that we are considering if this use case would be solved by the implementation of contexts which is planned to be delivered by the second semester of this year.

Hi @ldemesla we will start working on the contexts next week, could you please explain the use case for this request? so we can know this is a good candidate for solving this with the implementation of the contexts

Also, we don't provide the function createFlagsmithContext, in the javascript client, Could you please share where you found the code for using createFlagsmithContext?