Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Make cache LRU #105

@schuderer

Description

@schuderer

Caching in DataSources (as enabled with an ‘expires’ value other than 0), can be made more fit for purpose by following the Last Recently Used principle instead of, currently, Last Recently Added. That way, the items that are requested more frequently tend to stay in the cache longer. Currently, if an item has been added a longer time ago, it will be removed if enough new items have been added to push it out of the cache FIFO.

This should be trivial to achieve using OrderDict’s move_to_end method in the OrderedDict subclass’ getitem to move the last requested item to the “last added” (end) position of the dict.

However, care must be taken to test this properly and differentiate it from the previous FIFO style in the unit tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions