cacheable-lookup icon indicating copy to clipboard operation
cacheable-lookup copied to clipboard

Added get method to check number of cached calls

Open GKosheev opened this issue 2 years ago • 3 comments

Issue #64

I implemented get method to get the size of cached calls:

get numberOfCachedCalls() {
    return this._cache.size
}

GKosheev avatar Aug 06 '22 18:08 GKosheev

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.

szmarczak avatar Aug 06 '22 19:08 szmarczak

@GKosheev No need to duplicate code in the comments :) There's a review feature and you can add comments there if necessary.

szmarczak avatar Aug 10 '22 10:08 szmarczak

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.

GKosheev avatar Aug 12 '22 19:08 GKosheev

@szmarczak, should I change something specific in the last commit?

GKosheev avatar Aug 19 '22 12:08 GKosheev

@szmarczak, would that work?

GKosheev avatar Sep 07 '22 14:09 GKosheev

Will take a look now, sorry for delay. Also, no need to post a comment of your commit changes :)

szmarczak avatar Sep 07 '22 15:09 szmarczak

Looks good! Thanks for contributing! :heart:

szmarczak avatar Sep 07 '22 15:09 szmarczak