-
Notifications
You must be signed in to change notification settings - Fork 47
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
Hit ratio statistics #210
Comments
I would implement this by intercepting calls to the backend, which you can do using ProxyBackend. we can add examples to https://dogpilecache.sqlalchemy.org/en/latest/recipes.html if someone wants to come up with this. |
Upvote for adding a metrics collection example to the recipes page :) |
FWIW, I open sourced a Pyramid plugin to do this a few years ago, which illustrates how to accomplish this. The package offers a |
If you are using Redis as backend, you should override from dogpile.cache import make_region
from dogpile.cache.proxy import ProxyBackend
from dogpile.cache.api import NO_VALUE
class ReportingProxy(ProxyBackend):
def set_serialized(self, key, value):
# report cache miss
self.proxied.set_serialized(key, value)
def get_serialized(self, key):
cached = self.proxied.get_serialized(key)
if cached != NO_VALUE:
# report cache hit
pass
return cached
region = make_region().configure(
'dogpile.cache.redis',
arguments={
'url': 'redis://localhost:6379/0', # Redis connection URL
'distributed_lock': True, # Use distributed lock to prevent dogpiling
'thread_local_lock': False,
},
wrap=[ReportingProxy],
) |
Hi guys
In order to monitor and improve my app, i need to know number of calls and cache hit ratio per key in certain intervals. is it possible with dogpile?
The text was updated successfully, but these errors were encountered: