to get the Unix timestamp:
cache_expire_time = datetime.datetime.fromtimestamp( [value for key, value in cache._expire_info.items() if 'devices' in key.lower()][0] ) - datetime.datetime.now()
to find out the remaining time in seconds:
cache_expire_time.seconds
Please note that this seems to work only for locmem and not memcached, if anyone knows how to do this in memcached, please comment
tovmeod
source share