node-fetch-cache icon indicating copy to clipboard operation
node-fetch-cache copied to clipboard

Support redis?

Open RichardWright opened this issue 2 years ago • 1 comments

Hi

Are there any plans to extend this support a redis plugin?

Thanks

RichardWright avatar Jan 19 '24 13:01 RichardWright

Hi,

No specific plans but I do indeed want to create a Redis plugin! It will happen but I can't say when.

mistval avatar Jan 20 '24 01:01 mistval

Hi. We created a Redis custom cache. Works fine and tests all pass. ioredis is an optional dependency - required to use redis as a cache or perform the redis tests. You can see it in this fork in the redis-cache branch: https://github.com/dxclabs/node-fetch-cache/tree/redis-cache Needs some fixes, but if we can get through them, happy to submit as a PR.

campbellmc avatar Jun 22 '24 17:06 campbellmc

Hi @campbellmc , that looks great 🙌 A PR would be very much welcome!

mistval avatar Jun 22 '24 21:06 mistval

Yeah ok.

We have issues which are blocks at the moment.

These are all around having ioredis as an optional dependency:

(1) We detect ioredis being present with await import ... Problem is that the await at top level prevents cjs being built.

(2) we still need ioredis types which are in the ioredis package - doesn't appear possible to install independently

(3) We need to be able to return undefined from the set method in the case that ioredis is not installed. Although README.md says that a return value of undefined is ok, it's not actually in src/types.ts.

So if you ware ok with it, we will make ioredis a dependency (rather than an optional dependency).

It will have an impact on package size, but not a great one:

https://bundlephobia.com/package/[email protected]

campbellmc avatar Jun 24 '24 11:06 campbellmc

I think it may be best then to publish it as a separate package, with ioredis as a non-optional dependency. We could either add a plugins folder in this repo and add it there, or it could be an entirely separate repo.

If you want, you could just MR what you have, and then I'd be glad to do the plumbing and move it into a plugins folder and get it published. Or if you would like to publish it yourself in a separate repo, then of course feel free!

mistval avatar Jun 24 '24 20:06 mistval

All yours. 😎

campbellmc avatar Jun 24 '24 20:06 campbellmc

Redis is now supported via the @node-fetch-cache/redis package thanks to @campbellmc and associates.

mistval avatar Jun 29 '24 20:06 mistval