mapbox / mapbox/mapbox-navigation-ios

Enable configuration of file caching footprint

Open
#1,384 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Swift
Stars
918
Forks
326
Avg merge
1h 16m
Merged PRs (30d)
3

Description

As we add support for caching more types of resources in the SDK we should start being more intentional about the file cache footprint.

This work will introduce developer configurability of cache footprint (both disk and memory) and disk cache age, and introduce sane defaults for new configuration options.

As a developer, I should be able to:
- Safely ignore the cache configuration
- Specify maximum memory footprint to allow for hot caching of images or other data
- Specify maximum disk footprint for images or other data
- Specify the maximum age of objects to store on disk, enforced at the appropriate time in the lifecycle of the containing app
- Understand (through clear documentation and test cases) which objects would be evicted if disk space is close to the limit.

Note that both the `ImageCache` and `DataCache` currently use a `FileCache` under the hood. The object relationships should be reconsidered as a part of this work in order to ensure that multiple `FileCache` instances don't conflict with each other in practice -- for example, it could become a singleton, or multiple instances might need to manage their own cache directories on disk.

Also note that the memory cache eviction heuristic is an implementation detail we aren't concerned with.

It is not believed to be necessary to implement a refCount mechanism at this time. A few comments have been removed from this issue in order to keep it focused on this description, which has been edited.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ImageCache, DataCache, and FileCache implementations and reading how they currently share storage. Define the configuration surface, defaults, eviction behavior, and cache ownership before changing anything. Add documentation and test cases that cover ignored configuration, memory and disk limits, disk age, and which objects are evicted near the limit.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile-dev, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.