/
mkiiis
/
task_tracker
Обзор
Документация
Войти
/
mkiiis
/
task_tracker
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
app/idempotency.py
22 строки
544 B
mkiiis
lab4
14 дек 2025, 05:32
14 дек 2025, 05:32
88d2183
Код
Авторство
О чём код?
import time from typing import Optional, Dict, Any, Tuple _idemp_storage: Dict[str, Tuple[dict, float]] = {} IDEMPOTENCY_TTL = 24 * 3600 def get_key(key: str) -> Optional[dict]: record = _idemp_storage.get(key) if not record: return None value, expires_at = record if time.time() > expires_at: _idemp_storage.pop(key, None) return None return value def set_key(key: str, value: dict, ttl: int = IDEMPOTENCY_TTL): expires_at = time.time() + ttl _idemp_storage[key] = (value, expires_at)