秒杀系统 mysql_秒杀系统-介绍
秒殺系統
秒殺系統其實是針對庫存做的系統。用戶成功秒殺商品,對于我們系統的操作就是減庫存和記錄用戶的購買明細。用戶的購買明細包括記錄誰購買成功、購買成功的時間和付款信息。而對于減庫存操作,需要考慮到以下兩個問題:
(1)若是用戶成功秒殺商品,我們記錄了其購買明細,卻沒有減庫存。會導致商品的超賣。
(2)減了庫存卻沒有記錄用戶的購買明細,導致商品的少賣。
對于上述兩個問題,可以通過MySQL內置的事務機制進行處理,它可以準確的幫我們完成減庫存和記錄用戶購買明細的過程。
對于秒殺系統,我們只是實現秒殺的一些功能:
(1)秒殺接口的暴露。
(2)執行秒殺的操作。
(3)相關查詢,比如說列表查詢,詳情頁查詢。
秒殺系統包括包括三個模塊的設計,DAO層、Service層和Web層的設計,另外考慮到系統高并發的問題,從而設計了系統高并發的處理。在系統設計之前,為了更好地理解系統的開發過程,對相關技術進行描述。
6.3.1 相關技術介紹
MySQL:
創建相關表、事務的應用和行級鎖。
DAO:
數據訪問對象基本上是一個對象或接口,它提供對基礎數據庫或任何其他持久存儲的訪問。
MyBatis:
MyBATIS是支持自定義SQL、存儲過程和高級映射的第一類持久性框架。MybATIS消除了幾乎所有的JDBC代碼和手動設置參數和檢索結果。MyBatis可以使用簡單的XML或注釋的配置和地圖圖元,地圖接口和java POJO(Plain Old java對象)到數據庫的記錄。
SLF4J:
java的簡單日志門面(是slf4j)作為一個簡單的立面或抽象的各種日志框架(例如java.util.logging,logback,log4j)允許用戶插入所需的部署時間日志框架。
登錄項目
Logback:
回溯的目的是作為流行的Log4J項目的繼承者,拿起Log4J離開的地方。
日志回退的架構足夠通用,以便在不同的情況下應用。目前,回溯被分為三個模塊:回溯核心、回溯經典和回溯訪問。
回溯核心模塊為其他兩個模塊奠定基礎。LogLogic經典模塊可以被同化到Log4J的一個顯著改進的版本中。此外,回溯經典本身實現了SLF4J API,這樣您就可以輕松地在回溯和其他日志記錄框架之間來回切換,例如Log4J或JavaUTIL日志(JUL)。
回溯訪問模塊與Servlet容器(如Tomcat和JETTY)集成,提供HTTP訪問日志功能。注意,您可以輕松地在LogCub核心之上構建自己的模塊。
C3P0:
C3P0是一個易于使用的庫,通過使用JDBC3規范定義的功能和JDBC2的可選擴展來增強傳統JDBC驅動程序“企業就緒”。
Spring framework:
Spring框架是java平臺的一個應用框架和反轉控制容器。該框架的核心功能,可以在任何java應用程序使用,但也有在頂部的java EE平臺構建Web應用的擴展。
Spring MVC框架:
Spring WebMVC框架提供了模型視圖控制器(MVC)體系結構和準備好的組件,這些組件可以用來開發靈活和松散耦合的Web應用程序。MVC模式導致分離應用程序的不同方面(輸入邏輯、業務邏輯和UI邏輯),同時在這些元素之間提供松散耦合。
該模型封裝應用程序數據,一般來說,它們將由POJO組成。
視圖負責渲染模型數據,一般來說,它生成客戶端瀏覽器可以解釋的HTML輸出。
控制器負責處理用戶請求并建立適當的模型并將其傳遞給視圖進行渲染。
taglib:
TAGLIB指令聲明您的JSP頁面使用一組自定義標記,標識庫的位置,并提供一種標識JSP頁面中自定義標記的方法。
JSTL:
JavaServer頁面標準標簽庫(JSTL)是一個有用的JSP標簽集合,它封裝了許多JSP應用程序共同的核心功能。JSTL支持常見的結構化任務,如迭代和條件語句、用于操縱XML文檔的標記、國際化標記和SQL標記。
protostuff:
具有支持后向兼容性(模式演進)和驗證的內置支持的序列化庫。
MySQL:
Create related tables,the applications of transaction and row-level lock.
DAO:
The Data Access Object is basically an object or an interface that provides access to an underlying database or any other persistence storage.
MyBatis:
MyBatis is a first class persistence framework with support for custom SQL, stored procedures and advanced mappings.?MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results. MyBatis can use simple XML or Annotations for configuration and map primitives, Map interfaces and Java POJOs (Plain Old Java Objects) to database records.
SLF4J:
The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at?deployment?time.
Logback Project
Logback:
Logback is intended as a successor to the popular log4j project, picking up where log4j leaves off.
Logback's architecture is sufficiently generic so as to apply under different circumstances. At present time, logback is divided into three modules, logback-core, logback-classic and logback-access.
The logback-core module lays the groundwork for the other two modules. The logback-classic module can be assimilated to a significantly improved version of log4j. Moreover, logback-classic natively implements the SLF4J API so that you can readily switch back and forth between logback and other logging frameworks such as log4j or java.util.logging (JUL).
The logback-access module integrates with Servlet containers, such as Tomcat and Jetty, to provide HTTP-access log functionality. Note that you could easily build your own module on top of logback-core.
c3p0:
c3p0 is an easy-to-use library for making traditional JDBC drivers "enterprise-ready" by augmenting them with functionality defined by the jdbc3 spec and the optional extensions to jdbc2.
Spring framework:
The?Spring Framework?is an application?frameworkand inversion of control container for the Java platform. The?framework's?core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform.
Spring - MVC Framework:
The Spring Web MVC framework provides Model-View-Controller (MVC) architecture and ready components that can be used to develop flexible and loosely coupled web applications. The MVC pattern results in separating the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements.
The?Model?encapsulates the application data and in general they will consist of POJO.
The?View?is responsible for rendering the model data and in general it generates HTML output that the client's browser can interpret.
The?Controller?is responsible for processing user requests and building an appropriate model and passes it to the view for rendering.
taglib:
The taglib directive declares that your JSP page uses a set of custom tags, identifies the location of the library, and provides a means for identifying the custom tags in your JSP page.
JSTL:
The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates the core functionality common to many JSP applications.?JSTL?has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags.
protostuff:
A serialization library with built-in support for forward-backward compatibility (schema evolution) and validation.
總結
以上是生活随笔為你收集整理的秒杀系统 mysql_秒杀系统-介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: w ndows7安不上HP1020,惠普
- 下一篇: 场景编辑器开发第五天,设计架构重回fla