title: How to make arguments in python decorator configurable?
body: <p>I am using <a href="https://github.com/tkem/cachetools" rel="nofollow noreferrer">cachetools</a> for some basic caching. Here is an example of how I am using it:</p>
  <pre><code>class Access:
  
    @cached(cache=TTLCache(maxsize=5, ttl=10))
    def get_some_value(input: str):
      # do some calls and return a value
  </code></pre>
  <p>The problem here is how do I make the <code>maxsize</code> and <code>ttl</code> configurable? I cannot do something like</p>
  <pre><code>class Access:
    def __init__(self, maxsize: int = 5, ttl: int = 10):
      self.maxsize = maxsize
      self.ttl = ttl
  
    @cached(cache=TTLCache(maxsize=self.maxsize, ttl=self.ttl))
    def get_some_value(input: str):
      # do some calls and return a value
  </code></pre>
  <p>I am looking for a way to inject those values if required and also have a default. Any helpful pointers?
  Also, <code>get_some_value()</code> need not be an instance method. I could just make it a class method or module level also if need be.</p>