vercel / swr-site

The official website for SWR.
https://swr.vercel.app
Apache License 2.0
481 stars 351 forks source link

Feedback for “Cache – SWR” #372

Open sergiofdez4 opened 1 year ago

sergiofdez4 commented 1 year ago

Would you mind updating the docs when possible? https://swr.vercel.app/docs/advanced/cache (great library btw...)

koba04 commented 1 year ago

@sergiofdez4 What do you need in the docs?

sergiofdez4 commented 1 year ago

On how to clear cache. clear method does not exist (v.1.3.0). We're looping through the cache object and deleting each key. We're not sure if it is the best approach though. Any feedback is appreciated. Thanks for the quick response too.

koba04 commented 1 year ago

Thank you! As the docs say, modifying the cache data directly is not a recommended way because it might cause unexpected behaviors.

In v2 (RC), there is a new feature to mutate multiple data, and it can be used as a way to clear cache data. We've added it in the v2 docs. https://beta-swr.vercel.app/docs/advanced/cache#modify-the-cache-data