Closed tdeekens closed 4 months ago
Latest commit: 5334e4c2c5f86bab0fcf82ab3cbef96c2515135f
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Attention: Patch coverage is 89.47368%
with 2 lines
in your changes missing coverage. Please review.
Project coverage is 93.88%. Comparing base (
44a82fd
) to head (5334e4c
).
Summary
This refactors the cache's key for flags to be a hashed version of the adapter's context.
Description
When caching lazily it is important to fall back to a hot cache as often as possible. Otherwise a user would be served a stale cache for flags.
Taking for example the flow of:
With a lazy acting cache, in the above flow the user at 5. would still see an enabled feature. This is rooted in the fact that the cache does not synchronize its state until another hard reload (or unmounting of flopflip).
The reason for this behaviour is that at any point flopflip's cache is bound - without this change - to a user's key. Any user can only have one set of cached flags.
This change proposes to take the entire context of the adapter into account for the cache key. This allows a user to have n caches depending on the number of contexts the user is in. This allows a "hot cache" to be restored more likely and flopflip not falling back onto a cold cache often.