angelnikolov/ts-cacheable

globalCacheBusterNotifier not working when using PCacheable decorator

Closed this issue · 2 comments

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.

Hey @geraparra, you can see a test which shows how globalCacheBusterNotifier works with @PCacheable.

it('should clear all caches when the global cache buster is called', async () => {

Are you sure you are importing promiseGlobalCacheBusterNotifier? It's a different token for promises
as you could see here

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

Thanks for your help.