change default cache resolver
See original GitHub issuethe default cache resolver simply does a JSON.stringify test against the old and new parameters. This does not take into account the position of the properties and can lead to false results (depending on your point of view).
If you were to use object-hash to compare the two objects this is no longer an issue. See the code sample below
const hash = require('object-hash');
const p1 = { d1: 'd1', d2: 'd2' };
const p2 = { d2: 'd2', d1: 'd1' };
const hash1 = hash(p1);
const hash2 = hash(p2);
console.log('json', JSON.stringify(p1) === JSON.stringify(p2));
console.log('hash', hash1, hash2, hash1 === hash2);
the result of this is
json false hash f4c434a0e4c11deb776f4281c9b3848ccbe63578 f4c434a0e4c11deb776f4281c9b3848ccbe63578 true
this could be implemented by default , or by adding an option to specify a different cache resolver so that it won’t break existing code that relies on key position creating different cache results
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
change default cache resolver · Issue #14 - GitHub
There is an option to specify a different cache resolver already. You can just supply a cacheResolver to the config. All reactions.
Read more >33. Caching - Spring
Some offer a way to customize the default caches defined by the ... It is also possible to force a particular cache provider...
Read more >3 Ways to Configure Multiple Cache Managers in Spring Boot
We can define a default cache manager using this approach. You can continue using the caching annotation with no change.
Read more >spring cache with custom cacheResolver - Stack Overflow
Plain caching config works. I've lookad at spring code, it reads cacheResolver correctly but then fails on validation. Looks like a Spring bug ......
Read more >The default resolver settings - IBM
The following resolver functions are active by default: System-wide caching, which uses the default maximum cache size, the default maximum time-to-live (TTL) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Let me think about that… That’s quite a jump for a 6kb library. It drags along
crypto
which is pretty big. I feel like the benefit we gain from adding this compare to what we lose is smaller and is something that can be mitigated by a better documentation, i.e - if you want your cache to resolved properly for object parameters, they should have the same shape.@angelnikolov Can you please give me an example of using cacheResolver and cacheHasher and its difference,As i am using your package for my project,as of now not facing any issue while using other configurations except this two.