mailgun / expiringdict

Dictionary with auto-expiring values for caching purposes.
Apache License 2.0
347 stars 76 forks source link

Changed items aren't moved to the end of the list, will be expired in the wrong order #34

Open MattEttus opened 5 years ago

MattEttus commented 5 years ago

The order in an OrderedDict is based on the order of original insertion. If you modify an item, even though the expiry is changed, it stays in the same position as it originally was. This can cause the wrong items to be dropped.

The solution would be to first delete the item before setting it in set item.

MattEttus commented 5 years ago

To clarify, this can result in newer unexpired items being pushed out while older expired items remain.