Skip to content

Expirable LRU does not always call eviction callback under high pressure #208

@desertwitch

Description

@desertwitch

I understand this project appears largely unmaintained, but I'm documenting this issue for the record and to help other developers avoid the extensive debugging pain I experienced.

Under high-pressure conditions (heavy cache load causing numerous capacity-driven evictions), the eviction callback is not consistently invoked for every evicted item. I've observed this intermittently in my monitoring metrics, where cached resources were garbage collected without their eviction callbacks ever executing.

After significant investigation, I was able to confirm this behavior by adding a callbackCalled flag to my cached objects and validating it using a runtime finalizer. However, I spent many hours debugging before discovering the root cause of the discrepancy between my "open resources" and "closed resources" metrics.

I have since migrated to ttlcache, but I hope documenting this helps others encountering similar issues.

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