Clarification on ts-cacheable Cache Busting Policy

Discussão em 'Angular' iniciado por sigur, Agosto 6, 2025.

  1. sigur

    sigur Guest

    I'm considering using the ts-cacheable library (github - angelnikolov/ts-cacheable) for a personal project, and I need some clarification regarding its cache management policy, specifically concerning method calls with different parameters.

    The documentation states:


    If we call this method by service.getUser(1), its return value will be cached and returned, up until the method is called with a different parameter. Then the old cache will be busted and a new one will take its place.
    ​

    This suggests that if I call sayHelloWorldTo('Chandler') and then sayHelloWorldTo('Monica'), the cached entry for 'Chandler' would be replaced by the one for 'Monica'. A subsequent call to sayHelloWorldTo('Chandler') would then bust the 'Monica' entry and create a new one for 'Chandler'.

    Is there a way to cache multiple results from the same method call? My goal is to cache up to 20 unique results for a method. I'd expect the following sequence of calls to persist results in the cache without overwriting each other:

    sayHelloWorldTo('Phoebe');
    sayHelloWorldTo('Ross');
    sayHelloWorldTo('Chandler');
    sayHelloWorldTo('Phoebe');
    sayHelloWorldTo('Joey');
    sayHelloWorldTo('Monica');


    Could you confirm if this is the intended behavior and if there's a configuration option or decorator that would allow for multiple cached entries per method?

    Continue reading...

Compartilhe esta Página