Refresh data every day

My app has a set of links, and generating these is a time-consuming operation. What would be the best way to implement a mechanism that refresh these data every day?

Barring that, I could make these links part of dcc.Store component with session-level persistence. How that store should be populated so that it’s executed only once per user session?

You could use a serverside cache (one per session) with daily expiration.

2 Likes

Thanks, I decided to use something akin to that.

result = fun(get_ttl_hash(seconds=12 * 3600) # 24h cache

@functools.cache
def fun(ttl_hash=None):
     pass

def get_ttl_hash(seconds: int = 24 * 3600) -> int:
    """
    Return the same value withing `seconds` time period
    :param seconds: time period
    :return:
    """
    return round(time.time() / seconds)
1 Like