python-diskcache icon indicating copy to clipboard operation
python-diskcache copied to clipboard

Non transactional cache hit/miss statistics

Open ddorian opened this issue 2 years ago • 2 comments

@grantjenks

This is to move cache hit/miss outside of the get transaction.

A use case is to override it, make it async, and update the hit/miss counters in the db every 2-seconds instead of every transaction.

If you agree I'll fix linting etc.

ddorian avatar Mar 04 '24 08:03 ddorian

A use case is to override it, make it async, and update the hit/miss counters in the db every 2-seconds instead of every transaction.

I don’t see why these changes are necessary for this use cases. I think you could track hits/misses outside the cache already and update a different key (or cache) with the information asynchronously. Leveraging the cache’s Settings metadata seems like a mistake.

grantjenks avatar Mar 04 '24 16:03 grantjenks

I don’t see why these changes are necessary for this use cases.

The first use case is even the default implementation to not be transactional (less locking when having statistics and reading from external files).

The other idea is I'd have to add another approach (can't reuse self.statistics, have to check the returned value in get() and compare it against default, etc).

ddorian avatar Mar 04 '24 19:03 ddorian