django默认的缓存数据库是Memory
Memory
from django.core.cache import cache # 设置缓存 缓存的key value 过期时间 cache.set(f"sms_{mobile}", code, settings.SMS_EXP) # 获取缓存 根据缓存的key来获取 cache.get('sms_%s' % mobile)