Implement a simple in-memory cache using a dictionary with TTL support to reduce database load for repeated queries. The cache is integrated into the data retrieval functions, with configurable expiration times and automatic cleanup of stale entries.