utils-decorators icon indicating copy to clipboard operation
utils-decorators copied to clipboard

Disable Caching for test envs

Open Nemo9439 opened this issue 2 years ago • 6 comments

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.

Nemo9439 avatar Apr 04 '22 10:04 Nemo9439

@Nemo9439 any suggestions?

vlio20 avatar Apr 04 '22 10:04 vlio20

@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

tripodsgames avatar May 30 '22 17:05 tripodsgames

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

vlio20 avatar May 30 '22 17:05 vlio20

@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;

tripodsgames avatar May 30 '22 18:05 tripodsgames

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.

vlio20 avatar May 30 '22 18:05 vlio20

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

scaljeri avatar Oct 01 '22 20:10 scaljeri