一、首页轮播图加入缓存 如果不加缓存,每次用户访问首页,都去查一次数据库,对数据库压力大。 第一次访问查数据库,拿到数据,放到缓存(redis),以后再访问,直接从redis中能够获取。 apps/home/view.py from django.core.cache import cache from rest_framework.generics import ListAPIView from rest_framework.response import Response from rest_framework.viewsets