LOG · ENTRY← Blog

Quicache 3.1.0 released

A new version of Quicache has been released

Have you ever put off a minor task for so long that it becomes permanently embedded in your mental to-do list? Yeah, me too. In fact, that's basically my entire life. Today, I checked off one of those tasks.

What is QuiCache?

QuiCache is a development library that I originally built in July 2019. It's a small in-memory caching library that supports time-based expiry. For example, if you initalise a QuiCache instance with a 30s duration, it will clear that entry out of the cache when the timer expires.

I don't recall what project I originally built it for (possibly Panther or Railscope), but the goal was to have a short-lives in-memory cache using a compatibility that's 'universal' across JS runtimes. No localstorage, no asyncstorage, etc. Just pure JS memory storage.

QuiCache is now dependency free

The thing that I wanted to have for it was zero-dependencies. See, in order to easily manage the 'age' of a cached entry and determine if it should expire, I opted to use date-fns. This was primarily because I'd used momentjs in the original version, and then updated it to use date-fns in the interest of optimisation.

That dependency always bugged me, especially as it was only used in a single place. Removing it and rewriting it to use regular JS date was the thing that was on the checklist until today - 6 years after the last major version update.

Anything else?

A couple of things.

The first is that I'd like to make it API-compatible with the localstorage API. Right now, it couldn't be a drop-in alternative because it's synchronous but also the method names aren't the same - so, I'm considering adjusting the API to match localstorage, and providing an async version too.

The next is an optimisation I'm considering. Right now, adding an entry creates a new timeout for every single entry. It works, but it's definitely not as efficient as it could be. I'm considering moving over to using a single timer to sweep the entire cache, or lazy-clearing entries (i.e. validate on read), or potentially a hybrid of the 2 to account for edge case where someone accesses it in between timer ticks.

These are mostly just idle musings right now, but hopefully it won't be another 6 years before I get around to it. In either case, they will be a new major version.

How do I get it?

See the QuiCache for the library link.

Comments

Loading comments…

Leave a comment

Comments are reviewed before they appear.