code: def timed_cache(**timed_cache_kwargs):
      
  
      def _wrapper(f):
          maxsize = timed_cache_kwargs.pop('maxsize', 128)
          typed = timed_cache_kwargs.pop('typed', False)
          update_delta = timedelta(**timed_cache_kwargs)
          # nonlocal workaround to support Python 2
          # https://technotroph.wordpress.com/2012/10/01/python-closures-and-the-python-2-7-nonlocal-solution/
          d = {'next_update': datetime.utcnow() - update_delta}
          try:
              f = functools.lru_cache(maxsize=maxsize, typed=typed)(f)
          except AttributeError:
              print(
                  "LRU caching is not available in Pyton 2.7, "
                  "this will have no effect!"
              )
              pass
  
          @functools.wraps(f)
          def _wrapped(*args, **kwargs):
              now = datetime.utcnow()
              if now >= d['next_update']:
                  try:
                      f.cache_clear()
                  except AttributeError:
                      pass
                  d['next_update'] = now + update_delta
              return f(*args, **kwargs)
  
          return _wrapped
  
      return _wrapper
docs: LRU cache decorator with timeout.
  
      Parameters
      ----------
      days: int
      seconds: int
      microseconds: int
      milliseconds: int
      minutes: int
      hours: int
      weeks: int
      maxsise: int [default: 128]
      typed: bool [default: False]