javascript - 京东上的购物车问题
京东上的购物车是放在SESSION里的,他那个SESSION存放在时间是比较长的,长达几个月,如果有10万人的购物车里有信息,那么京东服务器上的SESSION目录的SESSION信息文件岂不是很多??他们会不会根据用户ID来划分目录,避免某个目录下的文件过多呢??
回复内容:
京东上的购物车是放在SESSION里的,他那个SESSION存放在时间是比较长的,长达几个月,如果有10万人的购物车里有信息,那么京东服务器上的SESSION目录的SESSION信息文件岂不是很多??他们会不会根据用户ID来划分目录,避免某个目录下的文件过多呢??
PHP Session 存储方式为临时文件,这只是默认的。
事实上绝大多数初具规模的站点都修改了存储方式,原因就是你讲到的避免出现令人意外的系统开销。Session 文件过万之后,会对系统造成负担,首先表现就是 web server 负荷增高,硬盘 io 增大,直至停止响应。可以用数据库、内存表、缓存随便什么,资料许多你自己找吧。
电商网站(京东和淘宝是这样)的购物车,未登录状态关联的是你的 session(用客户端 cookie 识别你),登陆后立刻移至你的账号下,这里不是 $session['product'] = []; 这么简单,还做了挺多针对用户的处理。而且鉴于运营需要,别说是几个月,可能是过去几年你加入购物车的、你浏览过的都在他们的日志系统里,只不过不给你看,转化成数据帮它们做决策了。
开发app、除了静态文件,最好不要涉及到文件存储,慢,事多。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

Java's platform independence means that the code written can run on any platform with JVM installed without modification. 1) Java source code is compiled into bytecode, 2) Bytecode is interpreted and executed by the JVM, 3) The JVM provides memory management and garbage collection functions to ensure that the program runs on different operating systems.

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Composer is a dependency management tool for PHP, and manages project dependencies through composer.json file. 1) parse composer.json to obtain dependency information; 2) parse dependencies to form a dependency tree; 3) download and install dependencies from Packagist to the vendor directory; 4) generate composer.lock file to lock the dependency version to ensure team consistency and project maintainability.

Reasons for writing platform-specific code in Java include access to specific operating system features, interacting with specific hardware, and optimizing performance. 1) Use JNA or JNI to access the Windows registry; 2) Interact with Linux-specific hardware drivers through JNI; 3) Use Metal to optimize gaming performance on macOS through JNI. Nevertheless, writing platform-specific code can affect the portability of the code, increase complexity, and potentially pose performance overhead and security risks.
