expiringdict
expiringdict copied to clipboard
Changed items aren't moved to the end of the list, will be expired in the wrong order
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.
To clarify, this can result in newer unexpired items being pushed out while older expired items remain.