Skip to content

Potential memory leak in memory store #19

Closed

Description

@jwoertink

Currently expired items aren't evicted from the cache. So if you store a bunch of items that expire and never get refreshed, all of those cached items will remain in memory.

When we read from cache and the item is expired, we should remove it from the cache before returning nil to ensure that it gets cleaned up.

Activity

  1. added a commit that references this issue on Mar 12, 2026
    5a07a31
  2. jwoertink commented on Mar 12, 2026

    @jwoertink
    MemberAuthor

    #20 will fix the issue of removing expired items from cache, but this will only happen when an item is read.

    We still have the issue of items expiring but then never being read again for us to know to remove them. We would still need some sort of cache sweeper that finds items expired and removes them. Maybe like if they've been expired for longer than X then there's a high chance they are LRU cache items so we can just remove them completely.

    Now the big question is, does this shard create some sort of loop that runs in a spawn? Or does it just create a worker class and leave it to you to run in your own cron? 🤷‍♂️

  3. added a commit that references this issue on Mar 19, 2026
    75f13e6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions