javascript - Under what circumstances is removeItem used in Storage?
学习ing
学习ing 2017-06-26 10:52:16
0
1
816
  1. Under what circumstances is removeItem used in Storage?

  2. Can removeItem release browser storage space?

学习ing
学习ing

reply all(1)
阿神

I had a requirement before: if there is no xx item in Storage, I would go to the backend to get the data and store it in Storage. If there is, it would not be fetched

So when you encounter something that needs to be updated or reacquired, you need to removeItem, and then it will reacquire item

Also, in order to synchronize item information on the front end, assuming that item exists in localStorage, but other users have modified the backend data corresponding to item on other clients, then at this time you can even local item in Storage is not synchronized. In this case, you need to remove when you log out and re-obtain it every time you log in. Although instant synchronization cannot be guaranteed, for our terminal at that time, there was not much concurrency. It is enough to be able to refresh the item information by logging in again. The approach we strive for is to store the timestamp of the back-end information on the front-end item, and check the freshness of this timestamp every time it is used. If it is fresh Continue to use the cached item, if it is not fresh, retrieve it again

Secondly, removeItemThis kind of usage may appear in many situations. For example, if this item is not needed in a certain situation, it can be deleted completely, because the following may do something based on whether the item exists, even if the following Don’t rely on this itemIf it’s useless, why not delete it and keep it? As for the space saving, I don’t think it exists

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!