GitHub:https://github.com/chibisov/drf-extensions

官方文档:http://chibisov.github.io/drf-extensions/docs/

安装

pip install drf-extensions

 

cache用法

1、使用

from myapps.serializers import UserSerializer
from rest_framework_extensions.cache.mixins import CacheResponseMixin

class UserViewSet(CacheResponseMixin, viewsets.ModelViewSet):
    serializer_class = UserSerializer

2、设置过期时间,配置在settings.py

REST_FRAMEWORK_EXTENSIONS = {
    'DEFAULT_CACHE_RESPONSE_TIMEOUT': 5
}

 

相关文章:

  • 2021-06-05
  • 2021-10-22
猜你喜欢
  • 2022-02-21
  • 2022-12-23
  • 2021-09-21
  • 2022-01-26
  • 2021-10-23
相关资源
相似解决方案