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

Possible mistake when clearing query cache #1264

Closed
bokmadsen opened this issue May 16, 2019 · 1 comment
Closed

Possible mistake when clearing query cache #1264

bokmadsen opened this issue May 16, 2019 · 1 comment

Comments

@bokmadsen
Copy link

In the documentation it states that the query cache is cleaned up, once in a while. However looking at the code it looks like it clears the entire cache every 1000 queries. This is due to the check in this line:

https://github.com/StackExchange/Dapper/blob/d19d6012e75feebf24d591ad21b16f13becc95f2/Dapper/SqlMapper.cs#L78

COLLECT_HIT_COUNT_MIN is defined as:
https://github.com/StackExchange/Dapper/blob/d19d6012e75feebf24d591ad21b16f13becc95f2/Dapper/SqlMapper.cs#L91

Wouldn't that render the IF statement true every time, as hitcount always would be >= 0?

@NickCraver
Copy link
Member

This method is behaving correctly - the first time a query is added to the cache, it has a hitCount of 0. Only if it's used again does it get a hitCount++, so that method is cleaning up things that are never re-used as is the intent :)

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

No branches or pull requests

2 participants