fix: return cached responses from idempotent decorator

This commit is contained in:
caoqianming 2026-03-19 21:58:30 +08:00
parent fcfe76bb6d
commit f17d9aec5b
1 changed files with 2 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import hashlib
import json
from django.core.cache import cache
from rest_framework.exceptions import ParseError
from rest_framework.response import Response
myLogger = logging.getLogger('log')
@ -48,6 +49,6 @@ def idempotent(seconds=4):
return real_func
elif hash_v_e == 'o': # 说明请求正在处理
raise ParseError(f'请求忽略,请{seconds}秒后重试')
return hash_v_e
return Response(hash_v_e)
return wrapper
return decorate