4.关于redis缓存购物车及结算中心-其他配置篇

Posted guishuzhe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了4.关于redis缓存购物车及结算中心-其他配置篇相关的知识,希望对你有一定的参考价值。

api/urls.py

from django.conf.urls import url
from api.views import shoppingcar, payment, order

urlpatterns = [
url(r‘^shoppingcar/$‘, shoppingcar.ShoppingCarViewSet.as_view()),
url(r‘^payment/$‘, payment.PayMentViewSet.as_view()),
url(r‘^order/$‘, order.OrderViewset.as_view()),
]

mysite/urls.py
from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
url(r‘^admin/‘, admin.site.urls),
url(r‘^api/(?P<version>w+)/‘, include("api.urls")),
]

settings.py
REST_FRAMEWORK = {
‘DEFAULT_VERSIONING_CLASS‘: ‘rest_framework.versioning.URLPathVersioning‘,
‘ALLOWED_VERSIONS‘: [‘v1‘, ‘v2‘], # 允许的版本

}
# redis设置
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"CONNECTION_POOL_KWARGS": {"max_connections": 100},
"PASSWORD": "123456",
}
}
}

# 购物车相关设置
SHOPPING_CAR_KEY = "shopping_car_%s_%s"
PAYMENT_KEY = "payment_%s_%s"
PAYMENT_COUPON_KEY = "payment_coupon_%s"

utils/response.py
class BaseResponse(object):

def __init__(self):
self.code = 1000
self.data = None
self.error = None

@property
def dict(self):
return self.__dict__

















































以上是关于4.关于redis缓存购物车及结算中心-其他配置篇的主要内容,如果未能解决你的问题,请参考以下文章

购物车与结算接口

购物车结算及商品详情

广告业务系统 之 数据桥梁 —— “日志中心-曝光数据流转结算”

jquery-防多店铺购物车结算全选,单选,及删除,价格计算

电商订单的操作

购物结算系统