Skip to content

Feature request: set without extending the expiration or adding new items #144

@favonia

Description

@favonia

This is related to #115 and #121.

The logic of PreviousOrDefaultTTL could still (conceptually) extend the expiration time if the item just expired and then got recycled. I wish to have a genuine PreviousTTL that would not add any new item if the item does not exist, assuming that the item was just recycled. One can argue that this behavior is perhaps closer to the spirit of #115 than #121, and that any reasonable use of PreviousOrDefaultTTL should be compatible with this new PreviousTTL.

Current workaround

There's already a way to implement this with the current ttlcache: instead of saving the data directly into the map, save a pointer to the data. Then, one can update the data without calling Set, avoiding expanding the expiration and potential new items altogether. I still feel we should consider this alternative PreviousTTL if PreviousOrDefaultTTL already exists.

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