Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instant cache busting #123

Merged
merged 21 commits into from
Sep 28, 2022
Merged

Conversation

ragtam
Copy link
Contributor

@ragtam ragtam commented Jul 31, 2022

This is a PR related to issue #121

Adds isInstant property to ICacheBusterConfig.

This is used as a predicate wether to clear cache before decorated method has been executed. If no isInstant property is set (default behaviour), then cache is cleared same way as it used to be, i.e after observable has emitted for @CacheBuster(), or after promise has been resolved for @PCacheBuster(). No breaking changes.

Copy link
Owner

@angelnikolov angelnikolov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR! (loved the tests!) I will take a better look tomorrow, but for now I left two comments.
Also, your indentation seems to be different than the project's.
Also, do you mind adding a couple of more Unit tests to promise-cacheable.decorator.spec.ts and observable-cacheable.decorator.spec.ts which test the new flag in integration with a @PCacheable and @Cacheable?

dist/esm5/common/ICacheBusterConfig.d.ts Show resolved Hide resolved
package.json Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jul 31, 2022

Codecov Report

Base: 75.08% // Head: 77.30% // Increases project coverage by +2.21% 🎉

Coverage data is based on head (3114659) compared to base (35fe12e).
Patch coverage: 97.29% of modified lines in pull request are covered.

❗ Current head 3114659 differs from pull request most recent head 9f46f7f. Consider uploading reports for the commit 9f46f7f to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #123      +/-   ##
==========================================
+ Coverage   75.08%   77.30%   +2.21%     
==========================================
  Files          12       13       +1     
  Lines         301      326      +25     
  Branches       79       83       +4     
==========================================
+ Hits          226      252      +26     
  Misses         60       60              
+ Partials       15       14       -1     
Impacted Files Coverage Δ
common/CacheBusterFunctions.ts 80.00% <80.00%> (ø)
cache-buster.decorator.ts 95.00% <100.00%> (+15.00%) ⬆️
common/index.ts 100.00% <100.00%> (ø)
promise.cache-buster.decorator.ts 94.44% <100.00%> (+14.44%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ragtam
Copy link
Contributor Author

ragtam commented Aug 1, 2022

Let me fix the indentation and add a couple of unit tests

@ragtam
Copy link
Contributor Author

ragtam commented Aug 15, 2022

Hey I added unit tests for observable cachable and promise cachable decorator. The one in promise is currently disabled due to some strange bug in AsyncStorageStrategy tests. It fails ocasionally (when run with npm run test, calling only the single test works fine). The problem appears on master too, when cache data until the cacheBusterNotifier has emitted test is duplicated. I still need to investingate what is happening there, but would appreciate some help. Cheers!

@angelnikolov
Copy link
Owner

@ragtam Tried your and ran the tests multiple times and unfortunately couldn't get it to fail.
I am 99% sure that this is related to a global state issue due to Jasmine running the tests in a randomized order.
I've added karma-jasmine-seed-reporter which will print out the seed number for your test run. When it fails, you can re-run your tests with JASMINE_SEED and reproduce it. That way you should be able to find the statefulness in the tests and fix the issue. Let me know if I can help furhter. Other than that the PR looks great! Nice typing improvements too!

@ragtam
Copy link
Contributor Author

ragtam commented Sep 21, 2022

Hey, its been some time, the issue is still on my radar, but now I am occupied with some private stuff. Ill see to that as soon I have some time.

@ragtam
Copy link
Contributor Author

ragtam commented Sep 28, 2022

@angelnikolov it took me some time but finally its working. The issue was quite trivial:
In promise-cacheable.decorator there are 3 strategies suite is run against, in describe block there used to be a declaration of a Service class, it is used to mock service calls. Due to the fact it was declared in describe block, it was newing up a strategy once only, as a result cache was shared between different test cases, this is why each of the test run separately was green, but running all of them failed. I moved Service class declaration to beforeEach block (the same way as in observable-cacheable) and it solved the issue. Still thanks for help and sorry it took so long.

@angelnikolov
Copy link
Owner

Failure unrelated. Merging.

@angelnikolov angelnikolov merged commit ffdd21b into angelnikolov:master Sep 28, 2022
@angelnikolov
Copy link
Owner

@ragtam Thanks a lot for your first contribution! The library has been updated in NPM as 1.0.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants