зеркало из https://github.com/mozilla/treeherder.git
use ``cacheResponseAndETAG`` instead of just cache
This commit is contained in:
Родитель
3432fc2644
Коммит
910f3b8e29
|
@ -36,12 +36,6 @@ To add a new repository, the following steps are needed:
|
|||
|
||||
> python manage.py init_datasources
|
||||
|
||||
* Restart memcached to clean any previously cached datasource
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
> sudo /etc/init.d/memcached restart
|
||||
|
||||
* Generate a new oauth credentials file:
|
||||
|
||||
.. code-block:: bash
|
||||
|
|
|
@ -19,10 +19,13 @@ from warnings import filterwarnings, resetwarnings
|
|||
from jsonfield import JSONField
|
||||
|
||||
from treeherder import path
|
||||
from treeherder.webapp.api import refdata
|
||||
|
||||
|
||||
# the cache key is specific to the database name we're pulling the data from
|
||||
SOURCES_CACHE_KEY = "treeherder-datasources"
|
||||
REPOSITORY_LIST_CACHE_KEY = 'treeherder-repositories'
|
||||
FAILURE_CLASSIFICAION_LIST_CACHE_KEY = 'treeherder-failure-classifications'
|
||||
|
||||
SQL_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sql')
|
||||
|
||||
|
@ -211,6 +214,7 @@ class Datasource(models.Model):
|
|||
@classmethod
|
||||
def reset_cache(cls):
|
||||
cache.delete(SOURCES_CACHE_KEY)
|
||||
cache.delete(REPOSITORY_LIST_CACHE_KEY)
|
||||
cls.objects.cached()
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -312,3 +312,7 @@ def obtain_username(email):
|
|||
BROWSERID_USERNAME_ALGO = obtain_username
|
||||
|
||||
SWAGGER_SETTINGS = {"enabled_methods": ['get',]}
|
||||
|
||||
REST_FRAMEWORK_EXTENSIONS = {
|
||||
'DEFAULT_CACHE_RESPONSE_TIMEOUT': 60 * 15
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from rest_framework import viewsets
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.authentication import SessionAuthentication
|
||||
from rest_framework_extensions.cache.mixins import CacheResponseMixin
|
||||
from rest_framework_extensions.mixins import CacheResponseAndETAGMixin
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
@ -35,12 +35,15 @@ class JobGroupViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
model = models.JobGroup
|
||||
|
||||
|
||||
class RepositoryViewSet(CacheResponseMixin,
|
||||
class RepositoryViewSet(CacheResponseAndETAGMixin,
|
||||
viewsets.ReadOnlyModelViewSet):
|
||||
"""ViewSet for the refdata Repository model"""
|
||||
model = models.Repository
|
||||
serializer_class = th_serializers.RepositorySerializer
|
||||
|
||||
def list_cache_key_func(self, **kwargs):
|
||||
return models.REPOSITORY_LIST_CACHE_KEY
|
||||
|
||||
|
||||
class MachinePlatformViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
"""ViewSet for the refdata MachinePlatform model"""
|
||||
|
@ -93,11 +96,13 @@ class JobTypeViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
model = models.JobType
|
||||
|
||||
|
||||
class FailureClassificationViewSet(CacheResponseMixin,
|
||||
class FailureClassificationViewSet(CacheResponseAndETAGMixin,
|
||||
viewsets.ReadOnlyModelViewSet):
|
||||
"""ViewSet for the refdata FailureClassification model"""
|
||||
model = models.FailureClassification
|
||||
|
||||
def list_cache_key_func(self, **kwargs):
|
||||
return models.FAILURE_CLASSIFICAION_LIST_CACHE_KEY
|
||||
|
||||
#############################
|
||||
# User and exclusion profiles
|
||||
|
|
Загрузка…
Ссылка в новой задаче