funkycache: a Python library to cache functions in SQLite 0 ▲ alexwlchan 39 minutes ago · 9 min read1894 words · Tech · hide 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. A lot of that code was tricky to test, and broken in subtle ways. I was so unsure of this code that I deleted the cache whenever I built… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town