'Constructor.
This cache will refresh the age of the cached object as long as they are
accessed within the allowed age. The age refers to the time since it was
last touched.
Args:
max_size: The maximum number of objects held in cache.
max_age: The maximum length of time an object is considered alive.'

def __init__(self, max_size=10, max_age=600):

    super(TimeBasedCache, self).__init__(max_size)
    self.max_age = max_age
    def HouseKeeper():
        'A    housekeeper    thread    which    expunges    old    objects.'
        if (not time):
            return
        now = time.time()
        for cache in TimeBasedCache.active_caches:
            with cache.lock:
                for node in cache._hash.values():
                    (timestamp, obj) = node.data
                    if ((timestamp + cache.max_age) < now):
                        cache.KillObject(obj)
                        cache._age.Unlink(node)
                        cache._hash.pop(node.key, None)
    if (not TimeBasedCache.house_keeper_thread):
        TimeBasedCache.active_caches = weakref.WeakSet()
        TimeBasedCache.house_keeper_thread = InterruptableThread(name='HouseKeeperThread', target=HouseKeeper)
        TimeBasedCache.house_keeper_thread.start()
    TimeBasedCache.active_caches.add(self)
