tkem / cachetools

Extensible memoizing collections and decorators
MIT License
2.34k stars 163 forks source link

Missing cache_info() for @cachedmethod #307

Closed aggsol closed 7 months ago

aggsol commented 8 months ago

I am implementing a cached method with cachetools like this:

class CachedNum(object):

    def __init__(self, cachesize):
        self.cache = LRUCache(maxsize=cachesize)

    @cachedmethod(lambda self: self.cache)
    def get(self, num):
       return num + 1000

nums = CachedNum(cachesize=10)

nums.get.cache_info() # This is missing
nums.cache.cache_info() # The cache itself also has no statistics

In contrast there are no cache statistics about hits/misses. Is this an oversight in cachetools or do I need to track them myself?

tkem commented 7 months ago

No, it's not an oversight, there just wasn't agreement on how self should be used with cache_info(), and there hasn't been sufficient demand for this, at least to my knowledge. PRs are welcome, of course.