File size: 639 Bytes
0f305ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from datetime import datetime, timedelta
import uuid
# Simple in-memory cache (replace with Redis in production)
result_cache = {}
CACHE_EXPIRY_HOURS = 1
def store_result(data):
cache_id = str(uuid.uuid4())
expiry = datetime.now() + timedelta(hours=CACHE_EXPIRY_HOURS)
result_cache[cache_id] = {
'data': data,
'expiry': expiry
}
return cache_id
def get_result(cache_id):
if cache_id not in result_cache:
return None
if datetime.now() > result_cache[cache_id]['expiry']:
del result_cache[cache_id]
return None
return result_cache[cache_id]['data'] |