mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +03:00
Add THROTTLE_CACHE_ALIAS
option to choose throttle cache.
This commit is contained in:
parent
ea6eee304c
commit
b8a2d6c9d8
|
@ -70,6 +70,12 @@ Or, if you're using the `@api_view` decorator with function based views.
|
|||
|
||||
The throttle classes provided by REST framework use Django's cache backend. You should make sure that you've set appropriate [cache settings][cache-setting]. The default value of `LocMemCache` backend should be okay for simple setups. See Django's [cache documentation][cache-docs] for more details.
|
||||
|
||||
You could select the cache to use, using the `THROTTLE_CACHE_ALIAS` setting. For example.
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'THROTTLE_CACHE_ALIAS': 'default'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
# API Reference
|
||||
|
|
|
@ -43,6 +43,7 @@ You can determine your currently installed version using `pip freeze`:
|
|||
### Master
|
||||
|
||||
* Support customizable view name and description functions, using the `VIEW_NAME_FUNCTION` and `VIEW_DESCRIPTION_FUNCTION` settings.
|
||||
* Add `THROTTLE_CACHE_ALIAS` option to choose throttle cache.
|
||||
* Bugfix: `required=True` argument fixed for boolean serializer fields.
|
||||
* Bugfix: `client.force_authenticate(None)` should also clear session info if it exists.
|
||||
* Bugfix: Client sending emptry string instead of file now clears `FileField`.
|
||||
|
|
|
@ -108,6 +108,8 @@ DEFAULTS = {
|
|||
),
|
||||
'TIME_FORMAT': None,
|
||||
|
||||
'THROTTLE_CACHE_ALIAS': 'default',
|
||||
|
||||
# Pending deprecation
|
||||
'FILTER_BACKEND': None,
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
Provides various throttling policies.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.core.cache import cache
|
||||
from django.core.cache import get_cache
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from rest_framework.settings import api_settings
|
||||
import time
|
||||
|
||||
cache = get_cache(api_settings.THROTTLE_CACHE_ALIAS)
|
||||
|
||||
|
||||
class BaseThrottle(object):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user