Skip to content

Implement smart cache size management with LRU eviction #324

@RUKAYAT-CODER

Description

@RUKAYAT-CODER

Background

Cache can grow unbounded consuming all storage. Implement LRU (Least Recently Used) eviction policy with configurable max size. When cache approaches limit, evict oldest/least-used items.

Description

Implement LRU cache eviction to prevent unbounded cache growth.

Current Behavior

Cache grows indefinitely until storage full

Expected Behavior

LRU eviction maintains max cache size

Impact

💾 Bounded memory usage
🛡️ Prevent storage exhaustion
📊 Predictable cache performance

Acceptance Criteria

  • Implement LRU eviction policy
  • Set max cache size (e.g., 100MB)
  • Evict least recently used items when limit reached
  • Test cache behavior at limit
  • Verify no data loss during eviction
  • Monitor cache hit rate impact
  • Document cache management

Implementation Hints

Use LRU data structure (Map with ordering). Track access times.

Performance Metrics

Before:

  • storageUsage: Grows until 100% (OOM)

After (Target):

  • storageUsage: Capped at 100 MB with LRU

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions