angelnikolov / ts-cacheable

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

globalCacheBusterNotifier not working when using PCacheable decorator #137

Closed geraparra closed 1 year ago

geraparra commented 1 year ago

Following the documentation:

If you want to globally bust your whole cache (i.e caches of all Cacheable decorators), just import the globalCacheBusterNotifier and call next() on it, like:

import { globalCacheBusterNotifier } from 'ts-cacheable';

globalCacheBusterNotifier.next();

I tried implementing global cache buster to clear whole cache but it's not working when a method is using PCacheable decorator, if I change to Cacheable decorator then globalCacheBusterNotifier.next() works fine, seems that something it's going on with PCacheable decorator.

do I need something different to use globalCacheBusterNotifier but support PCacheable decorators?

Regards,

Geri.

angelnikolov commented 1 year ago

Hey @geraparra, you can see a test which shows how globalCacheBusterNotifier works with @PCacheable. https://github.com/angelnikolov/ts-cacheable/blob/64c2728ce5066beb028deb3423c92a5df3f562ad/specs/promise-cacheable.decorator.spec.ts#L634 Are you sure you are importing promiseGlobalCacheBusterNotifier? It's a different token for promises as you could see here

geraparra commented 1 year ago

thank @angelnikolov now it's working, I was importing a wrong token for promises.

Thanks for your help.