Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6852621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:24:55+00:00 2026-05-27T01:24:55+00:00

For my app I store map images in a cache on the external storage

  • 0

For my app I store map images in a cache on the external storage as to reduce calls to the API that I am using. Since this data is map data, it is subject to change over time. As a result these images should be updated every-so-often.

How can I programmatically delete the cache directory periodically? Say for example, every week.

Some extra thoughts:
Perhaps deleting the entire directory is not the best way to go about it. Perhaps I can check the “freshness” of each image, and delete the old ones?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:24:56+00:00Added an answer on May 27, 2026 at 1:24 am

    Yes, it’s usually a good idea to limit your cache with some method or another. Some caches have fixed sizes, and older content is removed once your cache size is exceeded. This size could be a count of the number of items or a size in disk space. Some caches have TTLs for each item (or the same TTL for all items) and so items expire after a certain time. Some caches may never expire. Perhaps it is bounded in size by the number of possible items that would be cached in the first place. Any of these approaches are valid, though some may be more appropriate for certain scenarios than others.

    The “freshness” idea is probably an approach I’d consider. It’s the same as the TTL. Basically you want to set a length of time that your cache item will live for. Store this cache time along with the cache data, then check it whenever reading the cache data. If it’s past the expiration date, you can delete that cache file and retrieve the map data from the API again (and cache that). You could probably do something with just reading the file creation time too if you don’t want to store a date separately and have a fixed lifespan hard-coded or configurable in your application.

    Update to address comments:

    I’ve used hashing the URL as the filename before too. Just be aware that there’s a possibility of collisions (highly dependent on your hash algorithm and your data set of course). Also, if you’re going through a lot of URLs, the performance of your hash algorithm might matter too.

    Storing that cache metadata in a text file is fine, especially if you don’t have a ton of URLs. You’ll want to be careful about how you update that text file though. You could easily corrupt it if you’re not careful and access it from multiple threads without proper synchronization. If you have a lot of data, another option you can consider is using a database. If you do store this cache metadata in a file–whether database or text file–you can avoid all the problems with hashing by using a different scheme for your filenames. You could just increment in hex or base 36 for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I upload my app to app store, I already build my apps using device
I created an iPhone application for the App Store. I hear that some things
I'm in the middle of developing android app using google map. My question is
I'm working on an iPhone app that shows a map with multiple circle overlays
I currently have an app (in Silverlight), using mv-vm, that has an interface to
The reason I ask is my app lets users cache map tiles. Does anyone
I have a Silverlight app that makes multiple (often concurrent) asynchronous calls to an
I got a small app that use the Direction Service feature of Google Map.
I'm using ASP.NET MVC 3, with Raven DB as a backing data store. I
I'm trying to make an iOS app that shows my location on a map

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.