Open gennyble opened 2 years ago
(stealthily looks around) If you want to avoid writing a cache yourself, cacache is excellent at this (whispers)
(nods, whispering) cacache
looks very clean. I probably won't use it, though. I'm,,, (giggles) I'm weirdly looking forward to writing my little cache.
I was avoiding caching things because I liked the "generated on the fly" appeal, right, but that's just wasteful and inefficient. So, cache idea:
sha256 hash the query string and use that as a filename to save the image into wherever-the-cache-is-on-disk. A HashMap lives in memory with the sha256 as the key and the alt-text as the value.
Perhaps we should add a bit to statistics to indicate cache hits and misses.