My wiki needs some HTML templates which it used to load on startup. However, the HTML templates are not required when running the wiki from the command line to search, for example. So I rewrote the code to loaded them on every request, figuring it was cheap. But I don't like it. Just now I rewrote it so that it loads them all when the first one is required, and then it installs a filesystem watcher that checks whether any of the files gets a write event and if it does, it starts a timer that calls a function that checks whether any of the templates that have been written to haven not gotten any additional writes in the last second and only then it reloads them. And a mutex and removal from the cache, and timers, go routines and all the other stuff I usually hate. But it wasn't too bad and it seems to work.
https://src.alexschroeder.ch/oddmu.git