node-request-caching icon indicating copy to clipboard operation
node-request-caching copied to clipboard

Custom storage

Open ericclemmons opened this issue 12 years ago • 2 comments

First, great library. I'm using it extensively and will have some upcoming PRs.

But first, I wanted to ask how you think custom storage adapters should work. Ideally, I would like to be able to use my own custom implementation:

storage: {
  adapter: require('./store/file'),
  options: {
    path: '~/tmp`
  }
}

This would also require that my local lib has access to lib/store/store.js, which is the prototype for all other stores.

How would you like to go about this?

ericclemmons avatar Mar 31 '13 15:03 ericclemmons

Hi @ericclemmons and thank you for your feedback. Regarding the store it wasn't meant to be extended outside the lib, rather to add additional store to the lib itself. For example a file storage could be potentially of great use also for others.

We could however think about exporting the store API so that it can be extended by simply gaining access to a static RequestCaching.Store and then refactor the config options as you proposed.

What do you think about that?

matteoagosti avatar Apr 01 '13 12:04 matteoagosti

I agree that submitting a PR would be ideal.

First, though, it would be very easy to have a working implementation if I could push a custom store locally using the method you mentioned (or similar).

Then I could easily abstract out something functional into a PR and get it into the core.

Let me know how I can help!

ericclemmons avatar Apr 01 '13 14:04 ericclemmons