Python Web Shopping cart ideas simple version

Source: Internet
Author: User

The shopping cart is notoriously troublesome (I don't like to write anyway) .... But it's important.

1 using the DRF framework

2 relational database Select MySQL

3 Non-relational database select Redis

Let's think about permission validation first.

Non-logged-on users can store shopping carts

Login users can also store shopping cart

Users can also change the shopping cart additions and deletions (regardless of login and non-login)

Check the items to be settled at checkout

Merge shopping Cart when user logs in

Login user status Keep using cookies for jwt& non-logged on users

How to tell the difference, but it's a question where the cart stores the information.

Well-known relational database performance is really rotten home.

Relational database accesses more than 1100 times per second & Philippine relational database such as Redis can reach more than 11W

So optimization is important, or you run the program, and if the number of accesses is very large, the server crashes easily.

>>> Shopping Cart Data >>redis

Not logged in user shopping cart data storage to cookie& login user directly to Redis

Technical Direction Login User store Two 1 item information in Redis, save a sku_id and count (because the settlement is needed) storage type >> Hash

If you don't think of one, it's best to try it out.

Xxxx{}.format (user_id) ={xxx:10,xxxxx:20} Hashigen is the right place to make a shopping cart

The Redis also stores a check-in function.

It is convenient to use set type because of automatic weight

Of course, if the pursuit of a perfect list can not be too big for you to Lrem and then store also use Lpush can also ascending

It's very tempting to think about it.

Of course, the operation of the item information and check the time!! Be sure to work together!!!!!!!!!

User operation without login shopping cart

Using JSON to store is very convenient!!! SKU and check can be placed in a dictionary

But to be reasonable, you need to add a secret.

Base64 and Pickle standard modules

Finally talking about the merger shopping cart

Some people are going to be confused about how to tell me who I am and where I am.

It's very simple. You have a cookie on your computer and then you log in and the user and cookie don't merge?

Why do you play Overwatch ah pubg ah furnace stone ah buddy relationship Good many people play very normal.

You don't share a shopping software, do you? Of course, you have to say a software login two accounts

You're giving him a choice. Do you want to merge the shopping cart

Of course, it's just the basic design.

Python Web Shopping cart ideas simple version

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.