jftsang / mdpmflc

A web interface for MercuryDPM
0 stars 0 forks source link

As admin, I WANT to be able to clear the cache manually or automatically #23

Open jftsang opened 4 years ago

jftsang commented 4 years ago

There is currently no way of clearing the cache (except through manually deleting files in that directory), which means that it could get rather large after a while.

Possible solution is to have a cronjob that removes files older than 3 days.

jftsang commented 3 years ago

Use diskcache to cache images, with the option to refresh. This pattern doesn't quite work...

from diskcache import Cache

cache = Cache()

def fib(x: int, refresh: bool = False) -> int:
    if refresh:
        cache.evict(tag="fib")  # but can we evict just a single argument?

    return _fib(x)

@cache.memoize(tag="fib")
def _fib(x: int) -> int:
    print(f"Evaluating F_{x}")
    if x == 0 or x == 1:
        return x
    return fib(x-1) + fib(x-2)