vlio20 / utils-decorators

Decorators for web and node applications
https://vlio20.github.io/utils-decorators/
MIT License
216 stars 13 forks source link

Disable Caching for test envs #138

Open Nemo9439 opened 2 years ago

Nemo9439 commented 2 years ago

I'm using @memoizeAsync , and it tends screw up my unit tests , as the result of one test is being cached and returned in another test.

I want a simple way to disable caching globally in order to avoid this.

vlio20 commented 2 years ago

@Nemo9439 any suggestions?

tripodsgames commented 2 years ago

@Nemo9439 any suggestions?

@vlio20 I'm testing a branch with a global configuration object, so we can modify the settings at a global level. EX:

Config.Global.disableCache = true;

I want your opinion on this

vlio20 commented 2 years ago

@tripodsgames, I would like to avoid that because of the different configuration options that the different decorators have. Any other suggestions?

tripodsgames commented 2 years ago

@tripodsgames, I would like to avoid that because of the different configuration options that the different decorators have. Any other suggestions?

And a base configuration per decorator? EX:

memoizeAsync.DefaultSettings.disableCache = true;

It would even be useful to configure a default configuration. EX:

memoizeAsync.DefaultSettings.expirationTimeMs = 10000;
vlio20 commented 2 years ago

I think it would be better to have such configuration on the app level and not inside the lib. As there are multiple ways in which you could provide the configuration to the different decorators.

As more as I am thinking about a global configuration the less I want it to be part of the lib.

scaljeri commented 1 year ago

This issue is already old, maybe it should be closed. But anyway, my suggestion to @Nemo9439 is to write a wrapper decorator which does what he needs. I did something similar in this stackblitz