Open jzr-supove opened 2 years ago
Add option to pass custom function that is executed when element being deleted, so that we can process elements before they gone
Example usage:
def process(key, value): print(key, value) cache = ExpiringDict(max_len=2, max_age_seconds=1, on_delete=process) cache[0] = "A" cache[1] = "B" cache[2] = "C" cache[3] = "D"
Outputs:
0 A 1 B
Fixed issue when key gets deleted even though its updated recently
Example:
cache = ExpiringDict(max_len=2, max_age_seconds=1) cache['r'] = "Red" cache['g'] = "Green" cache['r'] = "LightRed" cache['b'] = "Blue" print(cache)
Output before:
ExpiringDict([('g', 'Green'), ('b', 'Blue')])
Output after fix:
ExpiringDict([('r', 'LightRed'), ('b', 'Blue')])
Trigger on delete
Add option to pass custom function that is executed when element being deleted, so that we can process elements before they gone
Example usage:
Outputs:
Hotfix
Fixed issue when key gets deleted even though its updated recently
Example:
Output before:
Output after fix: