S
SolidJS•13mo ago
pedro00dk

Solid-js router 0.10.x cache invalidation

Hi, I started migrating an app from solidjs router 0.9.x and 0.10.x. The new caching and preload features are nice, but I'm having some trouble with testing. In my test setup I intercept API requests and inject different stubs for different tests. Since the tests run fast, the new solid router cache function does not invalidate the cache from one test to the next, causing some tests to get API responses made for previous tests when making the same API requests. I looked at the source code of cache and there seems to be no way to invalidate the entire cache. I saw that there is a cache.set function there but it seems it can't be used for invalidating individual caches. Are there other tricks I can use to achieve this behavior? I really don't want to change components' code to fetch without caching for tests, so it would be interesting to have some sort of cache.clear to invalidate the entire cache for testing purposes.
5 Replies
ryansolid
ryansolid•13mo ago
Good suggestion. I wasn't thinking about testing. Lets do something about that.
Carlo Nyte
Carlo Nyte•5mo ago
Any updates on this?
pedro00dk
pedro00dkOP•5mo ago
There is a cache.clear() function for that purpose. I don't think it is documented though.
Carlo Nyte
Carlo Nyte•4mo ago
yea I saw that. I was wondering if we could clear individual caches rather than all of them 🙂
ryansolid
ryansolid•4mo ago
We just need to expose a method.
Want results from more Discord servers?
Add your server