Skip to content

feature(mobile): smart caching#26204

Open
dgrr wants to merge 5 commits intoimmich-app:mainfrom
dgrr:feature/smart-cache
Open

feature(mobile): smart caching#26204
dgrr wants to merge 5 commits intoimmich-app:mainfrom
dgrr:feature/smart-cache

Conversation

@dgrr
Copy link

@dgrr dgrr commented Feb 14, 2026

Description

Caching mechanism for high-res photos. It kinda simulates how icloud loads photos into the device.
Photos are stored in low-res long term, when a media is loaded then immich would load it from the server and keep it.
Smart cache would be in charge of clearing it out after some time.

There is a discussion about it here #23949

How Has This Been Tested?

I installed on an emulator and tested, seems to work.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Please describe to which degree, if any, an LLM was used in creating this pull request.

No, but it would be nice to use it for translations

@immich-push-o-matic
Copy link

immich-push-o-matic bot commented Feb 14, 2026

Label error. Requires exactly 1 of: changelog:.*. Found: 📱mobile. A maintainer will add the required label.

@dgrr dgrr force-pushed the feature/smart-cache branch 2 times, most recently from 3edf1aa to c5de8cb Compare February 14, 2026 08:33
@dgrr
Copy link
Author

dgrr commented Feb 14, 2026

ffs, i had to remove the justfile again

@dgrr dgrr force-pushed the feature/smart-cache branch from c5de8cb to a56abdf Compare February 14, 2026 08:37
@shenlong-tanwen
Copy link
Member

shenlong-tanwen commented Feb 14, 2026

@dgrr Hey, A couple of questions:

  • Why 7 days as default? A high-res image won't be changing every week
  • Why a properties file on Android and why not use the SQLite database?
  • And have you tested this on an iOS device as well?
  • Oh and, why'd you need a lastfile and what's it for?

@dgrr
Copy link
Author

dgrr commented Feb 14, 2026

  • Why 7 days as default? A high-res image won't be changing every week

idk, we can also do Never. The default is just 7 to clean up old high-res. So the mechanism is: User takes a pic or sees an old media. Maybe never looks at it again in the next 7 days, why store it? I am the one who would store it forever, that's why later added the Never option.

  • Why a properties file on Android and why not use the SQLite database?

I haven't worked with flutter much before, only some kotlin and java for android. I can switch to sqlite. I do agree that it might seem like overkill. I'll try to implement the sqlite change

  • And have you tested this on an iOS device as well?

No, I'll install an emulator actually

  • Oh and, why'd you need a lastfile and what's it for?

what do you mean with the lastfile? do you mean the last access?

@mertalev
Copy link
Member

mertalev commented Feb 25, 2026

There are a lot of changes being made to the network stack at the moment with URLSessionManager, etc. and this includes using the same session and cache for other API calls in addition to thumbnails. This PR makes a lot of changes in this area and introduces other session instances. If there's a good way to share the same session, I would prefer that instead. I'm also not sure about the specific approach of tracking access etc. the way it is done in this PR (for one thing, it turns every read into a write). Either way, I'd suggest waiting at least until #25942 is in before continuing work on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants