angelnikolov / ts-cacheable

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

Serialized parameters are used to call the original method on cache miss #54

Closed iherwig closed 4 years ago

iherwig commented 5 years ago

Hi there,

first, thanks for this very useful library!

I noticed a problem with non-primitive parameters in methods annotaged with @Cacheable.

Cacheable uses serialized values instead of the original values when calling a method in case of a cache miss. This will cause problems, if the method needs to access methods or properties of the original parameter values.

The attached diff fixes the problem in cacheable.decorator.js in my case: cacheable.decorator.js.diff.txt

Best regards Ingo

angelnikolov commented 5 years ago

@iherwig Thanks for reporting this. The serilization was implemented due to https://github.com/angelnikolov/ngx-cacheable/issues/7. Let me think about that for a while, this might require the same solution as for #53.

iherwig commented 4 years ago

Thanks for the quick reply and fix (#55)!