· python

funkycache: a Python library to cache functions in SQLite

Six months ago, I wrote an SQLite-backed cache to speed up the build system for this site.


A static site generator is an ideal candidate for caching, because there are lots of steps that have deterministic behaviour and no side effects. On a site with hundreds of pages, even a few milliseconds per step adds up to a meaningful improvement. That first cache was fairly basic.

It supported getting and setting strings, with a namespace for different functions, and not much else: from mosaic.cache import SQLiteCache cache = SQLiteCache("example.db") cache.set(namespace="fibonacci", key="10", value="55") print(cache.get(namespace="fibonacci", key="10"))This showed the value of a cache, but it provided cache storage, not cache logic. If I wanted to cache a function, I had to write per-function logic for saving values to the cache and retrieving them later.

Earlier coverage

Related coverage

Also worth reading

  1. next.js 16.5.0-canary.54 released
  2. next.js 16.5.0-canary.53 released
  3. With Qwen4-Max, Alibaba puts the open source jacket back on the hanger
  4. Janet Reno was talking about my friend Coolio (computer criminal)
  5. US allies deepen deal to guard AI supply chains against 'hostile actors' (cough, China, cough)