Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5592

Requesting document-level LRU

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Requesting MongoDB to officially support "LRU Capped Collections", basically capped collections but with LRU instead of FIFO ordering. IOW I would like to be able to set a max collection size, and have MongoDB automatically delete least recently used (read or write) documents when full. The LRU need not be perfect, but a decent approximation would likely be good enough for most needs.

      This is a fundamental requirement for us using MongoDB as a cache, presently we will need to implement one of the following less desireable hacks:
      1) Maintain the LRU in app server memory (sucks in a clustered environment)
      2) Maintain a "last access" timestamp with every doc (sucks in that it turns every read into a write)

      Either way, we have to write a background job that continually monitors the db size and deletes when we hit a threshold (or do this on every write which is expensive). Which also sucks because it has ugly failure modes.

      Ideally, the LRU would be persisted. I can think of a few ways this can be done relatively cheaply, as long as the LRU is not expected to be exact. A simple in-memory lru would be sufficient for our needs though.

      A couple of things I don't need, though others might
      1) Support for sharded collections. I feel that a per-shard LRU is plenty good, no need to maintain perfect LRU behaviour across all servers.
      2) LRU across collections, which would add complex inter-collection behaviour

      Thanks and open to alternatives. I tried seeing how this could be simulated with capped collections but could not find a reasonable solution.

            Assignee:
            Unassigned Unassigned
            Reporter:
            peger P Eger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: