mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Drop caching_config from plugin configuration
This commit is contained in:
@ -113,7 +113,6 @@ NetBox looks for the `config` variable within a plugin's `__init__.py` to load i
|
||||
| `min_version` | Minimum version of NetBox with which the plugin is compatible |
|
||||
| `max_version` | Maximum version of NetBox with which the plugin is compatible |
|
||||
| `middleware` | A list of middleware classes to append after NetBox's build-in middleware |
|
||||
| `caching_config` | Plugin-specific cache configuration
|
||||
| `template_extensions` | The dotted path to the list of template extension classes (default: `template_content.template_extensions`) |
|
||||
| `menu_items` | The dotted path to the list of menu items provided by the plugin (default: `navigation.menu_items`) |
|
||||
|
||||
@ -385,31 +384,3 @@ class SiteAnimalCount(PluginTemplateExtension):
|
||||
|
||||
template_extensions = [SiteAnimalCount]
|
||||
```
|
||||
|
||||
## Caching Configuration
|
||||
|
||||
By default, all query operations within a plugin are cached. To change this, define a caching configuration under the PluginConfig class' `caching_config` attribute. All configuration keys will be applied within the context of the plugin; there is no need to include the plugin name. An example configuration is below:
|
||||
|
||||
```python
|
||||
class MyPluginConfig(PluginConfig):
|
||||
...
|
||||
caching_config = {
|
||||
'foo': {
|
||||
'ops': 'get',
|
||||
'timeout': 60 * 15,
|
||||
},
|
||||
'*': {
|
||||
'ops': 'all',
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To disable caching for your plugin entirely, set:
|
||||
|
||||
```python
|
||||
caching_config = {
|
||||
'*': None
|
||||
}
|
||||
```
|
||||
|
||||
See the [django-cacheops](https://github.com/Suor/django-cacheops) documentation for more detail on configuring caching.
|
||||
|
@ -5,6 +5,7 @@
|
||||
### Breaking Changes
|
||||
|
||||
* 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)).
|
||||
|
||||
### New Features
|
||||
|
||||
@ -64,6 +65,7 @@ CustomValidator can also be subclassed to enforce more complex logic by overridi
|
||||
* [#5994](https://github.com/netbox-community/netbox/issues/5994) - Drop support for `display_field` argument on ObjectVar
|
||||
* [#6068](https://github.com/netbox-community/netbox/issues/6068) - Drop support for legacy static CSV export
|
||||
* [#6338](https://github.com/netbox-community/netbox/issues/6338) - Decimal fields are no longer coerced to strings in REST API
|
||||
* [#6639](https://github.com/netbox-community/netbox/issues/6639) - Drop support for queryset caching (django-cacheops)
|
||||
|
||||
### REST API Changes
|
||||
|
||||
|
@ -47,11 +47,6 @@ class PluginConfig(AppConfig):
|
||||
# Middleware classes provided by the plugin
|
||||
middleware = []
|
||||
|
||||
# Cacheops configuration. Cache all operations by default.
|
||||
caching_config = {
|
||||
'*': {'ops': 'all'},
|
||||
}
|
||||
|
||||
# Default integration paths. Plugin authors can override these to customize the paths to
|
||||
# integrated components.
|
||||
template_extensions = 'template_content.template_extensions'
|
||||
|
@ -80,12 +80,6 @@ class PluginTest(TestCase):
|
||||
"""
|
||||
self.assertIn('extras.tests.dummy_plugin.middleware.DummyMiddleware', settings.MIDDLEWARE)
|
||||
|
||||
def test_caching_config(self):
|
||||
"""
|
||||
Check that plugin caching configuration is registered.
|
||||
"""
|
||||
self.assertIn('extras.tests.dummy_plugin.*', settings.CACHEOPS)
|
||||
|
||||
def test_min_version(self):
|
||||
"""
|
||||
Check enforcement of minimum NetBox version.
|
||||
|
@ -632,12 +632,3 @@ for plugin_name in PLUGINS:
|
||||
plugin_middleware = plugin_config.middleware
|
||||
if plugin_middleware and type(plugin_middleware) in (list, tuple):
|
||||
MIDDLEWARE.extend(plugin_middleware)
|
||||
|
||||
# Apply cacheops config
|
||||
if type(plugin_config.caching_config) is not dict:
|
||||
raise ImproperlyConfigured(
|
||||
"Plugin {} caching_config must be a dictionary.".format(plugin_name)
|
||||
)
|
||||
CACHEOPS.update({
|
||||
"{}.{}".format(plugin_name, key): value for key, value in plugin_config.caching_config.items()
|
||||
})
|
||||
|
Reference in New Issue
Block a user