cacheable-lookup
cacheable-lookup copied to clipboard
Added get method to check number of cached calls
Issue #64
I implemented get
method to get the size of cached calls:
get numberOfCachedCalls() {
return this._cache.size
}
This is actually incorrect. It doesn't return the total number of cached requests, but the current cache size. I'd implement it like this:
this.stats = {
cache: 0,
query: 0,
};
and increment the counters respectively in https://github.com/szmarczak/cacheable-lookup/blob/5b08a3610a5ec1328da583a6327111428ff85c42/source/index.js#L213
You also need to provide some tests.
@GKosheev No need to duplicate code in the comments :) There's a review
feature and you can add comments there if necessary.
I'm not sure if I did the unit test as you wanted me to, I tried to follow the example you sent me with the verify
method.
But I am always ready to make corrections.
@szmarczak, should I change something specific in the last commit?
@szmarczak, would that work?
Will take a look now, sorry for delay. Also, no need to post a comment of your commit changes :)
Looks good! Thanks for contributing! :heart: