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

Flush stats #158

Closed
melissafzhang opened this issue Nov 26, 2019 · 8 comments
Closed

Flush stats #158

melissafzhang opened this issue Nov 26, 2019 · 8 comments
Assignees

Comments

@melissafzhang
Copy link

Is there a way to flush stats? I would like to see how many cache hits/misses there are in a given time period. Thanks!

@sujeshthekkepatt
Copy link
Contributor

You can use myCache.getStats() for getting info on cache. To flush all data you can use myCache.flushAll().

@melissafzhang
Copy link
Author

melissafzhang commented Nov 26, 2019 via email

@sujeshthekkepatt
Copy link
Contributor

I think there is no method for just flushing stats.

@erdii
Copy link
Member

erdii commented Nov 26, 2019

@melissafzhang hey and welcome here :)

Do I understand this correctly:
You'd need a new function cache.flushStats() that resets the stats back to 0?

We do not expose such a function for now, but you can (for the time being) use this hack:

cache.stats = {
	hits: 0,
	misses: 0,
	keys: 0,
	ksize: 0,
	vsize: 0,
}

@erdii erdii reopened this Dec 3, 2019
@sujeshthekkepatt
Copy link
Contributor

@erdii are you working on this? If not I can take it upon.

@erdii
Copy link
Member

erdii commented Dec 5, 2019

@sujeshthekkepatt that would be nice! :)

@sujeshthekkepatt
Copy link
Contributor

Cool. I will work on it. :). Please do assign me on the issue :)

sujeshthekkepatt added a commit to sujeshthekkepatt/node-cache that referenced this issue Dec 8, 2019
Currently no method to flush the stats.
Flushing stats helpful for metrics analysis. See more node-cache#158
@erdii
Copy link
Member

erdii commented Dec 8, 2019

#161 has landed! thanks to @sujeshthekkepatt for the implementation and @melissafzhang for the idea

Edit: published in v5.0.2

@erdii erdii closed this as completed Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants