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
I had a requirement before: if there is no
xx item
inStorage
, I would go to the backend to get the data and store it inStorage
. If there is, it would not be fetchedSo when you encounter something that needs to be updated or reacquired, you need to
removeItem
, and then it will reacquireitem
Secondly,
removeItem
This kind of usage may appear in many situations. For example, if thisitem
is not needed in a certain situation, it can be deleted completely, because the following may do something based on whether theitem
exists, even if the following Don’t rely on thisitem
If it’s useless, why not delete it and keep it? As for the space saving, I don’t think it exists