1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Remove cacheops workarounds & queryset caching metrics

This commit is contained in:
jeremystretch
2021-07-07 17:15:42 -04:00
parent f683f0786e
commit b6ec1d9aa7
4 changed files with 1 additions and 31 deletions

View File

@ -6,6 +6,7 @@
* The default CSV export format for all objects now includes all available data. Additionally, the CSV headers now use human-friendly titles rather than the raw field names. * The default CSV export format for all objects now includes all available data. Additionally, the CSV headers now use human-friendly titles rather than the raw field names.
* Support for queryset caching configuration (`caching_config`) has been removed from the plugins API (see [#6639](https://github.com/netbox-community/netbox/issues/6639)). * Support for queryset caching configuration (`caching_config`) has been removed from the plugins API (see [#6639](https://github.com/netbox-community/netbox/issues/6639)).
* The `cacheops_*` metrics have been removed from the Prometheus exporter (see [#6639](https://github.com/netbox-community/netbox/issues/6639)).
### New Features ### New Features

View File

@ -1,6 +1,5 @@
import logging import logging
from cacheops import invalidate_obj
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db.models.signals import post_save, post_delete, pre_delete from django.db.models.signals import post_save, post_delete, pre_delete
from django.db import transaction from django.db import transaction
@ -33,7 +32,6 @@ def rebuild_paths(obj):
for cp in cable_paths: for cp in cable_paths:
cp.delete() cp.delete()
if cp.origin: if cp.origin:
invalidate_obj(cp.origin)
create_cablepath(cp.origin) create_cablepath(cp.origin)

View File

@ -1,4 +1,3 @@
from cacheops import invalidate_model
from django.apps import apps from django.apps import apps
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
@ -108,8 +107,5 @@ class Command(BaseCommand):
elif options['verbosity']: elif options['verbosity']:
self.stdout.write(self.style.SUCCESS(str(count))) self.stdout.write(self.style.SUCCESS(str(count)))
# Invalidate cached queries
invalidate_model(model)
if options['verbosity']: if options['verbosity']:
self.stdout.write(self.style.SUCCESS("Done.")) self.stdout.write(self.style.SUCCESS("Done."))

View File

@ -1,4 +1,3 @@
from cacheops.signals import cache_invalidated, cache_read
from django.conf import settings from django.conf import settings
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db.models.signals import m2m_changed, post_save, pre_delete from django.db.models.signals import m2m_changed, post_save, pre_delete
@ -138,27 +137,3 @@ def run_custom_validators(sender, instance, **kwargs):
validators = settings.CUSTOM_VALIDATORS.get(model_name, []) validators = settings.CUSTOM_VALIDATORS.get(model_name, [])
for validator in validators: for validator in validators:
validator(instance) validator(instance)
#
# 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)