gennyble / textual

Text Rendering as a Service
Other
9 stars 1 forks source link

Cache #21

Open gennyble opened 2 years ago

gennyble commented 2 years ago

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.

passcod commented 2 years ago

(stealthily looks around) If you want to avoid writing a cache yourself, cacache is excellent at this (whispers)

gennyble commented 2 years ago

(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.