mailgun / expiringdict

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

calling 'keys' method doesn't clean up expirations at first. #14

Closed internety closed 7 years ago

internety commented 9 years ago

example:

from expiringdict import ExpiringDict
from time import sleep

expirationtest = ExpiringDict(max_len=100, max_age_seconds=5)
expirationtest["testing123"]="somedata"
print expirationtest.keys()
sleep(6)
print expirationtest.keys()

above example will print 'testing123' twice.

i am using python 2.7.10 and freshly installed expiringdict (via pip)

mdelcambre commented 8 years ago

From the readme, this appears to be known and potetially intended.

Note: Iteration over dict and also keys() do not remove expired values!

internety commented 7 years ago

You have right. Didn't read docs carefully enough....