- Implemented a new bottom bar feature in `bottom-bar.js` that fetches and displays various notifications and statuses in real-time. - Added functions for handling visibility, state updates, and user interactions within the bottom bar. - Introduced WebSocket connection for real-time updates and fallback polling mechanism. - Created a manual testing script `test_manual.py` to validate API endpoints for the manual module. - Included tests for various paths to ensure expected responses from the server.
33 lines
870 B
Python
33 lines
870 B
Python
import time
|
|
from typing import Any, Optional
|
|
|
|
class ManualCache:
|
|
"""
|
|
Very simple in-memory TTL cache for the Manual MVP.
|
|
Stores GET lists and details. Clears fully on any mutation.
|
|
"""
|
|
def __init__(self, ttl_seconds: int = 300):
|
|
self.ttl = ttl_seconds
|
|
self._store = {}
|
|
|
|
def get(self, key: str) -> Optional[Any]:
|
|
item = self._store.get(key)
|
|
if item is None:
|
|
return None
|
|
if time.time() > item["expires"]:
|
|
del self._store[key]
|
|
return None
|
|
return item["value"]
|
|
|
|
def set(self, key: str, value: Any):
|
|
self._store[key] = {
|
|
"value": value,
|
|
"expires": time.time() + self.ttl
|
|
}
|
|
|
|
def clear(self):
|
|
self._store.clear()
|
|
|
|
# Global singleton instance for the app
|
|
manual_cache = ManualCache(ttl_seconds=300) # 5 min cache
|