Digital asset high-concurrency purchase method and system based on multi-level cache pre-deduction
By employing a multi-level caching pre-deduction method and order locking records, the accuracy and consistency issues of digital asset allocation in high-concurrency flash sales were resolved, enabling precise allocation and rapid rollback of digital assets, and improving the system's self-recovery capability and consistency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HORGOS LIANJIANG TECHNOLOGY CO LTD
- Filing Date
- 2026-01-14
- Publication Date
- 2026-06-09
AI Technical Summary
In high-concurrency flash sale scenarios, existing technologies struggle to accurately and efficiently allocate unique and limited digital assets. Furthermore, the lack of lightweight and explicit intermediate state records during asynchronous processing complicates inventory rollback operations, making it difficult to guarantee consistency and timeliness.
A multi-level caching pre-deduction method is adopted, which stores a list of digital asset identifiers through a set data structure in a distributed cache, performs pre-deduction of inventory, creates order lock records in the cache, automatically rolls back inventory when asynchronous processing fails, and uses message queues and atomic operations to ensure consistency.
It enables precise allocation and rapid rollback of digital assets, simplifies distributed transaction processing, and enhances the system's self-recovery capability and consistency guarantee in abnormal situations.
Smart Images

Figure CN122173500A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital asset trading technology, specifically to a method and system for high-concurrency flash sales of digital assets based on multi-level caching and pre-deduction. Background Technology
[0002] In current high-concurrency digital asset flash sale scenarios, the core challenge of the system lies in how to accurately and efficiently allocate unique and limited specific digital assets to successful users under high traffic surges, while ensuring data consistency. Existing common high-concurrency inventory deduction solutions typically maintain an atomic counter representing the total number of items in a distributed cache. When a purchase request arrives, the inventory quantity is deducted through an atomic decrement operation, and an order is asynchronously created after a successful deduction.
[0003] This type of total quantity deduction scheme has flaws when dealing with digital assets that have unique identifiers. Digital asset inventory is not a homogeneous quantity concept, but rather a collection of asset entities with unique identifiers. Simply deducting the total quantity cannot determine which specific asset identifier is assigned to a user, nor can it accurately return previously deducted but unassigned asset identifiers to the available inventory in case of subsequent processing failures. Furthermore, in the asynchronous processing between cache deduction and database order placement, if a failure occurs, conventional techniques lack a lightweight and explicit intermediate state record, making rollback operations complex and often requiring additional periodic scanning and compensation logic to restore inventory, making consistency and timeliness difficult to guarantee. Summary of the Invention
[0004] The purpose of this invention is to provide a high-concurrency method and system for pre-deducting digital assets based on multi-level caching, so as to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, the present invention provides a high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction, the system comprising: The request receiving verification module receives a purchase request sent by a user for a target digital asset, wherein the purchase request carries a user identity identifier; The inventory pre-deduction module verifies the user's identity based on a preset first-level cache, and after the verification is successful, performs an inventory pre-deduction operation based on the digital asset inventory pool stored in the distributed cache. The digital asset inventory pool uses a set data structure to store a list of sellable digital asset identifiers. The order locking module creates an order locking record for the user identity in the distributed cache based on the digital asset identifier being deducted when the inventory pre-deduction operation is successful. The asynchronous order placement and rollback module, based on a message queue, asynchronously processes the order lock records, generates persistent order data, and completes the final binding of digital assets with users. If any step in the asynchronous processing fails, an automatic inventory rollback operation is performed based on the digital asset identifier recorded in the order lock record, and the corresponding digital asset identifier is added back to the digital asset inventory pool in the distributed cache.
[0006] Preferably, based on a preset first-level cache, the user identity identifier is used for qualification verification, including: Extract the purchase activity identifier of the target digital asset from the purchase request; Based on the flash sale activity identifier, the flash sale activity configuration information of the target digital asset is obtained from the first-level cache. The flash sale activity configuration information includes the activity status, the activity time range, and the user qualification verification rules. Determine whether the current time is within the activity time range and whether the activity status is an available state; If the current time is within the activity time range and the activity is in an eligible state, then according to the user qualification verification rules, query the verification information corresponding to the user identity in the first-level cache; Based on the retrieved verification information, it is determined whether the user's identity identifier meets the eligibility requirements for participation. If it does, the eligibility verification is passed.
[0007] Preferably, the user qualification verification rules include purchase restriction rules and blacklist / whitelist rules; According to the user qualification verification rules, query the verification information corresponding to the user identity identifier in the first-level cache, including: Based on the flash sale activity identifier, the purchase limit rules for the target digital asset are obtained from the first-level cache, and based on the user identity identifier, the number of the user's historical successful purchase records in the flash sale activity is queried to determine whether the number of historical successful purchase records is less than the maximum purchase quantity stipulated by the purchase limit rules. Based on the flash sale activity identifier, retrieve the blacklist and whitelist for the flash sale activity from the first-level cache, and determine whether the user identity identifier exists in the whitelist of the blacklist and whitelist or does not exist in the blacklist of the blacklist and whitelist. If the number of successful historical purchase records is less than the maximum purchase quantity, and the user's identity is either in the whitelist or not in the blacklist, then the user's identity is deemed to be eligible to participate.
[0008] Preferably, based on the digital asset inventory pool stored in the distributed cache, the inventory pre-deduction operation is performed, including: Based on the target digital asset information carried in the purchase request, determine the storage key of the corresponding digital asset inventory pool in the distributed cache; An atomic set pop instruction is sent to the distributed cache. The atomic set pop instruction acts on the list of digital asset identifiers corresponding to the storage key, and is used to randomly and atomically pop a digital asset identifier from the list of digital asset identifiers. If the distributed cache returns the instruction execution result, and the return result is successful and carries a specific digital asset identifier, then the inventory pre-deduction operation is determined to be successful, and the specific digital asset identifier is used as the digital asset identifier to be deducted.
[0009] Preferably, upon successful inventory pre-deduction operation, an order lock record is created in the distributed cache for the user identity based on the deducted digital asset identifier, including: Generate a globally unique temporary order identifier; In the distributed cache, an order lock record is stored using a key composed of the user identity identifier and the flash sale activity identifier, or using the temporary order identifier as the key. The order lock record at least includes the deducted digital asset identifier, the creation timestamp, and the order status, and the order status is marked as a pre-locked state.
[0010] Preferably, based on a message queue, the order lock records are processed asynchronously to generate persistent order data and complete the final binding of digital assets with the user, including: Read the order lock record from the distributed cache; Based on the information in the order lock record, perform order information integrity verification and secondary verification of business rules; After the secondary verification is passed, an order message containing user identity identifier, digital asset identifier, temporary order identifier, and order details is constructed; Send the order message to the specified message queue topic; Start an asynchronous message consumer service. The message consumer service listens to the specified message queue topic. When it consumes the order message, it performs a database transaction operation, writes the order data to the persistent order table in the database, changes the ownership status of the digital asset to belong to the user's identity, and updates the order status in the order lock record to the completed status.
[0011] Preferably, the user identity identifier, digital asset identifier, and creation timestamp contained in the order lock record are extracted from the distributed cache; Verify whether the format of the user identity identifier conforms to the preset specifications, and verify whether the digital asset identifier exists in the system-maintained list of valid digital asset identifier master data; Check whether the time difference between the creation timestamp and the current system time is less than the preset order lock validity period threshold; After verifying that the information in the order lock record is complete and valid, the user service is queried based on the user identity identifier to confirm that the user account is currently in normal status and has not been frozen. The asset service is queried based on the digital asset identifier to confirm that the digital asset is currently available for sale and is not locked to other incomplete orders. When a user's account is in a normal state and the digital assets are available for sale, the order information integrity verification and the secondary verification of business rules are deemed to have passed.
[0012] Preferably, if a failure occurs at any stage of the asynchronous processing, an automatic inventory rollback operation is performed based on the digital asset identifier recorded in the order lock record, including: During asynchronous processing, exceptions are captured in the order information integrity verification, business rule secondary verification, order message sending, and database transaction operation stages. When an anomaly is detected, the digital asset identifier that needs to be rolled back is determined based on the order lock records obtained before the anomaly occurred. An atomic set add instruction is sent to the distributed cache. The atomic set add instruction acts on the storage key corresponding to the digital asset inventory pool and adds the digital asset identifier that needs to be rolled back as an element back to the digital asset identifier list. After the atomic set addition instruction is successfully executed, the status of the corresponding order lock record in the distributed cache is cleared or updated to the rollback state.
[0013] Preferably, the first-level cache is a local memory cache or a configuration center cache, used to cache the flash sale activity configuration, user purchase limit rules, and blacklist / whitelist data; the distributed cache is a memory-based key-value storage database used to store the digital asset inventory pool and order lock records.
[0014] Preferably, the present invention also includes a method for high-concurrency flash sale of digital assets based on multi-level caching and pre-deduction, the method including all the modules and method flow of the high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described above.
[0015] Compared with the prior art, the beneficial effects of the present invention are: By employing a set data structure to store a list of sellable digital asset identifiers in a distributed cache, inventory management shifts from a numerical dimension to an entity identifier dimension. During inventory pre-deduction, a removal operation is directly performed on the set, which simultaneously reduces the quantity and allocates specific asset identifiers. This fundamentally eliminates the possibility of overselling, as each asset identifier exists only once in the set, and the removal operation is atomic. The system instantly knows the specific asset identifier allocated upon successful deduction, providing a precise data foundation for subsequent user binding and enabling accurate allocation of non-standard and unique assets.
[0016] After successful pre-deduction from the cache, an order lock record is created for the corresponding user in the same distributed cache. This record associates the user's identity with the specific digital asset identifier that has been deducted. This record serves as the single source of fact and state credential for the asynchronous order placement process. If any link in the subsequent asynchronous processing chain fails, the rollback mechanism can directly read the asset identifier stored in this lock record and, through a set addition operation, restore it to the available inventory pool. This makes the inventory rollback operation precise, automatic, and immediate, without the need for external compensation tasks. It simplifies a complex distributed transaction problem into a reversible process based on cache atomic operations and state records, improving the system's self-recovery capability and eventual consistency guarantee in abnormal situations. Attached Figure Description
[0017] Figure 1 This is a timing diagram of the high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in this invention; Figure 2 The flowchart for qualification verification; Figure 3 Flowchart for inventory pre-deduction operation; Figure 4 Line chart showing the pass rate of secondary verification for rules in digital asset flash sale business; Figure 5 Chart showing the execution metrics for atomic instructions to roll back inventory during digital asset acquisition. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Please see Figure 1This invention provides a high-concurrency digital asset pre-deduction system based on multi-level caching. The system includes: receiving a user's purchase request for a target digital asset carrying a user's identity identifier, which is processed by a request receiving and verification module. An inventory pre-deduction module verifies the user's identity identifier based on a preset first-level cache. After successful verification, the module accesses a digital asset inventory pool stored in a distributed cache to perform an inventory pre-deduction operation. This digital asset inventory pool uses a set data structure to store a list of sellable digital asset identifiers. When the pre-deduction operation successfully obtains a digital asset identifier, the order locking module immediately creates an order lock record in the distributed cache, using the user's identity identifier or an associated temporary order identifier as the key, containing information such as the deducted digital asset identifier. The asynchronous order placement and rollback module intervenes. This module processes the order lock record asynchronously based on a message queue. The process includes reading the record, performing business verification, generating an order message and delivering it to the message queue. The backend consumer service consumes the message and completes the persistent order placement and asset binding operations in the database. If any step in this asynchronous process fails, the module will perform an atomic add operation to the digital asset inventory pool in the distributed cache based on the digital asset identifier stored in the order lock record, thereby achieving automatic inventory rollback.
[0020] In one embodiment of the present invention, see [reference] Figure 2 The request receiving verification module extracts the flash sale activity identifier of the target digital asset from the flash sale request. Based on this identifier, it retrieves the corresponding flash sale activity configuration information from the first-level cache. The flash sale activity configuration information includes the activity status, activity time range, and user qualification verification rules. This module determines whether the current system time is within the activity time range and checks whether the activity status is "available for participation." If the current time is within the activity time range and the activity is "available for participation," it queries the first-level cache for verification information corresponding to the user's identity identifier according to the user qualification verification rules. The user qualification verification rules include purchase limit rules and blacklist / whitelist rules. According to the purchase limit rules, the system retrieves the purchase limit quantity for the flash sale activity from the first-level cache and queries the number of the user's historical successful purchase records in this activity to determine whether it is less than the purchase limit quantity. According to the blacklist / whitelist rules, the system retrieves the blacklist / whitelist data for the activity from the first-level cache and determines whether the user's identity identifier exists in the whitelist or does not appear in the blacklist. When the number of the user's historical successful purchase records does not reach the purchase limit limit and the user's identity identifier meets the requirements of the blacklist / whitelist rules, the system determines that the user's identity identifier has passed the qualification verification.
[0021] In practice, after receiving a user's purchase request carrying the user's identity identifier, the request receiving and verification module immediately extracts the purchase activity identifier of the target digital asset from the purchase request. This purchase activity identifier is crucial information that uniquely identifies a specific digital asset sale. Based on the purchase activity identifier, the request receiving and verification module retrieves the purchase activity configuration information of the target digital asset from the first-level cache. This configuration information is pre-loaded into the first-level cache by the system and includes the activity status, activity time range, and user eligibility verification rules. The request receiving and verification module then determines whether the current system time is within the activity time range and checks whether the activity status is "available for participation," such as whether the activity status is "in progress."
[0022] In some embodiments, if the current system time is within the activity period and the activity status is "available for participation," the request receiving verification module queries the first-level cache for verification information corresponding to the user's identity identifier, based on the user qualification verification rules. The user qualification verification rules include purchase limit rules and blacklist / whitelist rules. According to the purchase limit rules, the request receiving verification module retrieves the purchase limit rules for the target digital asset from the first-level cache. These rules specify the maximum quantity a user is allowed to successfully purchase in this flash sale. Based on the user's identity identifier, the request receiving verification module queries the number of historical successful purchase records for this flash sale. This number is also stored in the first-level cache and updated in real time. The request receiving verification module then determines whether the number of historical successful purchase records is less than the maximum purchase quantity specified by the purchase limit rules.
[0023] Understandably, according to the blacklist / whitelist rules, the request receiving verification module retrieves the blacklist / whitelist for the flash sale from the first-level cache. The blacklist / whitelist contains lists of user identities explicitly allowed to participate or explicitly prohibited from participating. The request receiving verification module determines whether the user identity exists in the whitelist of the blacklist / whitelist, or whether it does not exist in the blacklist of the blacklist / whitelist. When a user's historical successful purchase records are less than the maximum purchase quantity, and the user identity exists in the whitelist or does not exist in the blacklist, the request receiving verification module determines that the user identity is eligible to participate.
[0024] Optionally, the request receiving verification module can express the formal logic of the above verification process as the following formula. The calculation of the qualification verification pass result P depends on multiple Boolean conditions, and the formula is: Where: symbol This represents the truth value of the proposition "the current time is within the activity time range"; the symbol... Represents the truth value of the proposition "the activity state is an available state"; symbol This represents the number of a user's historical successful purchases, and is a non-negative integer; [symbol missing] The maximum purchase quantity stipulated by the purchase restriction rules is represented by a positive integer; symbol This represents the truth value of the proposition "The user's identity exists in the whitelist"; the symbol... Represents the truth value of the proposition "The user's identity exists in the blacklist"; logical operators This represents logical AND. Represents logical OR, This indicates logical NOT. The qualification verification passes if and only if the formula evaluates to true.
[0025] In practice, if any of the above verification conditions are not met—for example, the current time is outside the activity range or the activity status is "ended," the user's historical purchase records have reached the purchase limit, or the user's identity is on the blacklist and not on the whitelist—the request receiving verification module will immediately terminate the process and return a qualification verification failure result to the user. Subsequent inventory pre-deduction operations will not be executed. The execution of all verification logic relies on data in the first-level cache, which is either a local memory cache or a configuration center cache. The data update mechanism of the first-level cache ensures that the verification information has low read latency and high timeliness.
[0026] In one embodiment of the present invention, see [reference] Figure 3 The inventory pre-deduction module determines the storage key of the corresponding digital asset inventory pool in the distributed cache based on the target digital asset information in the purchase request. This module sends an atomic set pop instruction to the distributed cache service, which operates on the list of digital asset identifiers corresponding to the storage key. The execution of this atomic set pop instruction is random and atomic; it randomly removes a digital asset identifier from the set and returns it. The module receives the instruction execution result returned by the distributed cache. If the returned result is successful and contains a specific digital asset identifier, the inventory pre-deduction operation is considered successful, and this specific digital asset identifier is the deducted digital asset identifier.
[0027] In practice, once a user's identity passes qualification verification, the inventory pre-deduction module begins executing the inventory pre-deduction operation. Based on the target digital asset information carried in the purchase request, the inventory pre-deduction module determines the storage key of the digital asset inventory pool corresponding to the target digital asset in the distributed cache. The storage key is a string, and its construction rule can include a purchase activity identifier and a fixed namespace prefix. In some embodiments, the inventory pre-deduction module sends an atomic set pop instruction to the distributed cache server. The atomic set pop instruction is a native command provided by the distributed cache, and it operates on the list of digital asset identifiers corresponding to the previously determined storage key. The list of digital asset identifiers is stored in the distributed cache as a set data structure during initialization. Each element in the set is a unique digital asset identifier, representing a sellable digital asset. The execution of the atomic set pop instruction possesses atomicity and randomness. Atomicity ensures that only one request can successfully remove an element from the set in a concurrent environment, while randomness means that the popped element is unpredictable, avoiding the problem of hot assets being prioritized for purchase. Sending the atomic set pop instruction is the core operation for executing inventory deduction.
[0028] It's understandable that the inventory pre-deduction module then receives the instruction execution result returned by the distributed cache. There are two possible results. First, the atomic set pop instruction executes successfully, and the distributed cache returns a success status code along with a specific digital asset identifier—the element removed from the set. In this case, the inventory pre-deduction module determines that the inventory pre-deduction operation is successful and records this specific digital asset identifier as the deducted digital asset identifier for subsequent processes. Second, the atomic set pop instruction fails, for example, because the set is already empty and cannot pop an element; the distributed cache returns a result indicating failure or a null value. In this case, the inventory pre-deduction module determines that the inventory pre-deduction operation has failed and directly returns an insufficient inventory message to the user, terminating the process.
[0029] Optionally, the relationship between the operation and result determination logic of the atomic set pop instruction can be expressed by the following formula: Where: symbol This represents the operation of sending an atomic set pop instruction to a distributed cache; symbol Represents the storage key of the digital asset inventory pool in the distributed cache; symbol The status representing the result of instruction execution, with a value of "SUCCESS" or "FAILURE"; symbol This represents the specific digital asset identifier that appears when the result is "SUCCESS". When the result is "FAILURE", the value of the "AssetID" symbol is empty (NULL). Only when... The inventory pre-deduction operation is considered successful only when the value is "SUCCESS" and "AssetID" is not empty.
[0030] In practice, the digital asset inventory pool is preloaded into a distributed cache before the activity begins, and the number of elements in the set is the initial total inventory. Each successful atomic set pop instruction reduces the number of elements in the set by one. This operation is completed in the distributed cache memory, resulting in extremely high processing speed. In this way, the inventory deduction action is decoupled from subsequent steps such as qualification verification and order creation, completely transferring the pressure of inventory contention to the high-performance distributed cache, thus achieving high-concurrency processing capabilities for inventory deduction.
[0031] In one embodiment of the present invention, after the inventory pre-deduction operation is successful and the identifier of the deducted digital asset is obtained, the order locking module generates a globally unique temporary order identifier. The module creates an order locking record in a distributed cache, the key of which is composed of the user identity identifier and the flash sale activity identifier, or directly uses the temporary order identifier as the key. The order locking record includes at least the following fields: the identifier of the deducted digital asset, the record creation timestamp, and the order status, wherein the order status is marked as pre-locked at the time of creation.
[0032] In practice, after the inventory pre-deduction module successfully executes the inventory pre-deduction operation and obtains a specific digital asset identifier, the order locking module immediately intervenes, generating a globally unique temporary order identifier. The temporary order identifier is generated using a distributed unique sequence generation algorithm and is used in subsequent processes to associate the pre-deducted asset with the user identity identifier. Generating a globally unique temporary order identifier is a prerequisite for creating an order lock record. In some embodiments, the order locking module creates an order lock record for the user identity identifier in a distributed cache. The storage key of the order lock record is composed of a combination of the user identity identifier and the flash sale activity identifier; the combination rule can be string concatenation. The storage key can also directly use the temporary order identifier. Using a combination of the user identity identifier and the flash sale activity identifier as the key facilitates querying based on user and activity dimensions; using the temporary order identifier as the key provides better uniqueness and indexing efficiency. The action of creating an order lock record involves setting the value of the corresponding key in the distributed cache.
[0033] As is understandable, an order lock record contains several essential fields. At a minimum, it includes the identifier of the deducted digital asset, a creation timestamp, and the order status. The deducted digital asset identifier is the specific digital asset identifier obtained from the inventory pre-deduction operation. The creation timestamp is the system timestamp at the time the record is generated, used to subsequently determine the validity period of the order lock record. The order status is explicitly marked as pre-locked when the record is created. Order lock records are stored in a distributed cache in the form of a structured string or a serialized object.
[0034] Optionally, the creation operation and content of the order lock record can be formally represented as the following stored procedure: Where: symbol Represents an atomic command in a distributed cache that sets a key only if the key does not already exist; symbol The storage key representing the order lock record; symbol The value stored represents a data structure containing multiple fields that satisfy the relational property. In the formula, the symbol Indicates the digital asset being deducted; symbol Indicates the creation timestamp; symbol This indicates the order status, with its initial value fixed at "PRE_LOCKED" (pre-locked status). The "SETNX" command can be used to prevent duplicate locking operations on the same user identity or temporary order identity.
[0035] In practice, once an order lock record is created and stored in the distributed cache, it signifies that the digital asset identifier has transitioned from an occupied state in the inventory pool to a pre-locked state bound to a specific user. The pre-locked state is an intermediate state, meaning the asset has been reserved but the final order persistence and asset ownership transfer have not yet been completed. The order lock record in the distributed cache has a defined expiration time. This expiration time prevents the record from being permanently locked due to failures in subsequent asynchronous processing. The expiration time is set based on a business-defined threshold for the effective duration of order locks.
[0036] In one embodiment of the present invention, the asynchronous order placement and rollback module reads the order lock record from the distributed cache. The module extracts the user identity identifier, digital asset identifier, and creation timestamp contained in the record for order information integrity verification. The verification includes verifying the standardization of the user identity identifier format, confirming that the digital asset identifier exists in the system's valid asset master data list, and checking whether the difference between the record creation time and the current time is less than a preset lock validity duration threshold. After completing the information integrity verification, the module performs a secondary verification based on business rules. It queries the user service based on the user identity identifier to confirm that the account status is normal, and queries the asset service based on the digital asset identifier to confirm that the asset is salable and not locked by other orders. When all verifications pass, the module constructs an order message containing the user identity identifier, digital asset identifier, temporary order identifier, and order details, and sends this message to the designated message queue topic. The message consumer service started in the background listens to this message queue topic. When the order message is consumed, it performs an operation in a database transaction, persists the order data to the database order table, updates the ownership status of the digital asset to belong to the user identity identifier, and updates the status of the corresponding order lock record in the distributed cache to the completed state.
[0037] In practice, the asynchronous order placement and rollback module processes order lock records asynchronously based on a message queue. The module first reads the order lock records from a distributed cache. Reading the order lock records requires querying based on a storage key, which can be a combination of the user's identity identifier and the flash sale activity identifier, or a temporary order identifier. The read operation retrieves all field information contained in the order lock record, including the user's identity identifier, digital asset identifier, and creation timestamp. These fields are the foundational data for subsequent verification and processing.
[0038] In some embodiments, the asynchronous order placement and rollback module performs order information integrity verification based on information in the order lock record. Order information integrity verification checks whether the user identity identifier's format conforms to a preset specification, which may require the user identity identifier to be a numeric string of a specific length. Order information integrity verification checks whether the digital asset identifier exists in the system-maintained valid digital asset identifier master data list, which is a pre-loaded authoritative data source. Order information integrity verification checks whether the time difference between the creation timestamp and the current system time is less than a preset order lock validity period threshold, for example, a threshold set to 15 minutes. If the time difference between the creation timestamp and the current time exceeds the lock validity period threshold, the order lock record is determined to have expired. Refer to Table 1, which shows an example of the fields in an order lock record and their data sources and uses in integrity verification.
[0039] Table 1: Examples of Order Lock Record Fields and Validation Related Tables Understandably, after verifying the completeness and validity of the order lock record information, the asynchronous order placement and rollback module performs a secondary verification of business rules. This secondary verification queries the user service based on the user's identity, and the user service returns the current status information of the user account. This secondary verification confirms that the user account's current status is normal and not frozen. Next, it queries the asset service based on the digital asset's identity, and the asset service returns the current status information of the digital asset. This secondary verification confirms that the digital asset's current status is salable and not locked to other incomplete orders. When the user account status is normal and the digital asset status is salable, the asynchronous order placement and rollback module determines that the order information integrity verification and the secondary verification of business rules have passed.
[0040] In some embodiments, the system initiates an asynchronous message consumer service, which listens to a specified message queue topic. When the message consumer service consumes an order message, it performs multiple operations within a database transaction. The message consumer service writes the order data to a persistent order table in the database; this persistent order table is the final order table stored in the relational database. The message consumer service changes the ownership status of the digital asset to belong to the user's identity identifier; this operation is achieved by updating the asset ownership relationship table. Simultaneously, the message consumer service updates the order status in the corresponding order lock record in the distributed cache, changing the order status from pre-locked to completed.
[0041] See Figure 4 This is a line chart showing the pass rate of secondary verification for digital asset flash sale business rules. It displays the changes in verification indicators during different periods of a flash sale event and is a performance analysis chart for high-concurrency flash sale systems. All three indicators remain above 94%, indicating high overall reliability of the secondary verification process and suitability for high-concurrency flash sale scenarios. Fluctuations in user account status verification can be used for optimization (such as preheating the user status cache) to further improve the stability of the overall pass rate. This chart can be used for real-time monitoring or post-event review of flash sale events, assisting in evaluating the performance of the business rule verification process and supporting system optimization decisions.
[0042] In one embodiment of the present invention, during the entire process of asynchronously processing order lock records, the system performs anomaly capture on stages such as order information integrity verification, secondary verification of business rules, order message sending, and database transaction operations. When an anomaly is captured, the system determines the digital asset identifier that needs to be rolled back based on the order lock records acquired before the anomaly occurred. The system sends an atomic set add instruction to the distributed cache. This instruction acts on the storage key of the corresponding digital asset inventory pool, adding the digital asset identifier that needs to be rolled back as an element back to the original digital asset identifier list. After the atomic set add instruction is successfully executed, the system cleans up the corresponding order lock record in the distributed cache or updates its status to a rolled-back state. The first-level cache uses a local memory cache or a configuration center cache to store the flash sale activity configuration, user purchase limit count, and blacklist / whitelist data. The distributed cache uses a memory-based key-value storage database to store the digital asset inventory pool and order lock records.
[0043] In practice, the asynchronous order placement and rollback module automatically rolls back inventory when a failure occurs at any stage of the asynchronous processing. The asynchronous processing encompasses multiple stages, including order information integrity verification, secondary verification of business rules, order message sending, and database transaction operations. The asynchronous order placement and rollback module handles exceptions at these stages using try-catch mechanisms in programming languages or message queue retry and dead-letter queue monitoring mechanisms. When an exception is detected, the automatic inventory rollback operation is triggered.
[0044] In some embodiments, the asynchronous order placement and rollback module determines the digital asset identifiers that need to be rolled back based on the order lock records acquired before the exception occurred. The order lock records, which contain the deducted digital asset identifiers, are read and stored in memory variables at the start of the asynchronous process. Determining the digital asset identifiers that need to be rolled back is the direct basis for executing subsequent add operations. The asynchronous order placement and rollback module sends an atomic set add instruction to the distributed cache. This atomic set add instruction is an atomic command provided by the distributed cache for adding elements to a set. The atomic set add instruction operates on the storage key corresponding to the digital asset inventory pool, and this storage key is the same as the one used when performing the inventory pre-deduction operation. The atomic set add instruction adds the digital asset identifiers that need to be rolled back as elements back to the digital asset identifier list.
[0045] It's understandable that after the atomic set addition instruction executes successfully, the asynchronous order placement and rollback module cleans up or updates the corresponding order lock records in the distributed cache. The cleanup operation directly deletes the order lock records with the user's identity and flash sale activity identifier as the key, or the temporary order identifier as the key. The update operation modifies the order status field in the order lock record, marking the order status as rolled back. The cleanup or update operations prevent the same pre-locked record from being processed repeatedly or from being incorrectly identified as an expired record.
[0046] Optionally, the entire automatic inventory rollback operation can be formally expressed as a function: Where: symbol Represents the automatic inventory rollback operation function; symbol The symbol representing the digital asset that needs to be rolled back. The value comes from the deducted digital asset identifier field in the order lock record; symbol The storage key representing the digital asset inventory pool; symbol This represents the result of the rollback operation, with a value of either "SUCCESS" or "FAILURE". (Function) The internal logic includes sending atomic set add instructions. And subsequent operations to clear or update order lock records.
[0047] In practical implementation, the first-level cache is either a local memory cache or a configuration center cache. The first-level cache is used to cache the flash sale activity configuration, user purchase limit rules, and blacklist / whitelist data. The local memory cache offers extremely fast read speeds but presents challenges in data consistency. The configuration center cache provides unified data management and ensures data consistency within the cluster. The distributed cache is a memory-based key-value store database used to store the digital asset inventory pool and order lock records. The memory-based key-value store database provides high-performance atomic set operations and key-value access capabilities, supporting the high-concurrency access requirements for inventory pre-deduction and order lock record storage.
[0048] See Figure 5 This is a performance chart of atomic instruction execution metrics for inventory rollback in digital asset flash sales. It displays the success rate and time consumption of atomic set addition instructions across different rollback batches, and is a performance analysis chart for cache operations in high-concurrency systems. The atomic instruction success rate consistently remains above 98%, meeting the reliability requirements of inventory rollback in high-concurrency flash sales scenarios. The peak time consumption in batch 5 can serve as an optimization direction. This chart can be used to monitor the cache operation performance of the inventory rollback process, assist in evaluating the atomic operation capabilities of the distributed cache, and support optimization decisions for high-concurrency stability of the system.
[0049] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0050] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction, characterized in that: The system includes: The request receiving verification module receives a purchase request sent by a user for a target digital asset, wherein the purchase request carries a user identity identifier; The inventory pre-deduction module verifies the user's identity based on a preset first-level cache, and after the verification is successful, performs an inventory pre-deduction operation based on the digital asset inventory pool stored in the distributed cache. The digital asset inventory pool uses a set data structure to store a list of sellable digital asset identifiers. The order locking module creates an order locking record for the user identity in the distributed cache based on the digital asset identifier being deducted when the inventory pre-deduction operation is successful. The asynchronous order placement and rollback module, based on a message queue, asynchronously processes the order lock records, generates persistent order data, and completes the final binding of digital assets with users. If any step in the asynchronous processing fails, an automatic inventory rollback operation is performed based on the digital asset identifier recorded in the order lock record, and the corresponding digital asset identifier is added back to the digital asset inventory pool in the distributed cache.
2. The high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in claim 1, characterized in that, Based on a preset first-level cache, the user identity identifier is used for qualification verification, including: Extract the purchase activity identifier of the target digital asset from the purchase request; Based on the flash sale activity identifier, the flash sale activity configuration information of the target digital asset is obtained from the first-level cache. The flash sale activity configuration information includes the activity status, the activity time range, and the user qualification verification rules. Determine whether the current time is within the activity time range and whether the activity status is an available state; If the current time is within the activity time range and the activity is in an eligible state, then according to the user qualification verification rules, query the verification information corresponding to the user identity in the first-level cache; Based on the retrieved verification information, it is determined whether the user's identity identifier meets the eligibility requirements for participation. If it does, the eligibility verification is passed.
3. The high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in claim 2, characterized in that, The user qualification verification rules include purchase restriction rules and blacklist / whitelist rules; According to the user qualification verification rules, query the verification information corresponding to the user identity identifier in the first-level cache, including: Based on the flash sale activity identifier, the purchase limit rules for the target digital asset are obtained from the first-level cache, and based on the user identity identifier, the number of the user's historical successful purchase records in the flash sale activity is queried to determine whether the number of historical successful purchase records is less than the maximum purchase quantity stipulated by the purchase limit rules. Based on the flash sale activity identifier, retrieve the blacklist and whitelist for the flash sale activity from the first-level cache, and determine whether the user identity identifier exists in the whitelist of the blacklist and whitelist or does not exist in the blacklist of the blacklist and whitelist. If the number of successful historical purchase records is less than the maximum purchase quantity, and the user's identity is either in the whitelist or not in the blacklist, then the user's identity is deemed to be eligible to participate.
4. The high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in claim 1, characterized in that, Based on the digital asset inventory pool stored in the distributed cache, perform inventory pre-deduction operations, including: Based on the target digital asset information carried in the purchase request, determine the storage key of the corresponding digital asset inventory pool in the distributed cache; An atomic set pop instruction is sent to the distributed cache. The atomic set pop instruction acts on the list of digital asset identifiers corresponding to the storage key, and is used to randomly and atomically pop a digital asset identifier from the list of digital asset identifiers. If the distributed cache returns the instruction execution result, and the return result is successful and carries a specific digital asset identifier, then the inventory pre-deduction operation is determined to be successful, and the specific digital asset identifier is used as the digital asset identifier to be deducted.
5. The high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in claim 4, characterized in that, Upon successful inventory pre-deduction operation, an order lock record is created in the distributed cache for the user identity based on the deducted digital asset identifier, including: Generate a globally unique temporary order identifier; In the distributed cache, an order lock record is stored using a key composed of the user identity identifier and the flash sale activity identifier, or using the temporary order identifier as the key. The order lock record at least includes the deducted digital asset identifier, the creation timestamp, and the order status, and the order status is marked as a pre-locked state.
6. The high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in claim 5, characterized in that, Based on a message queue, the order lock records are processed asynchronously to generate persistent order data and complete the final binding of digital assets with users, including: Read the order lock record from the distributed cache; Based on the information in the order lock record, perform order information integrity verification and secondary verification of business rules; After the secondary verification is passed, an order message containing user identity identifier, digital asset identifier, temporary order identifier, and order details is constructed; Send the order message to the specified message queue topic; Start an asynchronous message consumer service. The message consumer service listens to the specified message queue topic. When it consumes the order message, it performs a database transaction operation, writes the order data to the persistent order table in the database, changes the ownership status of the digital asset to belong to the user's identity, and updates the order status in the order lock record to the completed status.
7. The high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in claim 6, characterized in that, Extract the user identity identifier, digital asset identifier, and creation timestamp contained in the order lock record from the distributed cache; Verify whether the format of the user identity identifier conforms to the preset specifications, and verify whether the digital asset identifier exists in the system-maintained list of valid digital asset identifier master data; Check whether the time difference between the creation timestamp and the current system time is less than the preset order lock validity period threshold; After verifying that the information in the order lock record is complete and valid, the user service is queried based on the user identity identifier to confirm that the user account is currently in normal status and has not been frozen. The asset service is queried based on the digital asset identifier to confirm that the digital asset is currently available for sale and is not locked to other incomplete orders. When a user's account is in a normal state and the digital assets are available for sale, the order information integrity verification and the secondary verification of business rules are deemed to have passed.
8. The high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in claim 1, characterized in that, If a failure occurs at any stage of the asynchronous processing, an automatic inventory rollback operation is performed based on the digital asset identifier recorded in the order lock record, including: During asynchronous processing, exceptions are captured in the order information integrity verification, business rule secondary verification, order message sending, and database transaction operation stages. When an anomaly is detected, the digital asset identifier that needs to be rolled back is determined based on the order lock records obtained before the anomaly occurred. An atomic set add instruction is sent to the distributed cache. The atomic set add instruction acts on the storage key corresponding to the digital asset inventory pool and adds the digital asset identifier that needs to be rolled back as an element back to the digital asset identifier list. After the atomic set addition instruction is successfully executed, the status of the corresponding order lock record in the distributed cache is cleared or updated to the rollback state.
9. The high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in claim 1, characterized in that, The first-level cache is a local memory cache or a configuration center cache, used to cache the flash sale activity configuration, user purchase limit rules, and blacklist / whitelist data. The distributed cache is a memory-based key-value storage database used to store the digital asset inventory pool and order lock records.
10. A high-concurrency flash sale method for digital assets based on multi-level caching and pre-deduction, characterized in that, It includes all modules and method flows of the high-concurrency flash sale system for digital assets based on multi-level caching and pre-deduction as described in any one of claims 1 to 9.