INNER CODE UNIT · Python

_market_cache

YichengYang-Ethan/oracle3 · oracle3/blinks/server.py:28

_market_cache: dict[str, tuple[float, dict]] = {}  # ticker -> (timestamp, metadata)
_CACHE_TTL = 300  # 5 minutes


def _get_cached_market(ticker: str) -> dict | None:
    """Return cached market metadata if still valid, else None."""
    entry = _market_cache.get(ticker)
    if entry is None:
        return None
    ts, data = entry
    if time.monotonic() - ts > _CACHE_TTL:
        del _market_cache[ticker]
        return None
    return data


def _set_cached_market(ticker: str, data: dict) -> None:
    """Store market metadata in cache."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…