Simulate st.cache_data(ttl=...). Input: ttl T (seconds), cost C (seconds per database query), then requests TIME KEY in increasing time.
A request is a hit if the key is cached and TIME − cached_time < T; otherwise the database is queried and the cache entry is refreshed. Print per request t= 10 district=Lucheng: cache hit (data 10 s old) or t= 0 district=Lucheng: query database (2.5 s) (time right-aligned in 4 characters), then hits 3/7 (43%), database time 10 s instead of 17.5 s and worst-case staleness shown to users: 299 s (TTL 300 s).