mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
35 lines
798 B
Python
35 lines
798 B
Python
from cacheops.signals import cache_invalidated, cache_read
|
|
from django.dispatch import Signal
|
|
from prometheus_client import Counter
|
|
|
|
|
|
#
|
|
# Caching
|
|
#
|
|
|
|
cacheops_cache_hit = Counter('cacheops_cache_hit', 'Number of cache hits')
|
|
cacheops_cache_miss = Counter('cacheops_cache_miss', 'Number of cache misses')
|
|
cacheops_cache_invalidated = Counter('cacheops_cache_invalidated', 'Number of cache invalidations')
|
|
|
|
|
|
def cache_read_collector(sender, func, hit, **kwargs):
|
|
if hit:
|
|
cacheops_cache_hit.inc()
|
|
else:
|
|
cacheops_cache_miss.inc()
|
|
|
|
|
|
def cache_invalidated_collector(sender, obj_dict, **kwargs):
|
|
cacheops_cache_invalidated.inc()
|
|
|
|
|
|
cache_read.connect(cache_read_collector)
|
|
cache_invalidated.connect(cache_invalidated_collector)
|
|
|
|
|
|
#
|
|
# Change logging
|
|
#
|
|
|
|
purge_changelog = Signal()
|