youknowone / ring

Python cache interface with clean API and built-in memcache & redis + asyncio support.
http://ring-cache.readthedocs.io/en/latest/
Other
480 stars 37 forks source link

ring.lru() maxsize behaves differently from functools.lru_cache() maxsize #136

Closed dmhowcroft closed 5 years ago

dmhowcroft commented 5 years ago

In functools.lru_cache() you can specify maxsize=None if you want to allow the cache to grow indefinitely.

If you try to do this with ring.lru(maxsize=None), however, you will run into a TypeError on line 117 of lru_cache.py when cache_len() is compared with maxsize, since the former is an integer and you have specified None for the latter.

Proposed fix: Change the code in lru_cache.py to skip this bounds check if maxsize is None.

youknowone commented 5 years ago

This fix will be included in next release. Thanks to @xymz