Method and apparatus for generating virtual resource list, electronic device, and storage medium
By combining synchronous and asynchronous storage methods in ultra-large live streaming rooms, the problem of inconsistent information in the virtual resource list is solved, realizing real-time display and efficient response of the virtual resource list, which is suitable for the virtual resource list generation system of ultra-large live streaming rooms.
Patent Information
- Application Number
- CN202210614516.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-05-27
AI Technical Summary
In a large live streaming room, when users view the list of virtual resources, they may encounter issues such as the virtual resource information not being displayed or the list being empty. This is especially true under high-concurrency request conditions, where the time difference caused by asynchronous storage leads to inconsistencies in information.
The virtual resource list is stored using a combination of synchronous and asynchronous methods. User accounts are distinguished based on the number of online users. Some data is stored asynchronously, while other data is stored synchronously. Missing data is inserted in real time when an access request is received. Redis database and local caching are used to improve response speed.
Ensuring that the virtual resource list stores all users' target data and avoiding an empty list improves response speed and data consistency, meeting users' real-time access needs.
Smart Images

Figure CN117176971B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of Internet technology, and in particular to a method, apparatus, electronic device, and storage medium for generating a virtual resource list. Background Technology
[0002] In scenarios where virtual resources are distributed, users typically view a virtual resource list after acquiring them. This list displays the user accounts that acquired the virtual resources and the corresponding quantity of virtual resources, arranged in descending order of quantity. In large live streaming rooms, due to the large number of users acquiring virtual resources, the instantaneous concurrent request volume for the virtual resource acquisition interface becomes extremely high. Therefore, a synchronous method cannot be used to store the user accounts and corresponding virtual resource quantities in the virtual resource list.
[0003] In related technologies, user accounts that acquire virtual resources and the corresponding number of virtual resources can be stored in a virtual resource list asynchronously. However, because data is stored asynchronously, there may be a time difference between the moment a user account acquires virtual resources and the moment the data is stored in the virtual resource list. Consequently, the virtual resource information of a user account that should be stored in the virtual resource list may not be displayed when that user account views the virtual resource list, or the virtual resource list may even be empty. Summary of the Invention
[0004] This disclosure provides a method, apparatus, electronic device, and storage medium for generating a virtual resource list, to at least solve the problem in related technologies where the virtual resource information of a user account cannot be displayed when the user account views the virtual resource list, or even where the virtual resource list may be empty. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, a method for generating a virtual resource list is provided, comprising: when virtual resources are distributed in a virtual space, obtaining the number of currently online user accounts in the virtual space; when the number of currently online user accounts is greater than a preset number, storing first target data of at least one first user account for obtaining virtual resources asynchronously into a virtual resource list, and storing second target data of at least one second user account for obtaining virtual resources synchronously into the virtual resource list; wherein the first target data includes a correspondence between each first user account and the number of virtual resources obtained, and the second target data includes a correspondence between each second user account and the number of virtual resources obtained; obtaining an access request sent by a third user account, the access request being used to request access to the virtual resource list, the access request including third target data; the third target data including a correspondence between the third user account and the number of virtual resources obtained; when the virtual resource list does not include the third target data, storing the third target data in the virtual resource list; and sending the virtual resource list to the third user account.
[0006] Optionally, the method for generating the virtual resource list further includes: when the number of currently online user accounts is greater than a preset number, generating a random detection value corresponding to the user account to be stored based on a random strategy, wherein the random detection value is any value between a preset maximum threshold and a preset minimum threshold; when the random detection value is greater than a random write threshold, determining the user account to be stored as the first user account, wherein the random write threshold is determined based on the product of a preset maximum threshold and a random write ratio; and when the random detection value is less than or equal to the random write threshold, determining the user account to be stored as the second user account.
[0007] Optionally, the method for generating the virtual resource list may further include: when the number of currently online user accounts is greater than the preset number, determining the random write ratio based on the number of currently online user accounts and the preset number of concurrent requests.
[0008] Optionally, the above-mentioned "storing the second target data of at least one second user account of the obtained virtual resources to the virtual resource list in a synchronous manner" includes: when the synchronous write condition is met, storing the second target data of at least one second user account of the obtained virtual resources to the virtual resource list in a synchronous manner, wherein the synchronous write condition is: the current device resource capacity determined based on the preset token bucket algorithm is less than the preset device resource capacity; the above method further includes: when the synchronous write condition is not met, re-determining at least one second user account as a first user account.
[0009] Optionally, the above-mentioned "storing the first target data of at least one first user account of the obtained virtual resources to the virtual resource list asynchronously" includes: generating an asynchronous write request message corresponding to the first target data, the asynchronous write request message being used to request that the first target data be stored in the virtual resource list; adding the asynchronous write request message to a message queue; and processing the asynchronous write request message in the message queue according to the message processing mechanism to store the first target data in the virtual resource list.
[0010] Optionally, the above method for generating the virtual resource list further includes: according to a preset time interval, starting from the data record with the smallest number of virtual resources in the virtual resource list, deleting a random number of data records, and ensuring that the number of data records in the virtual resource list is greater than the preset number of records.
[0011] Optionally, in the above method for generating the virtual resource list, the virtual resource list is stored in a queue Redis database; the above method for generating the virtual resource list further includes: determining whether the virtual resource list is saved in the local cache; if the virtual resource list is saved in the local cache, retrieving the virtual resource list from the local cache; if the virtual resource list is not saved in the local cache, retrieving the virtual resource list from the Redis database.
[0012] Optionally, the method for generating the virtual resource list may further include: loading the virtual resource list from the Redis database into the local cache at preset time intervals.
[0013] Optionally, the above method for generating the virtual resource list further includes: when virtual resources are distributed in the virtual space, after obtaining the number of currently online user accounts in the virtual space, if the number of currently online user accounts is less than or equal to a preset number, storing the fourth target data of the fourth user account for obtaining virtual resources in the virtual resource list through synchronization, wherein the fourth target data includes the correspondence between the fourth user account and the number of virtual resources obtained.
[0014] Optionally, the method for generating the above virtual resource list also includes:
[0015] Based on the resource processing application programming interface (API), the number of currently online user accounts in the virtual space is obtained; if the number of currently online user accounts is greater than a preset number, the first target data is stored asynchronously in the virtual resource list; the second target data is stored synchronously in the virtual resource list.
[0016] Based on the resource list API, obtain the access request sent by the third user account; store the third target data in the virtual resource list; and send the virtual resource list to the third user account.
[0017] According to a second aspect of the present disclosure, an apparatus for generating a virtual resource list is provided, comprising: an acquisition unit, a storage unit, and a sending unit; the acquisition unit is configured to acquire the number of currently online user accounts in a virtual space when virtual resources are distributed in the virtual space; the storage unit is configured to, when the number of currently online user accounts acquired by the acquisition unit is greater than a preset number, asynchronously store first target data of at least one first user account that has acquired virtual resources into the virtual resource list, and synchronously store second target data of at least one second user account that has acquired virtual resources into the virtual resource list; wherein, the first target data includes a correspondence between each first user account and the number of acquired virtual resources, and the second target data includes a correspondence between each second user account and the number of acquired virtual resources; the acquisition unit is further configured to acquire an access request sent by a third user account, the access request being used to request access to the virtual resource list stored in the storage unit, the access request including third target data; the third target data including a correspondence between a third user account and the number of acquired virtual resources; the storage unit is further configured to store the third target data in the virtual resource list when the virtual resource list does not include the third target data acquired by the acquisition unit; and the sending unit is configured to send the virtual resource list stored in the storage unit to the third user account.
[0018] Optionally, the above-mentioned virtual resource list generation device further includes: a generation unit and a determination unit; the generation unit is used to generate a random detection value corresponding to the user account to be stored according to a random strategy when the number of currently online user accounts is greater than a preset number, wherein the random detection value is any value between a preset maximum threshold and a preset minimum threshold; the determination unit is used to determine the user account to be stored as a first user account when the random detection value generated by the generation unit is greater than a random write threshold, wherein the random write threshold is determined according to the product of a preset maximum threshold and a random write ratio; the determination unit is also used to determine the user account to be stored as a second user account when the random detection value generated by the generation unit is less than or equal to the random write threshold.
[0019] Optionally, the above-mentioned virtual resource list generation device further includes: a determining unit, which is further configured to determine the random write ratio based on the number of currently online user accounts and the preset number of concurrent requests when the number of currently online user accounts is greater than the preset number.
[0020] Optionally, the storage unit in the aforementioned virtual resource list generation device is specifically used for: storing the second target data of at least one second user account that has obtained virtual resources into the virtual resource list in a synchronous manner when the synchronous write condition is met, wherein the synchronous write condition is: the current device resource capacity determined based on the preset token bucket algorithm is less than the preset device resource capacity; the aforementioned virtual resource list generation device further includes: a determining unit, which is further used for re-determining at least one second user account as a first user account when the synchronous write condition is not met.
[0021] Optionally, the storage unit in the aforementioned virtual resource list generation device is further configured to: generate an asynchronous write request message corresponding to the first target data, wherein the asynchronous write request message is used to request the storage of the first target data into the virtual resource list; add the asynchronous write request message to a message queue; and process the asynchronous write request message in the message queue according to a message processing mechanism to store the first target data into the virtual resource list.
[0022] Optionally, the above-mentioned virtual resource list generation device further includes: a deletion unit; the deletion unit is also used to delete a random number of data records in the virtual resource list stored in the storage unit, starting from the data record with the smallest number of virtual resources, according to a preset time interval, and to ensure that the number of data records in the virtual resource list is greater than the preset number of records.
[0023] Optionally, the virtual resource list in the above-mentioned virtual resource list generation device is stored in a queue Redis database; the above-mentioned virtual resource list generation device further includes: a judging unit; the judging unit is used to judge whether the virtual resource list is saved in the local cache; the obtaining unit is further used to obtain the virtual resource list from the local cache if the virtual resource list is saved in the local cache; the obtaining unit is further used to obtain the virtual resource list from the Redis database if the virtual resource list is not saved in the local cache.
[0024] Optionally, the above-mentioned virtual resource list generation device further includes: a loading unit; the loading unit is used to load the virtual resource list stored in the storage unit of the Redis database into the local cache according to a preset time interval.
[0025] Optionally, the above-mentioned virtual resource list generation device further includes: a storage unit, which is also used to, when the acquisition unit distributes virtual resources in the virtual space, after acquiring the number of currently online user accounts in the virtual space, if the number of currently online user accounts is less than or equal to a preset number, store the fourth target data of the fourth user account of the virtual resources in the virtual resource list through a synchronization method, the fourth target data including the correspondence between the fourth user account and the number of virtual resources acquired.
[0026] Optionally, the aforementioned virtual resource list generation device further includes: obtaining the number of currently online user accounts in the virtual space based on the resource processing application programming interface (API); if the number of currently online user accounts is greater than a preset number, storing the first target data asynchronously into the virtual resource list; storing the second target data synchronously into the virtual resource list; obtaining access requests sent by a third user account based on the resource list API; storing the third target data into the virtual resource list; and sending the virtual resource list to the third user account.
[0027] 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 a method for generating a virtual resource list as provided in the first aspect and any possible design thereof.
[0028] According to a fourth aspect of the present disclosure, a readable storage medium is provided that, when instructions in the readable storage medium are executed by a processor, enables the generation method of a virtual resource list as provided in the first aspect and any possible design thereof.
[0029] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement a method for generating a virtual resource list as provided in the first aspect and any possible design thereof.
[0030] The technical solution provided in this disclosure brings at least the following beneficial effects: when virtual resources are distributed in a virtual space, the current number of online users in the virtual space is obtained; then, if the number of currently online user accounts is greater than a preset number, the first target data of at least one first user account of the virtual resources is obtained and stored asynchronously in the virtual resource list, and the second target data of at least one second user account of the virtual resources is obtained and stored synchronously in the virtual resource list; an access request sent by a third user account is obtained; if the virtual resource list does not include the third target data, the third target data is stored in the virtual resource list; and the virtual resource list is sent to the third user account. Because the number of online user accounts currently exceeds the preset number, the large number of users seeking virtual resources leads to a very high instantaneous concurrent request volume for the virtual resource acquisition interface, making it difficult to handle uniformly using a synchronous method. This disclosure employs a combination of synchronous and asynchronous methods to write the virtual resource list. This ensures that the virtual resource list contains synchronously stored second target data. When a third user account initiates an access request to the virtual resource list, the virtual resource list displays and stores the second target data, preventing the virtual resource list from being empty. Furthermore, the virtual resource list also includes asynchronously stored first target data to ensure that the target data corresponding to all user accounts is saved, preventing the loss of target data for some user accounts. Moreover, by inserting the third target data corresponding to the third user account into the virtual resource list in real time, this disclosure can return a virtual resource list including the third target data to the third user account in real time. This ensures that even if the third user account is identified as the first user account, the third target data can still be stored in the virtual resource list to meet the actual needs of the third user account's access request.
[0031] 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
[0032] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0033] Figure 1 This is a schematic diagram illustrating the structure of a virtual resource list generation system according to an exemplary embodiment;
[0034] Figure 2 This is a flowchart illustrating one of a method for generating a virtual resource list according to an exemplary embodiment;
[0035] Figure 3This is a second flowchart illustrating a method for generating a virtual resource list according to an exemplary embodiment;
[0036] Figure 4 This is a third flowchart illustrating a method for generating a virtual resource list according to an exemplary embodiment;
[0037] Figure 5 This is one of the schematic diagrams illustrating a process for obtaining a list of virtual resources according to an exemplary embodiment;
[0038] Figure 6 This is a second schematic diagram illustrating a process for obtaining a list of virtual resources according to an exemplary embodiment;
[0039] Figure 7 This is a schematic diagram illustrating a virtual resource list according to an exemplary embodiment;
[0040] Figure 8 This is a schematic diagram illustrating a process for determining a user account type according to an exemplary embodiment;
[0041] Figure 9 This is a schematic diagram illustrating a process for synchronously storing second target data according to an exemplary embodiment;
[0042] Figure 10 This is a schematic diagram illustrating an asynchronous storage process for second target data according to an exemplary embodiment;
[0043] Figure 11 This is a schematic diagram of an application programming interface corresponding to a method for generating a virtual resource list according to an exemplary embodiment;
[0044] Figure 12 This is one of the schematic block diagrams illustrating a process for generating a virtual resource list according to an exemplary embodiment;
[0045] Figure 13 This is a second schematic block diagram illustrating a process for generating a virtual resource list according to an exemplary embodiment;
[0046] Figure 14 This is a block diagram illustrating a virtual resource list generation apparatus according to an exemplary embodiment;
[0047] Figure 15 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment. Detailed Implementation
[0048] 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.
[0049] 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.
[0050] It should be noted that the user information (including but not limited to user device information, user personal information, user behavior information, etc.) and data (including but not limited to the number of virtual resources, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0051] Furthermore, in the description of the embodiments of this disclosure, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. The term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, in the description of the embodiments of this disclosure, "multiple" refers to two or more.
[0052] Red envelopes are a form of virtual resource. In a red envelope grabbing scenario, after grabbing a red envelope, users typically view a "best luck list." This list includes the account ID of the user who grabbed the red envelope and the corresponding red envelope amount, arranged in descending order of amount. In a large live stream, due to the large number of user accounts grabbing red envelopes, the instantaneous concurrent request volume of the red envelope grabbing interface becomes extremely high. Therefore, a synchronous method cannot be used to store the user account that won the red envelope and its corresponding amount in the "best luck list."
[0053] In related technologies, the account identifier and corresponding amount of the user account that received the red envelope are stored in the best luck list in an asynchronous manner. However, because the data is stored asynchronously, there may be a time difference between the moment the user account receives the red envelope and the moment it is stored in the best luck list. As a result, the red envelope information of the user account that should be stored in the best luck list may not be displayed when the user account views the best luck list, and the best luck list may even be empty.
[0054] The present disclosure provides a method for generating a virtual resource list, which can be applied to a virtual resource list generation system. Figure 1A schematic diagram of the structure of the system for generating this virtual resource list is shown. For example... Figure 1 As shown, the virtual resource list generation system addresses the issue in related technologies where a user account's virtual resource information is not displayed when viewing the virtual resource list, or even where the virtual resource list is empty. The virtual resource list generation system includes a first device 11 and a second device 12. The first device 11 is connected to the second device 12.
[0055] The first device 11 can be used to interact with the second device 12. For example, the first device 11 can be equipped with a client. The first device 11 can obtain the issued virtual resources through the client, and can also send virtual resource acquisition requests and virtual resource list access requests to the second device 12 through the client, and receive information such as the virtual resource list from the second device 12.
[0056] In this embodiment of the disclosure, the first device 11 may further include or be connected to a database, and the aforementioned virtual resource list may be stored in the database. The first device 11 can perform access operations on the virtual resource list in the database.
[0057] In this embodiment, the first device 11 may be a personal smart device such as a mobile phone, smartwatch, camera, tablet computer, augmented reality (AR), virtual reality (VR), etc., or it may be an electronic device such as a laptop computer, desktop computer, television, etc., or it may be other electronic devices that can capture, display or store virtual resource lists. There are no restrictions on the device form of the first device 11.
[0058] In this embodiment, the second device 12 may be a server, a mobile phone, a tablet computer or other personal smart device, or it may be a laptop computer, a handheld computer, a desktop computer, an ultra-mobile personal computer (UMPC) or other electronic device, or it may be other electronic devices that can store and process virtual resource lists. There are no restrictions on the device form of the second device 12.
[0059] For example, if the second device 12 is a server, then the second device 12 can be a data server for Internet platforms such as short video application service platforms, news service platforms, live streaming service platforms, shopping service platforms, food delivery service platforms, sharing service platforms, and functional websites.
[0060] In the embodiments disclosed herein, the first device 11 and the second device 12 may have the same device form. For example, the first device 11 and the second device 12 may both be mobile phones, or both may both be tablet computers. In other embodiments, the first device 11 and the second device 12 may have different device forms.
[0061] Optionally, the first device 11 and the second device 12 can be connected via wired or wireless means. For example, the wireless communication protocol used between the first device 11 and the second device 12 can be Wi-Fi, Bluetooth, ZigBee, Near Field Communication (NFC), various cellular network protocols, etc., and there are no restrictions on this.
[0062] It should be noted that the first device 11 and the second device 12 can be independent devices or integrated into the same device; this invention does not specifically limit this. When the first device 11 and the second device 12 are integrated into the same device, the communication method between the first device 11 and the second device 12 is the communication between internal modules of that device. In this case, the communication process between the two is the same as that when the first device 11 and the second device 12 are independent, the communication process between them is the same.
[0063] The method for generating a virtual resource list provided in this application embodiment can be applied to an electronic device, which can be the first device or the second device described above. The list generation method includes: when virtual resources are distributed in a virtual space, obtaining the number of currently online user accounts in the virtual space; if the number of currently online user accounts is greater than a preset number, storing first target data of at least one first user account for the obtained virtual resources asynchronously in the virtual resource list, and storing second target data of at least one second user account for the obtained virtual resources synchronously in the virtual resource list; wherein, the first target data includes a correspondence between each first user account and the number of obtained virtual resources, and the second target data includes a correspondence between each second user account and the number of obtained virtual resources; obtaining an access request sent by a third user account, the access request being used to request access to the virtual resource list, the access request including third target data; the third target data including a correspondence between the third user account and the number of obtained virtual resources; if the virtual resource list does not include the third target data, storing the third target data in the virtual resource list; and sending the virtual resource list to the third user account.
[0064] The method for generating a virtual resource list provided in this disclosure will now be described with reference to the accompanying drawings. The following description uses the virtual resource list generation device as the execution subject, which can be the aforementioned electronic device, specifically the aforementioned second device, as an example to illustrate the method. Figure 2 This is a flowchart illustrating a method for generating a virtual resource list according to an embodiment of this disclosure. Figure 2 As shown, the method for generating a virtual resource list provided in this embodiment includes the following steps 201 to 205.
[0065] Step 201: When virtual resources are distributed in the virtual space, the virtual resource list generation device obtains the number of currently online user accounts in the virtual space.
[0066] In this embodiment of the disclosure, a virtual space refers to the construction of a virtual barrier within a network. User accounts that join this virtual space can access virtual resources, view real-time chat logs, view shopping links, and purchase items corresponding to those links, etc. For example, a virtual space can be a live streaming room. A streamer user account can use a first electronic device to capture, display, or store a list of virtual resources to live stream what they are doing. Other user accounts can enter this live streaming room through a website or application.
[0067] In this embodiment, virtual resources can be distributed by the broadcaster's user account or by other user accounts viewing the virtual space. Virtual resources can be red envelopes, virtual items, virtual currency, etc. It should be noted that the process of distributing virtual resources includes: splitting the virtual resources into several virtual resource units (including a pre-set number of virtual resources); then, upon receiving a virtual resource acquisition request from another user account (used to request virtual resources), and responding to the virtual resource acquisition request, randomly allocating virtual resource units.
[0068] Optionally, in this embodiment of the disclosure, the virtual resource list generation device splits the virtual resources into several virtual resource packages. Specifically, upon receiving a virtual resource distribution request, the virtual resource list generation device allocates the virtual resources according to a preset allocation strategy. The distribution request information is used to request the distribution of a preset number of virtual resources to currently online user accounts in the virtual space. The number of online user accounts refers to the total number of user accounts watching the live stream in the virtual space at a given time.
[0069] It is understood that the allocation strategy refers to how virtual resources are allocated. An average allocation method or a random allocation method can be used to divide the virtual resources into a fixed number of virtual resource units. This fixed number can be pre-set, the number of currently online user accounts, or determined based on the number of currently online user accounts; this is not limited in this embodiment.
[0070] It should be noted that the virtual resource list generation device determines the above-mentioned fixed quantity based on the number of currently online user accounts. Specifically, the fixed quantity can be determined by multiplying the preset ratio by the number of currently online user accounts, by the difference between the number of currently online users and the preset data, or by the sum of the number of currently online users and the preset data.
[0071] Optionally, in this embodiment of the disclosure, when the virtual resource list generation device receives a virtual resource acquisition request sent by a currently online user account, it responds to the virtual resource acquisition request by sending a virtual resource unit to the online user account that sent the virtual resource acquisition request.
[0072] Thus, by pre-allocating virtual resources according to the pre-defined allocation strategy, the network pressure of reallocating virtual resources in response to virtual resource acquisition requests can be reduced, thereby increasing the success rate of responding to virtual resource acquisition requests.
[0073] Step 202: When the number of currently online user accounts is greater than the preset number, the virtual resource list generation device will obtain the first target data of at least one first user account of the virtual resource and store it in the virtual resource list asynchronously, and obtain the second target data of at least one second user account of the virtual resource and store it in the virtual resource list synchronously.
[0074] In this embodiment, the first target data includes the correspondence between each first user account and the number of virtual resources obtained, and the second target data includes the correspondence between each second user account and the number of virtual resources obtained. It should be noted that when either the first user account or the second user account requests and obtains virtual resources, the first target data corresponding to the first user account or the second target data corresponding to the second user account needs to be stored in the virtual resource list. The first target data includes the account identifier, account avatar, and number of virtual resources obtained for each first user account, and may also include the login address, gender, preferences, etc., of the user account with developer permissions. The second target data is similar to the first target data and will not be described further here.
[0075] Optionally, in this embodiment of the disclosure, if the number of currently online user accounts is greater than a preset number, the virtual resource list generation device determines that the virtual space is an ultra-large virtual space, and determines, based on the determination result, to store the virtual resource-related data into the virtual resource list using synchronous and asynchronous methods.
[0076] Understandably, the preset quantity can be 10,000, 100,000, or 1 million, etc. If the virtual space is a very large virtual space, that is, if the number of currently online user accounts is large and network resources are insufficient to handle the storage problem of the virtual resource list synchronously in real time, then it is necessary to distinguish the users who have obtained virtual resources, dividing them into at least one first user account and at least one second user account. The first target data of the first user account is stored in the virtual resource list asynchronously, and the second target data of the second user account is stored in the virtual resource list synchronously.
[0077] In this embodiment of the disclosure, since the virtual resource list is written using both synchronous and asynchronous methods, there is second target data written in real time in the virtual resource list, so that the virtual resource list can display some of the relevant data of the obtained virtual resources.
[0078] Optionally, in this embodiment of the disclosure, in Figure 2 Based on the method shown, such as Figure 3 As shown, the method for generating the virtual resource list also includes the following step 301.
[0079] Step 301: When the number of currently online user accounts is less than or equal to the preset number, the virtual resource list generation device will obtain the fourth target data of the fourth user account of the virtual resource and store it in the virtual resource list through synchronization.
[0080] In this embodiment of the disclosure, the fourth target data includes the correspondence between a fourth user account and the amount of virtual resources obtained. The fourth user account is any account among the currently online user accounts.
[0081] It should be noted that if the number of currently online user accounts is less than or equal to the preset number, that is, all currently online user accounts simultaneously request and obtain virtual resources, i.e., the number of fourth user accounts is the same as the number of currently online user accounts, the device resource capacity is sufficient to support storing the fourth target data corresponding to the above-mentioned fourth user accounts into the virtual resource list in a synchronous manner.
[0082] The technical solution provided in this disclosure brings at least the following benefits: based on the number of currently online user accounts, if the device resource capacity is sufficient, the fourth target data is stored in the virtual resource list when using the synchronization method, so as to improve the real-time performance of the virtual resource list.
[0083] Optionally, in this embodiment of the disclosure, in Figure 2 Based on the method shown, such as Figure 4 As shown, the method for generating the virtual resource list also includes the following step 401.
[0084] Step 401: The virtual resource list generation device deletes a random number of data records from the virtual resource list, starting with the data record with the smallest number of virtual resources, according to a preset time interval.
[0085] In this embodiment of the disclosure, after deleting a random number of data records, the number of data records in the virtual resource list is greater than the preset number of records, so as to ensure that the virtual resource list issued to the user can both meet the display needs of the user account and minimize the amount of data.
[0086] Understandably, the virtual resource list may include data on all user accounts that have obtained virtual resources, or it may include data on only a portion of those accounts. Especially when the number of currently online user accounts in a virtual space becomes a large live stream, the number of accounts requesting access to virtual resources could reach thousands or even tens of thousands. However, when viewing the virtual resource list, users generally focus on accounts that have obtained more virtual resources; they typically don't pay attention to accounts that have obtained fewer. Therefore, displaying data on all user accounts that have obtained virtual resources is a waste of network resources. A pre-set number of user accounts' data on virtual resources could be saved in the virtual resource list. Based on this, some data in the virtual resource list can be appropriately deleted.
[0087] Further optionally, in this embodiment of the disclosure, the above-mentioned deletion of a random number of data records can be implemented as follows: after each preset time interval, the virtual resources are arranged in descending order of quantity, and the corresponding user accounts are adaptively adjusted according to the arrangement position of the virtual resource quantities. The virtual resource list is reordered, and starting from the user account with the smallest number of virtual resources in the virtual resource list, the target data corresponding to the user account with a random number of data records is deleted, while ensuring that the number of data records in the virtual resource list is greater than the preset number of records.
[0088] In one example, the virtual resource list generation device uses the difference between the number of data records already stored in the virtual resource list and a preset number of records as an upper limit, and then randomly selects a random number of records between the upper limit and zero.
[0089] In another example, the virtual resource list generation device determines the number of random records as the difference between the number of data records already stored in the virtual resource list and the preset number of records. Since the virtual resource list is stored gradually as current online user accounts request and obtain virtual resources, storing the target number of preset records in the virtual resource list is sufficient to meet the requirements. Therefore, it is possible to set the target number of preset records to be retained each time data is deleted from the virtual resource list.
[0090] The technical solution provided in this disclosure has at least the following beneficial effects: Since user accounts with a large number of virtual resources are more likely to pay attention to them in the virtual resource list, if there is a lot of data stored in the virtual resource list, a lot of network resources will be consumed in the process of rearranging the virtual resource list and loading the virtual resource list. Therefore, by deleting some data records (such as the relevant data records of user accounts with a small number of less-attended virtual resources), the display requirements of the virtual resource list can be met while reducing the consumption of network resources.
[0091] Step 203: The virtual resource list generation device obtains the access request sent by the third user account.
[0092] In this embodiment of the disclosure, the access request is used to request access to a list of virtual resources. The access request includes third target data, which includes the correspondence between a third user account and the number of virtual resources obtained. It should be noted that the third user account is an online user account in the virtual space, and the third user account can send the access request before or after obtaining the virtual resources.
[0093] In this embodiment of the disclosure, the device for generating the virtual resource list can be configured to automatically generate an access request after detecting that a third user account has obtained virtual resources, so as to display the virtual resource list on the electronic device logged into the third user account, thereby incentivizing the third user account to obtain virtual resources.
[0094] Step 204: If the virtual resource list does not include the third target data, the virtual resource list generation device stores the third target data in the virtual resource list.
[0095] Optionally, in this embodiment of the disclosure, if the third target data is stored in the virtual resource list in a synchronous manner, then when the third user account sends an access request, the third target data is included in the virtual resource list. In this case, the currently stored virtual resource list can meet the third user account's concern about the number of virtual resources, and the virtual resource list generation device can send the virtual resource list to the third user account.
[0096] Optionally, in this embodiment of the disclosure, if the third target data is stored in the virtual resource list asynchronously, and the third target data is not included in the virtual resource list when the third user account sends an access request, then the currently stored virtual resource list cannot meet the third user account's concern about the number of virtual resources. The virtual resource list generation device can store the third target data in the virtual resource list and then send the virtual resource list to the third user account.
[0097] Alternatively, the virtual resource list generation device may store the third target data in the virtual resource list. Specifically, this can be achieved by comparing the number of virtual resources obtained by the third user account with the number of virtual resources in the virtual resource list, and rearranging the virtual resource list in descending order of the number of virtual resources.
[0098] Optionally, in this embodiment of the disclosure, the virtual resource list in the above-mentioned virtual resource list generation device is stored in a queue Redis database, such as... Figure 5 As shown, before step 204 above, the method for generating the virtual resource list also includes steps 501 to 503.
[0099] Step 501: The virtual resource list generation device determines whether the virtual resource list is stored in the local cache.
[0100] Step 502: If the virtual resource list has been saved in the local cache, the virtual resource list generation device retrieves the virtual resource list from the local cache.
[0101] Step 503: If the virtual resource list is not saved in the local cache, the virtual resource list generation device retrieves the virtual resource list from the Redis database.
[0102] In this embodiment of the disclosure, the electronic device used for generating the virtual resource list includes memory and a local cache. The local cache refers to a storage device capable of high-speed data exchange, and it exchanges data with the processor before the memory. Therefore, if the virtual resource list is stored in the local cache, retrieving the virtual resource list from the local cache can improve the retrieval speed, thereby improving the speed of reprocessing the virtual resource list. It is understood that the virtual resource list generation device can search for whether the virtual resource list is stored using keywords.
[0103] Further optionally, in this embodiment of the disclosure, since the virtual resource list is pre-stored in a local cache, in order to improve the accuracy of the virtual resource list, such as... Figure 6 As shown, in Figure 5 Based on the above, the method for generating the virtual resource list also includes step 601.
[0104] Step 601: The virtual resource list generation device loads the virtual resource list from the Redis database into the local cache according to a preset time interval.
[0105] In this embodiment, the Redis database refers to a non-relational database that can store data based on key-value pairs, does not require structured query language parsing, and has no coupling between data, making it easy to expand. Therefore, the virtual resource list is stored in the Redis database.
[0106] In this embodiment of the disclosure, the virtual resource list is periodically loaded into the local cache according to a preset time interval. That is, the latest virtual resource list is continuously pulled into the local cache. The virtual resource list obtained through the local cache is less different from the virtual resource list stored in the Redis database, thereby improving the accuracy of the virtual resource list obtained through the local cache.
[0107] The technical solution provided in this disclosure has at least the following beneficial effects: by loading the virtual resource list into the local cache according to a preset time interval, the virtual resource list stored in the local cache is more consistent with the real-time virtual resource list, thereby improving the accuracy of the obtained virtual resource list.
[0108] In this embodiment of the disclosure, since the virtual resource list may not have been stored in the local cache when the access request is obtained, the virtual resource list can be obtained directly from the Redis database.
[0109] The technical solution provided in this disclosure brings at least the following beneficial effects: by retrieving the virtual resource list from the local cache, the speed of retrieving the virtual resource list can be improved, thereby improving the response speed to access requests from third-party user accounts and reducing the waiting time of third-party user accounts. Furthermore, by retrieving the virtual resource list from the Redis database, it is ensured that the virtual resource list can be retrieved and that access requests sent by third-party user accounts can be responded to.
[0110] Step 205: The virtual resource list generation device sends the virtual resource list to the third user account.
[0111] In this embodiment of the disclosure, the electronic device logged into a third user account, upon receiving the virtual resource list, such as... Figure 7 As shown, a list of virtual resources is displayed on the screen of the electronic device.
[0112] The technical solution provided in this disclosure offers at least the following advantages: Since the number of online user accounts exceeds the preset number, the large number of users accessing virtual resources leads to a very high instantaneous concurrent request volume for the virtual resource access interface, making it difficult to handle synchronously. This disclosure employs a combination of synchronous and asynchronous methods to write to the virtual resource list. This ensures that the virtual resource list contains synchronously stored second target data. When a third user account initiates an access request to the virtual resource list, the virtual resource list displays the stored second target data, preventing the virtual resource list from being empty. Furthermore, the virtual resource list also includes asynchronously stored first target data to ensure that the target data corresponding to all user accounts is saved, preventing the loss of target data for some user accounts. Moreover, by inserting the third target data corresponding to the third user account into the virtual resource list in real time, this disclosure can return a virtual resource list containing the third target data to the third user account in real time. This ensures that even if the third user account is identified as the first user account, the third target data can still be stored in the virtual resource list to meet the actual needs of the third user account's access request.
[0113] Optionally, in embodiments of this disclosure, such as Figure 8 As shown, prior to step 202 above, the method for generating the virtual resource list provided in this disclosure may further include steps 801 to 803.
[0114] Step 801: When the number of currently online user accounts is greater than the preset number, the virtual resource list generation device generates random detection values corresponding to the user accounts to be stored based on a random strategy.
[0115] Step 802: When the random detection value is greater than the random write threshold, the virtual resource list generation device determines the user account to be stored as the first user account.
[0116] Step 803: If the random detection value is less than or equal to the random write threshold, the virtual resource list generation device determines the user account to be stored as the second user account.
[0117] In this embodiment of the disclosure, the random detection value is any value between the preset maximum threshold and the preset minimum threshold, and the random write threshold is determined based on the product of the preset maximum threshold and the random write ratio.
[0118] In one example, assuming that random detection values need to be generated for 100 user accounts to be stored, the preset maximum threshold can be set to 100, the preset minimum threshold can be set to 1, and the random detection value of 80, which is between 1 and 100, can be randomly selected. After the random detection value is generated, the random detection value corresponding to other user accounts to be stored cannot be 80.
[0119] In another example, suppose we need to generate random detection values for 100 user accounts to be stored. We can set the preset maximum threshold to 50 and the preset minimum threshold to 1. We can randomly select a value of 20 between 1 and 50. Since the number of user accounts to be stored is greater than the number of random detection values that can be selected, after the random detection values are generated, there will still be a value of 20 among the random detection values corresponding to the other user accounts to be stored.
[0120] In this embodiment of the disclosure, based on the above-described random detection value selection method, the random detection value can be compared with the random write threshold to determine whether the user account to be stored is the first user account or the second user account, that is, whether to use synchronous or asynchronous methods for data storage.
[0121] Further optional, in embodiments of this disclosure, such as Figure 8 As shown, step 202 above may include step 804 below.
[0122] Step 804: When the number of currently online user accounts is greater than the preset number, the virtual resource list generation device determines the random write ratio based on the number of currently online user accounts and the preset number of concurrent requests.
[0123] For example, suppose there are 100,000 currently online user accounts in the live broadcast room, but the current network can receive 10,000 pre-set concurrent requests, then the random write ratio is 10%.
[0124] In this embodiment of the disclosure, the random write threshold is determined based on the product of a preset maximum threshold and a random write ratio. For example, if the preset maximum threshold is 100 and the random write ratio is 10%, then when the random detection value is less than or equal to 10, the user account to be stored is determined as the second user account, and when the random detection value is greater than 10, the user account to be stored is determined as the first user account.
[0125] In this embodiment, if the number of currently online user accounts is 100, then the 100 values from 1 to 100 are determined as random detection values corresponding to the user accounts to be stored. If the number of currently online user accounts is greater than 100, then the correspondence between the number of currently online user accounts and the threshold difference (the difference between a preset maximum threshold and a preset minimum threshold) is determined, and the 100 values from 1 to 100 are determined as random detection values corresponding to the user accounts to be stored. For example, if the number of currently online user accounts is 2000, which is 20 times 100, then each value from 1 to 100 can be repeated 20 times, and these 2000 values are determined as random detection values corresponding to the user accounts to be stored.
[0126] The technical solution provided in this disclosure brings at least the following beneficial effects: by determining the random write ratio, the user account to be stored can be identified as the second user account when the device resource capacity allows, so as to increase the amount of second target data stored synchronously and improve the speed of storing the virtual resource-related attributes corresponding to the online user account to the virtual resource list.
[0127] The technical solution provided in this disclosure brings at least the following beneficial effects: by allocating random detection values and comparing the random detection values with random write thresholds, the user accounts to be stored are determined as the first user account and the second user account. This balances the quantity relationship between the first user account that uses asynchronous storage and the second user account that uses synchronous storage, ensuring that the relevant data of virtual resources are stored in the virtual resource list and responding to access requests from third user accounts to access the virtual resource list.
[0128] Optionally, in embodiments of this disclosure, such as Figure 9 As shown, step 202 of the above method for generating a virtual resource list, "the second target data of at least one second user account of the virtual resource is obtained and stored in the virtual resource list in a synchronous manner", can also be implemented by step 901 below.
[0129] Step 901: When the synchronous writing conditions are met, the virtual resource list generation device will obtain the second target data of at least one second user account of the virtual resource and store it in the virtual resource list in a synchronous manner.
[0130] Based on step 901 above, the method for generating a virtual resource list provided in this embodiment of the disclosure further includes:
[0131] Step 902: If the synchronous write conditions are not met, the virtual resource list generation device will re-identify at least one second user account as the first user account.
[0132] In this embodiment, the synchronous write condition is that the current device resource capacity, determined based on a preset token bucket algorithm, is less than a preset device resource capacity. The preset token bucket algorithm is a commonly used algorithm in network traffic shaping and rate limiting, used to control the number of synchronous write operations. Device resource capacity includes network status, data processing status, and pending processes, etc.
[0133] It should be noted that, in theory, if the user account to be stored is determined to be the second user account, the second target data can be stored in the virtual resource list synchronously. However, in practice, due to the limitation of device resource capacity, it may not be possible to store the second target data in real time synchronously. Therefore, before storing the second target data synchronously, a fallback rate limiting protection method can be set up through a pre-set token bucket algorithm.
[0134] In this embodiment of the disclosure, a synchronous write operation refers to generating a synchronous write operation for storing the second target data after determining that the second target data will be stored synchronously.
[0135] The technical solution provided in this disclosure brings at least the following benefits: by using a pre-set token bucket algorithm, a fallback rate limiting protection is achieved to ensure that the second target data is stored in the virtual resource list in a synchronous manner.
[0136] Optionally, in embodiments of this disclosure, such as Figure 10 As shown, step 202 of the above method for generating a virtual resource list, "obtaining the first target data of at least one first user account of the virtual resource and storing it in the virtual resource list asynchronously", can also be implemented through steps 1001 to 1003 below.
[0137] Step 1001: The virtual resource list generation device generates an asynchronous write request message corresponding to the first target data.
[0138] Step 1002: The virtual resource list generation device will asynchronously write the request message and add it to the message queue.
[0139] Step 1003: The virtual resource list generation device processes the asynchronous write request messages in the message queue according to the message processing mechanism and stores the first target data in the virtual resource list.
[0140] In this embodiment of the disclosure, the asynchronous write request message is used to request the storage of the first target data into the virtual resource list. It should be noted that each asynchronous write request message corresponds one-to-one with a first user account.
[0141] In this embodiment of the disclosure, the message queue is a container for storing messages during message transmission. The message processing mechanism can be a first-in-first-out (FIFO) mechanism, that is, asynchronous write request messages stored in the message queue are processed sequentially in a FIFO manner, and the first target data is stored in the virtual resource list asynchronously.
[0142] It should be noted that asynchronous mode refers to a storage time difference between determining when to store the first target data in the virtual resource list and the actual time to store the first target data in the virtual resource list, which is greater than a preset time difference. Synchronous mode refers to a storage time difference between determining when to store the first target data in the virtual resource list and the actual time to store the first target data in the virtual resource list, which is less than or equal to a preset time difference. Of course, theoretically, the above storage time difference can be zero.
[0143] The technical solution provided in this disclosure brings at least the following beneficial effects: In the process of storing the first target data into the virtual resource list in an asynchronous manner, a message queue mechanism is added to ensure that all the first target data can be written into the virtual resource list.
[0144] Optionally, in this embodiment of the disclosure, the method for generating the virtual resource list further includes: obtaining the number of currently online user accounts in the virtual space based on the resource processing API; if the number of currently online user accounts is greater than a preset number, storing the first target data asynchronously into the virtual resource list; storing the second target data synchronously into the virtual resource list; obtaining the access request sent by the third user account based on the resource list API; storing the third target data into the virtual resource list; and sending the virtual resource list to the third user account.
[0145] Optionally, in embodiments of this disclosure, such as Figure 11 As shown, the above method for generating a virtual resource list can also be applied to electronic devices, which include: a resource processing API and a resource list API; the resource processing API is used to determine the number of currently online user accounts in the virtual space; if the number of currently online user accounts is greater than a preset number, the first target data is stored asynchronously in the virtual resource list; the second target data is stored synchronously in the virtual resource list; the resource list API is used to obtain access requests sent by a third user account; the third target data is stored in the virtual resource list; and the virtual resource list is sent to the third user account.
[0146] In the embodiments disclosed herein, such as Figure 12 As shown, the resource processing API (red envelope grabbing API) not only responds to requests for virtual resources from user accounts to be stored based on the virtual resource acquisition logic, but also generates a list of virtual resources. During the generation of the virtual resource list, the API executes relevant virtual resource list generation strategies based on the number of currently online user accounts in the virtual space and the concurrency pressure of the Redis cluster. The resource processing API also implements extended methods for the above steps.
[0147] In the embodiments disclosed herein, such as Figure 13 As shown, based on the access request from the third user account to access the virtual resource list, and the third user account's third target data, the resource list API (Access Best Luck List APP) sends the virtual resource list to the third user account. The resource list API is also used to implement extended methods of the above steps.
[0148] The technical solution provided in this disclosure brings at least the following benefits: the method of generating virtual resource lists through the resource processing API can reduce the pressure on the resource list API and increase the speed of sending virtual resource lists to third-party user accounts.
[0149] The foregoing primarily describes the solutions of the embodiments of this disclosure from a methodological perspective. It is understood that the virtual resource list generation apparatus, in order to achieve the above-mentioned functions, includes at least one of the hardware structures and software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.
[0150] This disclosure embodiment can divide the virtual resource list generation device into functional units according to the above method example. For example, each function can be divided into a separate functional unit, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software functional unit. It should be noted that the unit division in this disclosure embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0151] Figure 14 This is a schematic diagram illustrating the structure of a virtual resource list generation apparatus according to an exemplary embodiment. (Refer to...) Figure 14 As shown, the virtual resource list generation apparatus provided in this embodiment includes: an acquisition unit 1401, a storage unit 1402, and a sending unit 1403;
[0152] The acquisition unit 1401 is used to acquire the number of currently online user accounts in a virtual space when virtual resources are distributed in the virtual space; for example, such as Figure 2 As shown, the acquisition unit 1401 can be used to perform step 201.
[0153] Storage unit 1402 is configured to, when the number of currently online user accounts acquired by acquisition unit 1401 exceeds a preset number, asynchronously store first target data of at least one first user account acquiring virtual resources into a virtual resource list, and synchronously store second target data of at least one second user account acquiring virtual resources into the virtual resource list; wherein, the first target data includes a correspondence between each first user account and the number of virtual resources acquired, and the second target data includes a correspondence between each second user account and the number of virtual resources acquired; for example... Figure 2 As shown, storage unit 1402 can be used to perform step 202.
[0154] The acquisition unit 1401 is further configured to acquire an access request sent by a third user account. The access request requests access to a list of virtual resources stored in the storage unit, and includes third target data. The third target data includes the correspondence between the third user account and the number of virtual resources acquired. Figure 2 As shown, the acquisition unit 1401 can be used to perform step 203.
[0155] Storage unit 1402 is further configured to store the third target data into the virtual resource list when the virtual resource list does not include the third target data acquired by acquisition unit 1401; such as Figure 2 As shown, storage unit 1402 can be used to perform step 204.
[0156] Sending unit 1403 is used to send the list of virtual resources stored in storage unit 1402 to a third user account. For example... Figure 2 As shown, the sending unit 1403 can be used to perform step 205.
[0157] Optional, such as Figure 14 As shown, the above-mentioned virtual resource list generation device further includes: a generation unit 1404 and a determination unit 1405;
[0158] Generation unit 1404 is used to generate random detection values corresponding to user accounts to be stored, based on a random strategy, when the number of currently online user accounts exceeds a preset number. The random detection values are any values between a preset maximum threshold and a preset minimum threshold. Figure 8 As shown, the generation unit 1404 can be used to perform step 801.
[0159] The determining unit 1405 is used to determine the user account to be stored as the first user account when the random detection value generated by the generating unit 1404 is greater than the random write threshold. The random write threshold is determined based on the product of a preset maximum threshold and a random write ratio. Figure 8As shown, the determining unit 1405 can be used to perform step 802.
[0160] The determining unit 1405 is also used to determine the user account to be stored as the second user account when the random detection value generated by the generating unit 1404 is less than or equal to the random write threshold. Figure 8 As shown, the determining unit 1405 can be used to perform step 803.
[0161] Optional, such as Figure 14 As shown, the aforementioned virtual resource list generation device further includes: a determining unit 1405, which is further configured to determine a random write ratio based on the number of currently online user accounts and a preset number of concurrent requests when the number of currently online user accounts exceeds a preset number. Figure 8 As shown, the determining unit 1405 can be used to perform step 804.
[0162] Optionally, the storage unit 1402 in the aforementioned virtual resource list generation device is specifically used for: storing the second target data of at least one second user account that has obtained virtual resources into the virtual resource list synchronously when the synchronous write condition is met. The synchronous write condition is that the current device resource capacity determined based on the preset token bucket algorithm is less than the preset device resource capacity. The aforementioned virtual resource list generation device further includes: a determining unit, which is further used for re-determining at least one second user account as a first user account when the synchronous write condition is not met. Figure 9 As shown, the storage unit 1402 can be used to perform steps 901 to 902.
[0163] Optionally, the storage unit 1402 in the aforementioned virtual resource list generation device is further configured to: generate an asynchronous write request message corresponding to the first target data, the asynchronous write request message being used to request the storage of the first target data into the virtual resource list; add the asynchronous write request message to a message queue; and process the asynchronous write request message in the message queue according to a message processing mechanism to store the first target data into the virtual resource list. Figure 10 As shown, the storage unit 1402 can be used to execute steps 1001 to 1003.
[0164] Optional, such as Figure 14 As shown, the above-mentioned virtual resource list generation device further includes: a deletion unit 1406;
[0165] The deletion unit 1406 is also used to delete a random number of data records from the virtual resource list stored in the storage unit, starting with the data record with the smallest number of virtual resources, according to a preset time interval, while ensuring that the number of data records in the virtual resource list is greater than the preset number of records. For example... Figure 4As shown, the deletion unit 1406 can be used to perform step 401.
[0166] Optionally, the virtual resource list in the aforementioned virtual resource list generation device is stored in a queue Redis database; such as Figure 14 As shown, the above-mentioned virtual resource list generation device further includes: a judgment unit 1407;
[0167] Judgment unit 1407 is used to determine whether the virtual resource list is stored in the local cache; for example Figure 5 As shown, the judgment unit 1407 can be used to execute step 501.
[0168] The acquisition unit 1401 is also used to retrieve the virtual resource list from the local cache if the virtual resource list is already saved in the local cache; for example Figure 5 As shown, the acquisition unit 1401 can be used to perform step 502.
[0169] Unit 1401 is also used to retrieve the list of virtual resources from the Redis database when the list is not stored in the local cache. Figure 5 As shown, the acquisition unit 1401 can be used to perform step 503.
[0170] Optionally, the above-mentioned virtual resource list generation device further includes: a loading unit 1408;
[0171] Loading unit 1408 is used to load the list of virtual resources stored in the storage units of the Redis database into the local cache according to a preset time interval. For example... Figure 6 As shown, the loading unit 1408 can be used to perform step 601.
[0172] Optional, such as Figure 14 As shown, the above-mentioned virtual resource list generation device further includes:
[0173] Storage unit 1402 is further configured to, when acquisition unit 1401 distributes virtual resources in the virtual space, acquire the number of currently online user accounts in the virtual space, and if the number of currently online user accounts is less than or equal to a preset number, store the fourth target data of the fourth user account for the virtual resources in the virtual resource list synchronously. The fourth target data includes the correspondence between the fourth user account and the number of virtual resources acquired. Figure 3 As shown, storage unit 1402 can be used to perform step 301.
[0174] Optionally, the above-mentioned virtual resource list generation device includes: obtaining the number of currently online user accounts in the virtual space based on the resource processing application programming interface (API); if the number of currently online user accounts is greater than a preset number, storing the first target data asynchronously into the virtual resource list; storing the second target data synchronously into the virtual resource list; obtaining the access request sent by the third user account based on the resource list API; storing the third target data into the virtual resource list; and sending the virtual resource list to the third user account.
[0175] Regarding the apparatus in the above embodiments, the specific manner in which each unit performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0176] Figure 15 This is a schematic diagram of the structure of an electronic device provided in this disclosure. For example... Figure 15 As shown, the electronic device may include a processor 1501 and a memory 1502 for storing executable instructions of the processor 1501; wherein the processor 1501 is configured to execute the instructions to implement the virtual resource list generation method in the above embodiment.
[0177] In addition, the electronic device may also include a communication bus 1503 and at least one communication interface 1504.
[0178] Processor 1501 may be a central processing unit (CPU), a microprocessor unit, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of programs according to the present disclosure.
[0179] The communication bus 1503 is a signal path used to transmit information between the aforementioned components.
[0180] Communication interface 1504 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.
[0181] Memory 1502 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Memory 1502 may exist independently and be connected to processor 1501 via communication bus 1504. Memory 1502 may also be integrated with processor 1501.
[0182] The memory 1502 stores instructions for executing the present invention, and its execution is controlled by the processor 1501. The processor 1501 executes the program or instructions stored in the memory 1502 to implement the functions of the method of the present invention.
[0183] As an example, combined Figure 14 The functions implemented by the acquisition unit 1401, storage unit 1402, and sending unit 1403 in the virtual resource list generation device are the same as those of the acquisition unit 1401, storage unit 1402, and sending unit 1403. Figure 15 The processor 15011 in it has the same function.
[0184] In a specific implementation, as one example, the processor 1501 may include one or more CPUs, for example... Figure 15 CPU0 and CPU1 in the CPU.
[0185] In a specific implementation, as one embodiment, the electronic device may include a plurality of processors 1501, each of which may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. Here, processor 1501 may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0186] In a specific implementation, as one embodiment, the electronic device may further include an output device 1505 and an input device 1506. The output device 1505 communicates with the processor 1501 and can display information in various ways. For example, the output device 1505 may be a liquid crystal display (LCD), a light-emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device 1506 communicates with the processor 1501 and can accept user input in various ways. For example, the input device 1506 may be a mouse, keyboard, touchscreen device, or sensing device, etc.
[0187] Those skilled in the art will understand that Figure 15 The structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or use different component arrangements. Figure 15 The electronic devices in the system can be servers, clients, or other devices.
[0188] In addition, this disclosure also provides a computer-readable storage medium storing a program or instructions that, when executed by a processor, enable an electronic device to perform the virtual resource list generation method provided in the above embodiments. Optionally, the readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device, etc.
[0189] In addition, this disclosure also provides a computer program product, including a computer program / instructions, which is stored in a non-volatile readable storage medium. When the computer program product is executed by at least one processor, it causes an electronic device to perform the method for generating a virtual resource list as provided in the above embodiments.
[0190] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure 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 this disclosure are indicated by the claims.
[0191] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method for generating a virtual resource list, characterized in that, include: When virtual resources are distributed in a virtual space, obtain the number of currently online user accounts in the virtual space; The virtual space refers to the construction of a virtual barrier in the network, whereby user accounts that join the virtual space can obtain virtual resources; If the number of currently online user accounts is greater than a preset number, a random detection value corresponding to the user account to be stored is generated according to a random strategy. The random detection value is any value between a preset maximum threshold and a preset minimum threshold. If the random detection value is greater than the random write threshold, the user account to be stored is determined as the first user account. The random write threshold is determined based on the product of the preset maximum threshold and the random write ratio. If the random detection value is less than or equal to the random write threshold, the user account to be stored is determined to be the second user account; First target data of at least one first user account that has obtained virtual resources is stored asynchronously in the virtual resource list, and second target data of at least one second user account that has obtained virtual resources is stored synchronously in the virtual resource list; wherein, the first target data includes the correspondence between each first user account and the number of virtual resources obtained, and the second target data includes the correspondence between each second user account and the number of virtual resources obtained; Obtain an access request sent by a third user account, the access request being used to request access to the virtual resource list, the access request including third target data; the third target data including the correspondence between the third user account and the number of virtual resources obtained; the third user account is an online user account in the virtual space; If the third target data is not included in the virtual resource list, the third target data will be stored in the virtual resource list. The list of virtual resources is sent to the third user account.
2. The method for generating a virtual resource list according to claim 1, characterized in that, When the number of currently online user accounts is greater than a preset number, the method further includes: The random write ratio is determined based on the number of currently online user accounts and the preset number of concurrent requests.
3. The method for generating a virtual resource list according to claim 1, characterized in that, The second target data of at least one second user account that obtains virtual resources is stored in the virtual resource list synchronously, including: Under the condition of synchronous writing, the second target data of at least one second user account of the virtual resource will be obtained and stored in the virtual resource list in a synchronous manner. The synchronous writing condition is: the current device resource capacity determined based on the preset token bucket algorithm is less than the preset device resource capacity. The method further includes: If the synchronous write condition is not met, the at least one second user account will be reassigned as the first user account.
4. The method for generating a virtual resource list according to claim 1, characterized in that, The step of asynchronously storing the first target data of at least one first user account that obtains virtual resources into the virtual resource list includes: Generate an asynchronous write request message corresponding to the first target data, the asynchronous write request message being used to request that the first target data be stored in the virtual resource list; Add the asynchronous write request message to the message queue; According to the message processing mechanism, the asynchronous write request messages in the message queue are processed, and the first target data is stored in the virtual resource list.
5. The method for generating a virtual resource list according to claim 1, characterized in that, The method further includes: According to a preset time interval, starting from the data record with the smallest number of virtual resources in the virtual resource list, a random number of data records are deleted.
6. The method for generating a virtual resource list according to claim 1, characterized in that, The list of virtual resources is stored in a queue Redis database; the method further includes: If the list of virtual resources is already stored in the local cache, retrieve the list of virtual resources from the local cache; If the virtual resource list is not stored in the local cache, the virtual resource list is retrieved from the Redis database.
7. The method for generating a virtual resource list according to claim 6, characterized in that, The method further includes: The list of virtual resources in the Redis database is loaded into the local cache at preset time intervals.
8. The method for generating a virtual resource list according to claim 1, characterized in that, In the case of distributing virtual resources in a virtual space, after obtaining the number of currently online user accounts in the virtual space, the method further includes: If the number of currently online user accounts is less than or equal to the preset number, the fourth target data of the fourth user account for virtual resources will be obtained and stored in the virtual resource list through synchronization. The fourth target data includes the correspondence between the fourth user account and the number of virtual resources obtained.
9. The method for generating a virtual resource list according to claim 1, characterized in that, The method further includes: Based on the resource processing application programming interface (API), the number of currently online user accounts in the virtual space is obtained; if the number of currently online user accounts is greater than a preset number, the first target data is stored asynchronously in the virtual resource list; the second target data is stored synchronously in the virtual resource list. Based on the resource list API, obtain the access request sent by the third user account; store the third target data in the virtual resource list; and send the virtual resource list to the third user account.
10. A device for generating a virtual resource list, characterized in that, It includes an acquisition unit, a generation unit, a determination unit, a storage unit, and a transmission unit; The acquisition unit is used to acquire the number of currently online user accounts in the virtual space when virtual resources are distributed in the virtual space; the virtual space refers to the virtual barrier built in the network, and user accounts that join the virtual space can obtain virtual resources; The generation unit is used to generate random detection values corresponding to user accounts to be stored according to a random strategy when the number of currently online user accounts is greater than a preset number. The random detection values are any values between a preset maximum threshold and a preset minimum threshold. The determining unit is used to determine the user account to be stored as the first user account when the random detection value generated by the generating unit is greater than the random write threshold. The random write threshold is determined based on the product of the preset maximum threshold and the random write ratio. The determining unit is further configured to determine the user account to be stored as a second user account when the random detection value generated by the generating unit is less than or equal to the random write threshold. The storage unit is used to asynchronously store the first target data of at least one first user account that has obtained virtual resources into the virtual resource list, and synchronously store the second target data of at least one second user account that has obtained virtual resources into the virtual resource list; wherein, the first target data includes a correspondence between each first user account and the number of virtual resources obtained, and the second target data includes a correspondence between each second user account and the number of virtual resources obtained. The acquisition unit is further configured to acquire an access request sent by a third user account, the access request being used to request access to a list of virtual resources stored in the storage unit, the access request including third target data; the third target data including the correspondence between the third user account and the number of virtual resources acquired; the third user account being an online user account in the virtual space; The storage unit is further configured to store the third target data into the virtual resource list when the virtual resource list does not include the third target data acquired by the acquisition unit; The sending unit is used to send the list of virtual resources stored in the storage unit to the third user account.
11. The apparatus for generating a virtual resource list according to claim 10, characterized in that, The device further includes: The determining unit is further configured to, when the number of currently online user accounts is greater than a preset number, determine the random write ratio based on the number of currently online user accounts and the preset number of concurrent requests.
12. The virtual resource list generation apparatus according to claim 10, characterized in that, The storage unit is specifically used for: Under the condition of synchronous writing, the second target data of at least one second user account of the virtual resource will be obtained and stored in the virtual resource list in a synchronous manner. The synchronous writing condition is: the current device resource capacity determined based on the preset token bucket algorithm is less than the preset device resource capacity. The device further includes: The determining unit is further configured to re-determine the at least one second user account as the first user account if the synchronous write condition is not met.
13. The apparatus for generating a virtual resource list according to claim 10, characterized in that, The storage unit is further used for: Generate an asynchronous write request message corresponding to the first target data, the asynchronous write request message being used to request that the first target data be stored in the virtual resource list; Add the asynchronous write request message to the message queue; According to the message processing mechanism, the asynchronous write request messages in the message queue are processed, and the first target data is stored in the virtual resource list.
14. The apparatus for generating a virtual resource list according to claim 10, characterized in that, The device further includes: a deletion unit; The deletion unit is further configured to delete a random number of data records from the data record with the smallest number of virtual resources in the virtual resource list stored in the storage unit according to a preset time interval, and to ensure that the number of data records in the virtual resource list is greater than the preset number of records.
15. The apparatus for generating a virtual resource list according to claim 10, characterized in that, The list of virtual resources is stored in a queue Redis database; the device further includes: a judgment unit; The judgment unit is used to determine whether the virtual resource list is stored in the local cache; The acquisition unit is further configured to acquire the virtual resource list from the local cache if the virtual resource list has been saved in the local cache; The acquisition unit is further configured to acquire the virtual resource list from the Redis database if the local cache does not store the virtual resource list.
16. The apparatus for generating a virtual resource list according to claim 15, characterized in that, The device further includes: a loading unit; The loading unit is used to load the list of virtual resources stored in the storage unit of the Redis database into the local cache according to a preset time interval.
17. The apparatus for generating a virtual resource list according to claim 10, characterized in that, The device further includes: The storage unit is further configured to, when the acquisition unit obtains the number of currently online user accounts in the virtual space when the number of currently online user accounts is less than or equal to the preset number, store the fourth target data of the fourth user account for the virtual resources in the virtual resource list through synchronization, wherein the fourth target data includes the correspondence between the fourth user account and the number of virtual resources obtained.
18. The apparatus for generating a virtual resource list according to claim 10, characterized in that, The device further includes: Based on the resource processing application programming interface (API), the number of currently online user accounts in the virtual space is obtained; if the number of currently online user accounts is greater than a preset number, the first target data is stored asynchronously in the virtual resource list; the second target data is stored synchronously in the virtual resource list. Based on the resource list API, obtain the access request sent by the third user account; store the third target data in the virtual resource list; and send the virtual resource list to the third user account.
19. 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 method for generating a virtual resource list as described in any one of claims 1-9.
20. A readable storage medium, characterized in that, When the instructions in the readable storage medium are executed by the processor, the method for generating a virtual resource list as described in any one of claims 1-9 can be implemented.
Citation Information
Patent Citations
System and method for lauching a resource in a network
CA2770789A1
Red envelope processing method and system
CN106649637A
