I wondered how to properly store the cache? Ie, I want to hear a suggestion on how best to keep it. For example, I think this: Download the information, save it to the cache. If the user switches back to the view with the information that is downloaded from the Internet, then we give out the existing one, checking how much time has passed. Then there is the problem of storing it. Because, new information comes, but the old one is not deleted, and then a logical question appears. Delete it when we download new information, after what time. Or reset it every day? I would like to hear a suggestion. How you implement cache storage.

    1 answer 1

    The answer to your question depends on the formulation of the problem you are trying to solve.

    In general, you can update the data either as they become obsolete (to track the relevance of time) or periodically.

    new information arrives, but the old is not deleted

    Of course, outdated data should be deleted after downloading new ones.

    • The task is to download a list of information on updating books (approximate time for updating chapters, 20 minutes). So I think, if you stick like this 10 times, the base is already 10 mb, delete it after the passage of time or after 5 calls. - Yegor Glukhov
    • @EgorGlukhov, personally, in this case, I would simply “go through” the cache and replace the old data with new data if the information about the book was updated. If not, left a record of the book as is. - Streletz
    • There the list is updated, rarely come across the same book. - Yegor Glukhov