mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Implemented redis caching for GET only viewsets
This commit is contained in:
parent
0215680ea5
commit
66fdc16524
4 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
from django.views.decorators.cache import cache_page
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
from rest_framework.permissions import IsAuthenticated
|
from rest_framework.permissions import IsAuthenticated
|
||||||
from .serializers import LandmarkSerializer
|
from .serializers import LandmarkSerializer
|
||||||
|
@ -8,3 +10,7 @@ class LandmarkListView(generics.ListAPIView):
|
||||||
serializer_class = LandmarkSerializer
|
serializer_class = LandmarkSerializer
|
||||||
# permission_classes = [IsAuthenticated]
|
# permission_classes = [IsAuthenticated]
|
||||||
queryset = Landmark.objects.all()
|
queryset = Landmark.objects.all()
|
||||||
|
|
||||||
|
@method_decorator(cache_page(60*60))
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
from django.views.decorators.cache import cache_page
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
from .models import Semester
|
from .models import Semester
|
||||||
from .serializers import SemesterSerializer
|
from .serializers import SemesterSerializer
|
||||||
|
@ -6,3 +8,7 @@ from .serializers import SemesterSerializer
|
||||||
class SemesterListView(generics.ListAPIView):
|
class SemesterListView(generics.ListAPIView):
|
||||||
serializer_class = SemesterSerializer
|
serializer_class = SemesterSerializer
|
||||||
queryset = Semester.objects.all()
|
queryset = Semester.objects.all()
|
||||||
|
|
||||||
|
@method_decorator(cache_page(60*60))
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
from django.views.decorators.cache import cache_page
|
||||||
from rest_framework import generics, viewsets
|
from rest_framework import generics, viewsets
|
||||||
from .models import Subject, SubjectInstance
|
from .models import Subject, SubjectInstance
|
||||||
from .serializers import SubjectInstanceSerializer
|
from .serializers import SubjectInstanceSerializer
|
||||||
|
@ -10,6 +12,10 @@ class SubjectListAllView(generics.ListAPIView):
|
||||||
serializer_class = SubjectInstanceSerializer
|
serializer_class = SubjectInstanceSerializer
|
||||||
queryset = SubjectInstance.objects.all()
|
queryset = SubjectInstance.objects.all()
|
||||||
|
|
||||||
|
@method_decorator(cache_page(60*60))
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SubjectListView(generics.ListAPIView):
|
class SubjectListView(generics.ListAPIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
from django.views.decorators.cache import cache_page
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
from .models import Year_Level
|
from .models import Year_Level
|
||||||
from .serializers import YearLevelSerializer
|
from .serializers import YearLevelSerializer
|
||||||
|
@ -6,3 +8,7 @@ from .serializers import YearLevelSerializer
|
||||||
class CourseListView(generics.ListAPIView):
|
class CourseListView(generics.ListAPIView):
|
||||||
serializer_class = YearLevelSerializer
|
serializer_class = YearLevelSerializer
|
||||||
queryset = Year_Level.objects.all()
|
queryset = Year_Level.objects.all()
|
||||||
|
|
||||||
|
@method_decorator(cache_page(60*60))
|
||||||
|
def dispatch(self, *args, **kwargs):
|
||||||
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue