Data processing method and device, electronic equipment and storage medium
By determining whether the item records of the target user's account match, updating the item quantity, adjusting the expiration time, and clearing expired records, the problem of virtual item records occupying a large amount of storage space and long query time is solved, thus achieving efficient virtual item management and display.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
- Filing Date
- 2023-05-11
- Publication Date
- 2026-05-12
AI Technical Summary
When virtual items are issued to user accounts, the number of records generated is enormous, consuming a large amount of storage space, and querying virtual items takes a long time.
By obtaining the item records of the target user's account, it is determined whether there are matching item records, and the item quantity is updated when matching records exist to avoid generating new records; the expiration time is adjusted to a fixed time point in the time cycle to generate initial item records; the same type of virtual item is aggregated and displayed, and expired records are cleaned up in a timely manner.
It reduces storage space usage, shortens query time, and improves user experience and system efficiency.
Smart Images

Figure CN116582718B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a data processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Once the conditions for issuing virtual items to a user account are met, virtual items will be issued to that account. Each issuance of virtual items generates a record, resulting in a massive volume of records. This large number of records consumes a significant amount of storage space; furthermore, when a user account queries its virtual items, it needs to filter through this vast amount of records, leading to lengthy query times. Summary of the Invention
[0003] To overcome the problems existing in related technologies, this disclosure provides a data processing method, apparatus, electronic device, and storage medium. The technical solution of this disclosure is as follows:
[0004] According to a first aspect of the present disclosure, a data processing method is provided, comprising:
[0005] In response to a request to distribute virtual items to a target user account, the system obtains the item identifier, expiration time, and quantity of the virtual items to be distributed to the target user account.
[0006] Obtain at least one target item record corresponding to the target user account. Each target item record includes: target item identifier, target expiration time, and target item quantity. The target item quantity is the number of virtual items in the target user account whose item identifier is the target item identifier and whose expiration time is the target expiration time.
[0007] Based on the pending expiration time and the pending item identifier, determine whether the at least one target item record includes a matching item record, wherein the target item identifier in the matching item record is the same as the pending item identifier, and the target expiration time in the matching item record is the same as the pending expiration time;
[0008] If the matching item record is included in at least one target item record, the quantity of the target item in the matching item record is updated according to the quantity of items to be distributed.
[0009] Optionally, the expiration time is a fixed point in time within a time period;
[0010] Obtaining the expiration time of the virtual items to be distributed to the target user account includes:
[0011] Obtain the expected expiration time of the virtual items to be distributed to the target user's account;
[0012] Determine the time period to which the expected expiration time belongs;
[0013] The fixed time point within the time period is determined as the expiration time to be issued.
[0014] Optionally, the target item record includes an identifier of the target user account;
[0015] If the matching item record is not included in the at least one target item record, the method further includes:
[0016] Obtain the identifier of the target user account;
[0017] Based on the identifier of the target user account, the identifier of the item to be distributed, and the expiration time of the item to be distributed, an initial item record is generated, and the quantity of the item in the initial item record is 0;
[0018] Lock and read the initialization item record;
[0019] Based on the quantity to be issued, update the quantity of items in the initial item record to obtain a new item record, and unlock and read the new item record.
[0020] Optionally, the target item record includes an identifier of the target user account;
[0021] The step of obtaining at least one target item record corresponding to the target user account includes:
[0022] Obtain the identifier of the target user account;
[0023] Based on the identifier of the target user account, determine the target data table for storing the records of the target items;
[0024] Based on the identifier of the target user account, read the at least one target item record from the target data table.
[0025] Optionally, it also includes:
[0026] In response to a virtual item display request from the target user account, at least one target item record corresponding to the target user account is obtained;
[0027] The quantity of each type of virtual item is determined based on the quantity of each of the target items contained in at least one target item record with the same target item identifier, wherein the item identifiers of the virtual items belonging to the same type are the same;
[0028] Based on the target expiration time contained in at least one target item record with the same target item identifier, the display expiration time of each virtual item is determined;
[0029] Based on the item identifier, quantity, and expiration time to be displayed for each virtual item, a display instruction is generated and sent to the client of the target user account. The display instruction is used to instruct the client to aggregate and display each virtual item according to the item identifier and quantity, and to display the quantity and expiration time to be displayed for each virtual item.
[0030] Optionally, the virtual item display request for the target user account includes information about the display page; it also includes:
[0031] Obtain information from the displayed page;
[0032] The step of generating a display instruction based on the item identifier, quantity, and expiration time to be displayed for each virtual item includes:
[0033] Based on the information on the display page, virtual items that do not match the display page are filtered to obtain filtered virtual items;
[0034] A filtered display instruction is generated based on the item identifier, quantity, and expiration time to be displayed for each of the filtered virtual items.
[0035] Optionally, determining the display expiration time of each virtual item based on the target expiration time contained in at least one target item record with the same target item identifier includes:
[0036] Based on the expiration time of each of the virtual items belonging to the same type, the expiration time of each of the at least one target item record with the same target item identifier is determined.
[0037] The expiration time of each virtual item to be displayed is determined based on the expiration time of each virtual item belonging to the same category.
[0038] Optionally, it also includes:
[0039] In response to the start of a scheduled cleanup task, it iterates through each item record;
[0040] The expired item record is determined based on the expiration time and the quantity of the item included in the item record;
[0041] Delete the expired item records in batches.
[0042] According to a second aspect of the present disclosure, a data processing apparatus is provided, comprising:
[0043] The acquisition module is configured to, in response to a virtual item delivery request to a target user account, acquire the item identifier to be delivered, the expiration time to be delivered, and the quantity of virtual items to be delivered to the target user account.
[0044] The record acquisition module is configured to acquire at least one target item record corresponding to the target user account. One target item record includes: target item identifier, target expiration time, and target item quantity. The target item quantity is the number of virtual items in the target user account whose item identifier is the target item identifier and whose expiration time is the target expiration time.
[0045] The determination module is configured to determine, based on the pending expiration time and the pending item identifier, whether the at least one target item record includes a matching item record, wherein the target item identifier in the matching item record is the same as the pending item identifier, and the target expiration time in the matching item record is the same as the pending expiration time;
[0046] The update module is configured to update the quantity of the target item in the matching item record according to the quantity of the items to be distributed, when the matching item record is included in the at least one target item record.
[0047] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the data processing method as described in the first aspect.
[0048] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the data processing method as described in the first aspect.
[0049] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the data processing method as described in the first aspect.
[0050] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:
[0051] In this disclosure, when distributing virtual items to a target user account, the system can determine whether the target item record for the target user account includes a matching item record based on the item identifier and expiration time of the virtual item. The matching item record must have the same target item identifier as the distributed item identifier and the same target expiration time as the distributed item. If the target item record includes a matching item record, the quantity of target items in the matching item record can be directly updated based on the quantity of distributed items. Thus, when a matching item record exists, there is no need to generate a new item record; updating the quantity of items in the matching item record is sufficient to record the distributed virtual items, thereby reducing storage space consumption and shortening query time.
[0052] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0053] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0054] Figure 1 This is a flowchart illustrating a data processing method according to an exemplary embodiment;
[0055] Figure 2 This is a sequence diagram of the generation of new item records in this disclosure;
[0056] Figure 3 This is a sequence diagram for displaying virtual items in this disclosure;
[0057] Figure 4 This is a sequence diagram of the deletion of expired item records in this disclosure;
[0058] Figure 5 This is a block diagram illustrating a data processing apparatus according to an exemplary embodiment;
[0059] Figure 6 This is a block diagram illustrating an apparatus for data processing according to an exemplary embodiment;
[0060] Figure 7 This is a block diagram illustrating an apparatus for data processing according to an exemplary embodiment. Detailed Implementation
[0061] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0062] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0063] Figure 1 This is a flowchart illustrating a data processing method according to an exemplary embodiment, such as... Figure 1 As shown, this data processing method can be used in electronic devices such as computers, mobile phones, and tablets, including steps S11 to S14.
[0064] In step S11, in response to a request to distribute virtual items to a target user account, the system obtains the item identifier, expiration time, and quantity of the virtual items to be distributed to the target user account.
[0065] The target user account can be any user account to which virtual items will be distributed. The request to distribute virtual items to the target user account can be triggered by the target user account completing relevant tasks or meeting the conditions for distributing virtual items, or it can be initiated by the party distributing the virtual items.
[0066] The "Item to be Distributed" identifier is the identifier of the virtual item to be distributed to the target user's account; the "Expiration Time to be Distributed" is the expiration time of the virtual item to be distributed to the target user's account; and the "Quantity to be Distributed" is the quantity of the virtual item to be distributed to the target user's account. A virtual item distribution request for a target user's account carries the identifier of the target user's account, an "Item to be Distributed" identifier, an "Expiration Time to be Distributed" date, and a "Quantity to be Distributed" date.
[0067] Optionally, the system can first check whether the name and identifier of the target user account, the name and identifier of the virtual item to be distributed are abnormal, and if any abnormality is found, the virtual item distribution request can be suspended.
[0068] In step S12, at least one target item record corresponding to the target user account is obtained. Each target item record includes: target item identifier, target expiration time, and target item quantity. The target item quantity is the number of virtual items in the target user account whose item identifier is the target item identifier and whose expiration time is the target expiration time.
[0069] A target item record is a record of virtual items issued to a target user account. This record can be accessed via snapshots. A target item record can include the target user account's identifier, a target item identifier, a target expiration time, and a target item quantity. The target item quantity in a target item record is the number of virtual items in the target user account whose item identifier matches the target item identifier included in that record and whose expiration time matches the target expiration time included in that record.
[0070] If the target item identifier and / or target expiration time are different between any two target item records corresponding to the target user account, then the two target item records will be merged into one target item record.
[0071] Optionally, to shorten query time, when storing target item records corresponding to target user accounts, the target data table for storing target item records can be determined based on the identifier of the target user account. The correspondence between the identifier of the target user account and each data table can be pre-configured. For example, the data table for storing target item records corresponding to each target user account can be determined based on the last digit of the target user account identifier. Item records corresponding to user accounts whose identifier ends in 1 can be stored in the same data table, item records corresponding to user accounts whose identifier ends in 2 can be stored in the same data table, and so on.
[0072] Therefore, step S12 may include: obtaining the identifier of the target user account; determining the target data table for storing the target item records based on the identifier of the target user account; and reading the at least one target item record from the target data table based on the identifier of the target user account.
[0073] The identifier of a target user account can be obtained from the virtual item distribution request. Based on this identifier, configuration information can be queried to determine the target data table storing the target item records corresponding to that user account. Furthermore, the target item records corresponding to the target user account can be quickly retrieved from this target data table.
[0074] In this way, whether it is distributing virtual items to user accounts or displaying virtual items to user accounts, the time to obtain the target item records corresponding to the target user account can be shortened, avoiding the waste of a lot of time and computing resources to query massive item records from each data table.
[0075] In step S13, based on the pending expiration time and the pending item identifier, it is determined whether the at least one target item record includes a matching item record, wherein the target item identifier in the matching item record is the same as the pending item identifier, and the target expiration time in the matching item record is the same as the pending expiration time.
[0076] If two target item records corresponding to a target user account have the same target item identifier and target expiration time, these two target item records will be merged into one target item record. Since a target item record is the item record corresponding to a target user account, it is only necessary to determine whether a matching item record is included based on the pending expiration date and the pending item identifier. The matching item record contains the same target item identifier as the pending item identifier, and the matching item record also contains the same target expiration date as the pending expiration date.
[0077] In step S14, if the matching item record is included in the at least one target item record, the quantity of the target item in the matching item record is updated according to the quantity of items to be distributed.
[0078] If the target item record does not include a matching item record, a new item record can be generated directly based on the virtual items to be distributed. If the target item record includes a matching item record, even if a new item record is generated, it will be merged with the matching item record. Therefore, when the target item record includes a matching item record, the quantity of the target item in the matching item record can be updated directly based on the quantity of the virtual items to be distributed, and the virtual items to be distributed can be distributed to the target user account.
[0079] By adopting the technical solution of the disclosed embodiments, when distributing virtual items to a target user account, it can be determined whether the target item record corresponding to the target user account includes a matching item record based on the distributed item identifier and the distributed expiration time of the virtual item distributed to the target user account. The target item identifier in the matching item record is the same as the distributed item identifier, and the target expiration time in the matching item record is the same as the distributed expiration time. When the target item record includes a matching item record, the quantity of target items in the matching item record can be directly updated based on the quantity of distributed items. Thus, when a matching item record exists, there is no need to generate a new item record; the distribution of virtual items can be recorded by updating the quantity of items in the matching item record, thereby reducing storage space consumption and shortening query time.
[0080] Optionally, to further reduce the number of item records, the expiration time of virtual items can be adjusted. The expiration time of virtual items can be set as a fixed point in a time period; for example, the expiration time can be set as the end time of the time period.
[0081] Therefore, when obtaining the expected expiration time of virtual items to be distributed to a target user account, the anticipated expiration time of the virtual items to be distributed to the target user account can be obtained; the time period of the anticipated expiration time can be determined; and the fixed time point within the time period can be determined as the expected expiration time. The anticipated expiration time of a virtual item is the unadjusted expiration time.
[0082] For example, virtual item A has a validity period of 20 hours. Two instances of virtual item A are issued to the same user account at 01:00 and 02:00 on the same day. According to relevant technologies, this user account would have one virtual item A expiring at 21:00 and another expiring at 22:00. Because the expiration times are different, two item records would need to be generated. Using the technical solution of this disclosure embodiment, the time period can be set to daily, with a fixed time of 23:59:59 each day. Then, the expiration time of both virtual item A expected to expire at 21:00 and virtual item A expected to expire at 22:00 is adjusted to 23:59:59 of the current day. Therefore, only one item record needs to be generated, and the item quantity in this record combines the quantities of virtual item A issued at 01:00 and 02:00.
[0083] In this way, by adjusting the expiration time of virtual items to a fixed point in the time cycle, the problem of a large number of item records caused by different expiration times can be effectively solved, thereby effectively reducing the storage space occupied and shortening the time spent querying item records.
[0084] Optionally, based on the above technical solution, if the target item record does not include a matching item record, a new item record corresponding to the target user account can be generated.
[0085] The identifier of the target user account can be obtained from the virtual item delivery request; based on the identifier of the target user account, the identifier of the item to be delivered, and the expiration time of the item to be delivered, an initial item record is generated, and the item quantity in the initial item record is 0; the initial item record is locked and read; based on the quantity to be delivered, the item quantity in the initial item record is updated to obtain a new item record, and the lock on the new item record is released and read.
[0086] When writing initial item records to the database, the database can automatically start a MySQL transaction (auto-commit the transaction). The MySQL transaction can lock the initial item records, meaning that the initial item records cannot be read at this time, to prevent reading the wrong item records and ensure the atomicity of database operations.
[0087] Based on the quantity to be issued, update the quantity of items in the initial item record to obtain a new item record, write the new item record into the database, and unlock and read the new item record.
[0088] When writing initialization item records to the database, the initialization item records can be written to the target data table that stores the target item records corresponding to the target user account.
[0089] By adopting the technical solution of this disclosure embodiment, when the target item record does not include a matching item record, a new item record can be generated to record the virtual items to be issued.
[0090] Figure 2 This is a sequence diagram of a process for generating new item records in this disclosure. After a user account participates in an activity and meets the distribution conditions, the business side calls the distribution service to distribute virtual items. When calling the distribution service, the business side carries the activity identifier, the item identifier of the virtual item, the identifier of the target user account, the validity period of the virtual item, and the quantity of the item. The distribution service can perform permission verification to check whether the activity identifier, the item identifier of the virtual item, and the identifier of the target user account are abnormal. If the permission verification passes, the distribution service can obtain the expected expiration time of the virtual item based on the validity period of the virtual item and the current time, and then obtain the expiration time of the virtual item. The distribution service snapshot reads the target item record corresponding to the target user account. If no matching item record exists in the target item record, an initial item record is inserted. The initial item record includes an item quantity of 0 and includes the identifier of the target user account, the item identifier of the virtual item, and the expiration time. A locked read is enabled on the initial item record, and the quantity of the virtual item is added to the item quantity included in the initial item record to obtain a new item record. This realizes the insertion of the new item record into the database and the unlocking read of the new item record.
[0091] Virtual items acquired by a user account have an expiration date; virtual items within their validity period can be displayed in the user's inventory panel. In related technologies, when displaying virtual items in the inventory panel, the same type of virtual item with different expiration dates will be displayed in different inventory slots, making it difficult for users to determine the total number of each type of virtual item they own. Furthermore, occupying too many inventory slots can lead to a poor user experience. To solve the above technical problems, the data processing method proposed in this disclosure embodiment may further include steps S21 to S24.
[0092] In step S21, in response to the virtual item display request of the target user account, at least one target item record corresponding to the target user account is obtained.
[0093] The request to display virtual items for a target user account can be triggered when the target user account opens their inventory panel. This request carries an identifier for the target user account, allowing the retrieval of the target item's record. The method for retrieving the target item's record is described above and will not be repeated here.
[0094] In step S22, the quantity of each type of virtual item is determined based on the quantity of each of the target items contained in at least one target item record with the same target item identifier, wherein the item identifiers of the virtual items belonging to the same type are the same.
[0095] In step S23, the expiration time to be displayed for each virtual item is determined based on the target expiration time contained in at least one target item record with the same target item identifier.
[0096] Records containing the same target item identifier are considered to be of the same type of virtual item. Therefore, the quantity of each type of virtual item can be determined based on the number of target items contained in each record with the same target item identifier. Furthermore, the display expiration time of each virtual item can be determined based on the expiration time of each record containing the same target item identifier.
[0097] For example, target item record A includes: target item identifier A1, target expiration time T1, and target item quantity 5; target item record B includes: target item identifier A1, target expiration time T2, and target item quantity 7. Since both include target item identifier A1, it proves that target item record A and target item record B are records of the same type of virtual item. Based on target item record A and target item record B, it can be determined that the quantity of this type of virtual item with item identifier A1 is 12. Based on the target expiration time T1 and target expiration time T2, the expected expiration time for displaying this type of virtual item with item identifier A1 can be determined.
[0098] Optionally, step S23 may include: determining the expiration time of each virtual item belonging to the same type based on the target expiration time contained in at least one target item record with the same target item identifier; and determining the display expiration time of each virtual item based on the expiration time of each virtual item belonging to the same type.
[0099] This can be achieved by determining the expiration time of the virtual item with the shortest expiration time among all the virtual items included in each category, and then setting that as the display expiration time for that type of virtual item. "Shortest expiration time" refers to the time closest to the current time.
[0100] Using the previous example, target item record A includes: target item identifier A1, target expiration time T1, and target item quantity 5; target item record B includes: target item identifier A1, target expiration time T2, and target item quantity 7. If T1 is January 1st 23:59:59 and T2 is January 2nd 23:59:59, then T1 can be determined as the expiration time to be displayed for the virtual item with item identifier A1.
[0101] In this way, by determining the shortest expiration time for each type of virtual item as the expiration time to be displayed for that type of virtual item, users can determine the nearest expiration time and avoid displaying other expiration times. This prevents users from not using virtual items with the nearest expiration time, causing the virtual items to expire and resulting in waste.
[0102] In step S24, a display instruction is generated based on the item identifier, quantity, and expiration time to be displayed for each virtual item, and the display instruction is sent to the client of the target user account. The display instruction is used to instruct the client to aggregate and display each virtual item based on the item identifier and quantity, and to display the expiration time to be displayed for each virtual item.
[0103] After receiving the display instruction, the target user's client can aggregate and display each virtual item based on its identifier and quantity, showing the quantity and expiration time of each item. The expiration time can be displayed directly or as a countdown to the current time. Aggregated display means showing all virtual items of the same type in a single inventory slot.
[0104] For example, if there are 10 virtual flowers, 3 of which expire in 1 day and 7 expire in 2 days, when displaying this type of virtual item, the icon of the virtual flower can be displayed in a backpack slot, with the quantity "×10" displayed in the lower right corner of the icon to let the user know that there are a total of 10 virtual flowers, and the expiration time "1 day" displayed in the upper right corner of the icon to let the user know that some virtual flowers will expire in 1 day. Optionally, the expiration time displayed in the upper right corner of the icon can also be "3 flowers, 1 day" to let the user know that 3 virtual flowers will expire in 1 day.
[0105] When a user consumes a virtual item, the quantity in the item record will change accordingly. Item records with a quantity of 0 are not considered when determining the display expiration time for that type of virtual item. Therefore, when the quantity in the item record with the minimum expiration time becomes 0, the resulting display expiration time will also change accordingly. The displayed display expiration time will also change accordingly.
[0106] Alternatively, the aggregated backpack panel can be generated directly according to the display instructions, and then sent to the client so that the client can directly display the aggregated backpack panel.
[0107] By adopting the technical solution of this disclosure embodiment, the same virtual item with different expiration times can be displayed in different backpack slots, and the total number of such virtual items can be displayed. On the one hand, this saves backpack slots, and on the other hand, it allows users to quickly determine the total number of each type of virtual item. At the same time, it can also display the most recent expiration time, which can effectively improve the user experience.
[0108] Optionally, based on the above technical solution, the virtual item display request for the target account may further include information about the display page, which may include the type of live stream corresponding to the display page and the streamer's account corresponding to the display page. For example, if the target account opened its inventory in a game live stream, the virtual item display request may include information about the game live stream.
[0109] When generating a display instruction based on the item identifier, quantity, and expiration time of each virtual item, virtual items that do not match the display page can be filtered first, resulting in filtered virtual items. For example, some virtual items can only be consumed in the knowledge livestream room; therefore, if the display page is a game livestream room, there is no need to display virtual items that can only be consumed in the knowledge livestream room.
[0110] When generating a display instruction, it is only necessary to generate the filtered display instruction based on the item identifier, quantity, and expiration time to be displayed of the filtered virtual items. The filtered display instruction is used to instruct the client to aggregate and display each type of filtered virtual item according to the item identifier and quantity, and to display the quantity and expiration time of each type of filtered virtual item. The filtered display instruction is sent to the client so that the client can display the filtered virtual items.
[0111] In this way, the virtual items displayed on the display page are virtual items that can be consumed on that display page, avoiding the bad user experience caused by users not being able to consume the virtual items they own on that display page.
[0112] Figure 3 This is a sequence diagram of a method for displaying virtual items as disclosed in this publication. When a client views the inventory panel, it sends a virtual item display request to the server. The server queries all non-expired item records in the client's user account and aggregates records with the same item identifier to obtain the quantity and expiration time of each virtual item. Based on the information on the display page, the virtual items are filtered to obtain a filtered list of virtual items. Based on the item identifier, quantity, and expiration time of the filtered virtual items, an aggregated background panel is generated. The aggregated background panel is returned to the client so that the client can display it.
[0113] Optionally, based on the above technical solution, the following can also be implemented: in response to the start of a scheduled cleanup task, each item record is traversed; expired item records are determined based on the expiration time and the quantity of items included in the item records; and the expired item records are deleted in batches.
[0114] Figure 4 This is a sequence diagram of a method for deleting expired item records in this disclosure. The scheduled cleanup task can be started at regular intervals within each time period, and the start time of the scheduled cleanup task can be staggered to avoid peak periods. The scheduled cleanup task can obtain the shardID (data table number) of each data table storing item records, and traverse all data tables based on the shardID. It then traverses the item records in each data table, and determines whether an item record is expired based on its expiration time and the quantity of items included in the record. Item records with an expiration time earlier than the current time and / or a quantity of 0 are considered expired. The determined expired item records are then deleted.
[0115] Since the expiration time is a fixed point in the time cycle, a large number of item records will expire at the same time. Deleting all confirmed expired item records simultaneously would put a lot of pressure on the database. Therefore, it is better to delete confirmed expired item records in batches. After deleting the confirmed expired item records, an expiration record entry can be inserted.
[0116] Therefore, by promptly deleting expired item records, storage space can be freed up in a timely manner. Furthermore, when retrieving item records corresponding to user accounts, time is not wasted on expired item records, effectively improving efficiency. In addition, deleting items in batches can reduce the pressure on the database.
[0117] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure.
[0118] Figure 5 This is a block diagram illustrating a data processing apparatus according to an exemplary embodiment, with reference to... Figure 5 The device includes an acquisition module 51, a record acquisition module 52, a determination module 53, and an update module 54.
[0119] The acquisition module 51 is configured to, in response to a virtual item delivery request to a target user account, acquire the virtual item identifier to be delivered, the expiration time to be delivered, and the quantity of virtual items to be delivered to the target user account.
[0120] The record acquisition module 52 is configured to acquire at least one target item record corresponding to the target user account. One target item record includes: target item identifier, target expiration time, and target item quantity. The target item quantity is the number of virtual items in the target user account whose item identifier is the target item identifier and whose expiration time is the target expiration time.
[0121] The determination module 53 is configured to determine, based on the pending expiration time and the pending item identifier, whether the at least one target item record includes a matching item record, wherein the target item identifier in the matching item record is the same as the pending item identifier, and the target expiration time in the matching item record is the same as the pending expiration time;
[0122] The update module 54 is configured to update the quantity of the target item in the matching item record according to the quantity of the items to be distributed when the matching item record is included in the at least one target item record.
[0123] Optionally, the expiration time is a fixed point in time within a time period; the acquisition module 51 includes:
[0124] The time acquisition unit is configured to acquire the expected expiration time of the virtual items to be distributed to the target user's account;
[0125] The period determination unit is configured to determine the time period to which the expected expiration time belongs;
[0126] The time determination unit is configured to determine the fixed time point within the time period as the expiration time to be issued.
[0127] Optionally, the target item record includes an identifier of the target user account; if the matching item record is not included in the at least one target item record, it further includes:
[0128] The identifier acquisition module is configured to acquire the identifier of the target user account;
[0129] The record generation module is configured to generate an initial item record based on the identifier of the target user account, the identifier of the item to be issued, and the expiration time of the item to be issued, wherein the quantity of the item in the initial item record is 0;
[0130] The lock read module is configured to perform a lock read on the initialization item record;
[0131] The release module is configured to update the quantity of items in the initial item record according to the quantity to be issued, obtain a new item record, and release the lock on the new item record.
[0132] Optionally, the target item record includes the identifier of the target user account; the record acquisition module 52 includes:
[0133] The identifier acquisition unit is configured to acquire the identifier of the target user account;
[0134] The data table determination unit is configured to determine the target data table storing the target item records based on the identifier of the target user account;
[0135] The reading unit is configured to read the at least one target item record from the target data table based on the identifier of the target user account.
[0136] Optionally, it also includes:
[0137] The item record acquisition module is configured to acquire at least one target item record corresponding to the target user account in response to the virtual item display request of the target user account.
[0138] The quantity determination module is configured to determine the quantity of each type of virtual item based on the quantity of each of the target items contained in at least one target item record with the same target item identifier, wherein the item identifiers of the virtual items belonging to the same type are the same;
[0139] The time determination module is configured to determine the display expiration time of each virtual item based on the target expiration time contained in at least one target item record with the same target item identifier.
[0140] The instruction generation module is configured to generate a display instruction based on the item identifier, quantity, and expiration time to be displayed for each virtual item, and send the display instruction to the client of the target user account. The display instruction is used to instruct the client to aggregate and display each virtual item based on the item identifier and quantity, and to display the quantity and expiration time to be displayed for each virtual item.
[0141] Optionally, the virtual item display request for the target user account includes information about the display page; it also includes:
[0142] The information acquisition module is configured to acquire information from the displayed page;
[0143] The instruction generation module includes:
[0144] The filtering unit is configured to filter virtual items that do not match the display page based on the information of the display page, and obtain filtered virtual items.
[0145] The instruction generation unit is configured to generate a filtered display instruction based on the item identifier, quantity, and expiration time to be displayed for each of the filtered virtual items.
[0146] Optionally, the time determination module includes:
[0147] Each time determination unit is configured to determine the expiration time of each virtual item belonging to the same type based on the target expiration time contained in at least one target item record with the same target item identifier.
[0148] The expiration time determination unit is configured to determine the display expiration time of each virtual item based on the expiration times of each virtual item belonging to the same type.
[0149] Optionally, it also includes:
[0150] The traversal module is configured to traverse each item record in response to the start of a scheduled cleanup task;
[0151] The expired record determination module is configured to determine expired item records based on the expiration time and the quantity of items included in the item records;
[0152] The deletion module is configured to delete the expired item records in batches.
[0153] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0154] Figure 6 This is a block diagram illustrating an apparatus 600 for data processing according to an exemplary embodiment. For example, apparatus 600 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0155] Reference Figure 6 The device 600 may include one or more of the following components: a processing component 602, a memory 604, a power component 606, a multimedia component 608, an audio component 610, an input / output (I / O) interface 612, a sensor component 614, and a communication component 616.
[0156] Processing component 602 typically controls the overall operation of device 600, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the aforementioned data processing method. Furthermore, processing component 602 may include one or more modules to facilitate interaction between processing component 602 and other components. For example, processing component 602 may include a multimedia module to facilitate interaction between multimedia component 608 and processing component 602.
[0157] Memory 604 is configured to store various types of data to support the operation of device 600. Examples of such data include instructions for any application or method operating on device 600, contact data, phonebook data, messages, pictures, videos, etc. Memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0158] Power supply component 606 provides power to the various components of device 600. Power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to device 600.
[0159] Multimedia component 608 includes a screen that provides an output interface between the device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 608 includes a front-facing camera and / or a rear-facing camera. When the device 600 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0160] Audio component 610 is configured to output and / or input audio signals. For example, audio component 610 includes a microphone (MIC) configured to receive external audio signals when device 600 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 604 or transmitted via communication component 616. In some embodiments, audio component 610 also includes a speaker for outputting audio signals.
[0161] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0162] Sensor assembly 614 includes one or more sensors for providing status assessments of various aspects of device 600. For example, sensor assembly 614 may detect the on / off state of device 600, the relative positioning of components such as the display and keypad of device 600, changes in the position of device 600 or a component of device 600, the presence or absence of user contact with device 600, the orientation or acceleration / deceleration of device 600, and temperature changes of device 600. Sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 614 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 614 may also include an accelerometer, a gyroscope, a magnetometer, a pressure sensor, or a temperature sensor.
[0163] Communication component 616 is configured to facilitate wired or wireless communication between device 600 and other devices. Device 600 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 616 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 616 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0164] In an exemplary embodiment, the apparatus 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the data processing method described above.
[0165] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, which can be executed by a processor 620 of the device 600 to complete the data processing method described above. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0166] Figure 7This is a block diagram illustrating an apparatus 700 for data processing according to an exemplary embodiment. For example, apparatus 700 may be provided as a server. (Refer to...) Figure 7 The apparatus 700 includes a processing component 722, which further includes one or more processors, and memory resources represented by memory 732 for storing instructions, such as computer program products, that can be executed by the processing component 722. The computer program products stored in memory 732 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 722 is configured to execute instructions to perform the aforementioned data processing method.
[0167] Device 700 may also include a power supply component 726 configured to perform power management of device 700, a wired or wireless network interface 750 configured to connect device 700 to a network, and an input / output (I / O) interface 758. Device 700 may operate on an operating system stored in memory 732, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.
[0168] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.
[0169] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A data processing method, characterized in that, include: In response to a request to distribute virtual items to a target user account, the system obtains the item identifier, expiration time, and quantity of the virtual items to be distributed to the target user account; the expiration time is a fixed point in time within the time period corresponding to the expected expiration time of the virtual items to be distributed to the target user account. Obtain at least one target item record corresponding to the target user account. Each target item record includes: target item identifier, target expiration time, and target item quantity. The target item quantity is the number of virtual items in the target user account whose item identifier is the target item identifier and whose expiration time is the target expiration time. Based on the pending expiration time and the pending item identifier, determine whether the at least one target item record includes a matching item record, wherein the target item identifier in the matching item record is the same as the pending item identifier, and the target expiration time in the matching item record is the same as the pending expiration time; If the matching item record is included in at least one target item record, the quantity of the target item in the matching item record is updated according to the quantity of items to be distributed.
2. The method according to claim 1, characterized in that, The expiration time is a fixed point in time within a time period; Obtaining the expiration time of the virtual items to be distributed to the target user account includes: Obtain the expected expiration time of the virtual items to be distributed to the target user's account; Determine the time period to which the expected expiration time belongs; The fixed time point within the time period is determined as the expiration time to be issued.
3. The method according to claim 1, characterized in that, The target item record includes the identifier of the target user account; If the matching item record is not included in the at least one target item record, the method further includes: Obtain the identifier of the target user account; Based on the identifier of the target user account, the identifier of the item to be distributed, and the expiration time of the item to be distributed, an initial item record is generated, and the quantity of the item in the initial item record is 0; Lock and read the initialization item record; Based on the quantity to be issued, update the quantity of items in the initial item record to obtain a new item record, and unlock and read the new item record.
4. The method according to claim 1, characterized in that, The target item record includes the identifier of the target user account; The step of obtaining at least one target item record corresponding to the target user account includes: Obtain the identifier of the target user account; Based on the identifier of the target user account, determine the target data table for storing the records of the target items; Based on the identifier of the target user account, read the at least one target item record from the target data table.
5. The method according to claim 1, characterized in that, Also includes: In response to a virtual item display request from the target user account, at least one target item record corresponding to the target user account is obtained; The quantity of each type of virtual item is determined based on the quantity of each of the target items contained in at least one target item record with the same target item identifier, wherein the item identifiers of the virtual items belonging to the same type are the same; Based on the target expiration time contained in at least one target item record with the same target item identifier, the display expiration time of each virtual item is determined; Based on the item identifier, quantity, and expiration time to be displayed for each virtual item, a display instruction is generated and sent to the client of the target user account. The display instruction is used to instruct the client to aggregate and display each virtual item according to the item identifier and quantity, and to display the quantity and expiration time to be displayed for each virtual item.
6. The method according to claim 5, characterized in that, The virtual item display request for the target user account includes information about the display page; it also includes: Obtain information from the displayed page; The step of generating a display instruction based on the item identifier, quantity, and expiration time to be displayed for each virtual item includes: Based on the information on the display page, virtual items that do not match the display page are filtered to obtain filtered virtual items; A filtered display instruction is generated based on the item identifier, quantity, and expiration time to be displayed for each of the filtered virtual items.
7. The method according to claim 5, characterized in that, The step of determining the display expiration time of each virtual item based on the target expiration time contained in at least one target item record with the same target item identifier includes: Based on the expiration time of each of the virtual items belonging to the same type, at least one of the target item records with the same target item identifier is used to determine the expiration time of each of the target expiration time. The expiration time of each virtual item to be displayed is determined based on the expiration time of each virtual item belonging to the same category.
8. The method according to any one of claims 1-7, characterized in that, Also includes: In response to the start of a scheduled cleanup task, it iterates through each item record; The expired item record is determined based on the expiration time and the quantity of the item included in the item record; Delete the expired item records in batches.
9. A data processing apparatus, characterized in that, include: The acquisition module is configured to, in response to a request to distribute virtual items to a target user account, acquire the item identifier to be distributed, the expiration time to be distributed, and the quantity of virtual items to be distributed to the target user account; the expiration time to be distributed is a fixed point in time within the time period corresponding to the expected expiration time of the virtual items to be distributed to the target user account. The record acquisition module is configured to acquire at least one target item record corresponding to the target user account. One target item record includes: target item identifier, target expiration time, and target item quantity. The target item quantity is the number of virtual items in the target user account whose item identifier is the target item identifier and whose expiration time is the target expiration time. The determination module is configured to determine, based on the pending expiration time and the pending item identifier, whether the at least one target item record includes a matching item record, wherein the target item identifier in the matching item record is the same as the pending item identifier, and the target expiration time in the matching item record is the same as the pending expiration time; The update module is configured to update the quantity of the target item in the matching item record according to the quantity of the items to be distributed, when the matching item record is included in the at least one target item record.
10. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the data processing method as described in any one of claims 1 to 8.
11. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the data processing method as described in any one of claims 1 to 8.