Julien-R44 / bentocache

🍱 Bentocache is a robust multi-tier caching solution for Node.js applications
https://bentocache.dev
MIT License
394 stars 10 forks source link

Liveness probes #9

Open nicolabovolato opened 8 months ago

nicolabovolato commented 8 months ago

Hi and thank you for this much needed library.

Have you considered, or are you planning to add, a way to drivers are able to communicate properly? I'm thinking about exposing a function to ping redis or select 1 a database.

It would be great to have such functionality available on the BentoCache instance, to be called when needed or exposed by an http route.

Julien-R44 commented 8 months ago

hey, thanks !

i am not sure if that's the role of the library to do that

when you create your Bentocache instance, you must pass your ioredis instance, for example. so you can keep this instance around and use it for your route + health check. so yeah, nothing stops you from doing this without bentocache exposing this functionality. It just seems a bit out of scope to me

and also, there are drivers for which it wouldn't make sense to have this, like filesystem and in-memory.

let me know what you think

nicolabovolato commented 8 months ago

I agree with you that if a library like bentocache provides one with the ability to supply his own (redis or whatsoever) instances there should be no need to implement healthchecks. Still I think that given the aim of bentocache, a built in healthcheck would be nice!

Moreover, I don't see this capability with redis' bus driver, as in the constructor you can only provide ioredis options. I could always wrap or extend the driver class if it wasn't that (and rightly so) underlying instances are private members.

As for memory or fs drivers, I still think that a healthcheck can [1] [2] be implemented, even if that may not make sense for common workloads. Also, testing won't be trivial.

With that being said, I still think it would be a nice feature but perhaps not as valuable as it is to me for other users. Up to you! I would be happy to submit a pr should ever change your mind.