angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

Async storage strategies with observable @Cacheable decorator #136

Closed fiavanana closed 2 months ago

fiavanana commented 1 year ago

Local storage works great with @Cacheable decorator, but the local storage is very limited in space. We would like to use async storage strategies (ionic storage or capacitor storage) and keep using @Cacheable decorator as we are using Observable in our code and not Promise. We see the note in the documentation:

IMPORTANT: Right now, we only support async strategies as a configuration for our promise decorators

Is this possible to implement a solution for that case? Or do you know if someone already use a solution?

Thank you!

angelnikolov commented 1 year ago

Hey @fiavanana this is a really nice feature that you are asking for and I can see how it can be useful with async APIs like IndexedDB and others. However I am having trouble finding time right now and while this seems trivial, it will require some internal changes since most of the @Cacheable is entirely synchronous right now with no assumptions neither for observables, nor any async operations.

That said, if you are willing to implement the solution I will be happy to review. Otherwise, this will a while :) Thank you anyway!