matcha icon indicating copy to clipboard operation
matcha copied to clipboard

FEAT: Email body cache should have a size limit

Open andrinoff opened this issue 7 months ago • 4 comments

Is your feature request related to a problem?

Email bodies are cached to disk via config.SaveEmailBody() with no global size limit or eviction policy. For active users with large mailboxes, the ~/.cache/matcha/email_bodies/ directory can grow to hundreds of megabytes or more over time.

Describe the solution you'd like

Implement a cache size limit with LRU eviction:

  • Set a configurable maximum cache size (e.g. default 100MB)
  • When the limit is reached, evict the least recently accessed entries
  • Alternatively, use time-based expiration (e.g. evict entries older than 30 days)

Describe alternatives you've considered

Manual cache clearing by the user (rm -rf ~/.cache/matcha/email_bodies/). This works but is not user-friendly and clears everything.

Additional context

The existing PruneStaleBodyCache function only removes bodies for UIDs no longer in the folder email list — it doesn't limit total cache size.

andrinoff avatar Apr 15 '26 19:04 andrinoff

Hi @andrinoff,

It seems I already solved this issue before in #1171 and #1227.

So I can’t understand what the difference is. I think my work may have just been overwritten?

mavonx avatar May 11 '26 07:05 mavonx

Hi @andrinoff,

It seems I already solved this issue before in #1171 and #1227.

So I can’t understand what the difference is. I think my work may have just been overwritten?

It was improved in #1257 by @FromSi

andrinoff avatar May 11 '26 07:05 andrinoff

@andrinoff

Is the only difference that the cache is now global across all folders instead of per-folder?

mavonx avatar May 11 '26 07:05 mavonx

@andrinoff

Is the only difference that the cache is now global across all folders instead of per-folder?

also a more robust multi-email caching, where it fails less, than you're variation did

andrinoff avatar May 11 '26 07:05 andrinoff