A method, device and computer-readable storage medium for determining virtual items
By receiving virtual item acquisition requests in a distributed system, querying data from cache and storage databases, and determining the data version based on historical acquisition time, the data consistency problem is solved and the accuracy of data processing is improved.
Patent Information
- Application Number
- CN202011442486.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-08
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2040-12-08
AI Technical Summary
In distributed systems, when data is stored on different devices, data consistency is difficult to ensure, resulting in low accuracy of data processing.
By receiving the virtual item acquisition request from the client, the first historical virtual item data is queried from the cache database. If it is not queried, the second historical virtual item data is obtained from the storage database, and the data version is determined based on the historical acquisition time. When the data version is the latest, the target virtual item is determined and distributed.
Improve the accuracy of data processing, and by marking and determining the data versions within each time period, it ensures that the historical virtual item data of the latest data version is processed, improving the accuracy of data processing.
Smart Images

Figure CN112559568B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a method and device for determining a virtual item, and a computer-readable storage medium. Background Art
[0002] With the rapid development of information technology, the various data generated by the Internet are becoming increasingly massive, and a large amount of data is mostly stored on different devices in distributed systems.
[0003] During the research and practice of related technologies, the inventors of this application found that when reading various types of data on the Internet, since the data is stored on different devices in a distributed system, data consistency is difficult to ensure and the accuracy of data processing is low. Summary of the Invention
[0004] The embodiments of the present application provide a method, device, and computer-readable storage medium for determining a virtual item, which can improve the accuracy of data processing.
[0005] The present invention provides a method for determining a virtual item, including:
[0006] Receiving a virtual item acquisition request sent by a client, wherein the virtual item acquisition request indicates a target virtual item to be acquired;
[0007] querying, from a cache database, first historical virtual item data of the client according to the virtual item acquisition request, the first historical virtual item data including the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item;
[0008] When the first historical virtual item data is not found, obtaining second historical virtual item data of the client from a storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item;
[0009] determining a data version of the second historical virtual item data based on the second historical acquisition time;
[0010] When the data version of the second historical virtual item data is the latest data version, determining the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item;
[0011] The target virtual item is distributed to the client.
[0012] Accordingly, an embodiment of the present application provides a virtual item determination device, including:
[0013] A receiving unit, configured to receive a virtual item acquisition request sent by a client, wherein the virtual item acquisition request indicates a target virtual item to be acquired;
[0014] a query unit, configured to query first historical virtual item data of the client from a cache database according to the virtual item acquisition request, wherein the first historical virtual item data includes the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item;
[0015] a first acquiring unit, configured to acquire, when the first historical virtual item data is not found, second historical virtual item data of the client from a storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item;
[0016] a first determining unit, configured to determine a data version of the second historical virtual item data based on the second historical acquisition time;
[0017] a second determining unit configured to determine, when the data version of the second historical virtual item data is the latest data version, the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item;
[0018] The issuing unit is configured to issue the target virtual item to the client.
[0019] In one embodiment, the first determining unit includes:
[0020] A first acquisition subunit is configured to acquire a historical acquisition time of the client in a reference database, wherein the historical acquisition time represents an acquisition time of the virtual item acquired by the client in each historical stage;
[0021] a second acquisition subunit, configured to determine a target historical acquisition time from the historical acquisition times based on a time sequence of the historical acquisition times;
[0022] The first determining subunit is configured to compare the second historical acquisition time with the target historical acquisition time, and determine a data version of the second historical virtual item data based on a comparison result.
[0023] In one embodiment, the second determining unit includes:
[0024] a third acquisition subunit, configured to acquire, based on the second historical virtual item, data processing logic corresponding to the virtual item acquisition request when the data version of the second historical virtual item data is the latest data version;
[0025] an execution subunit, configured to execute the data processing logic on the virtual item acquisition request to obtain a data processing result;
[0026] A second determining subunit is configured to determine the target virtual item corresponding to the virtual item acquisition request based on the data processing result.
[0027] In one embodiment, the third acquisition subunit is further configured to, when the data version of the second historical virtual item data is the latest data version, acquire historical virtual item acquisition information of the client; and acquire data processing logic corresponding to the virtual item acquisition request based on the historical virtual item acquisition information and the second historical virtual item.
[0028] In one embodiment, the virtual item determination apparatus further includes:
[0029] a second acquiring unit, configured to acquire, from the reference database, the historical virtual item data corresponding to the target historical acquisition time when the data version of the second historical virtual item data is not the latest data version;
[0030] A third determining unit is configured to determine the target virtual item corresponding to the virtual item acquisition request based on the historical virtual item data corresponding to the target historical acquisition time.
[0031] In one embodiment, the virtual item determination apparatus further includes:
[0032] A generating unit, configured to generate target virtual item data of the client at a current time based on the distributed target virtual item;
[0033] a storage unit, configured to store the target virtual item data in the cache database, the storage database, and the reference database;
[0034] An updating unit is configured to update the historical virtual item data of the client in the cache database, the storage database, and the reference database based on the storage result.
[0035] In one embodiment, the virtual item determination apparatus further includes:
[0036] a third acquiring unit, configured to acquire, from a reference database, a historical acquisition time of the client when the first historical virtual item data is found;
[0037] a fourth determining unit, configured to determine a data version of the first historical virtual item data based on the first historical acquisition time and the historical acquisition time;
[0038] A fifth determining unit is configured to determine, based on the first historical virtual item, the target virtual item corresponding to the virtual item acquisition request when the data version of the first historical virtual item data is the latest data version.
[0039] In one embodiment, the virtual item determination apparatus further includes:
[0040] a fourth acquiring unit, configured to acquire historical virtual item data within a preset time period from the reference database when the data version of the first historical virtual item data is not the latest data version;
[0041] A sixth determining unit is configured to determine the target virtual item corresponding to the virtual item acquisition request based on the historical virtual item data within the preset time period.
[0042] Accordingly, an embodiment of the present application further provides a computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the steps of any virtual item determination method provided in any embodiment of the present application.
[0043] Accordingly, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for loading by a processor to execute the steps in any virtual item determination method provided in any embodiment of the present application.
[0044] An embodiment of the present application can receive a virtual item acquisition request sent by a client, wherein the virtual item acquisition request indicates a target virtual item to be acquired; based on the virtual item acquisition request, query first historical virtual item data of the client from a cache database, wherein the first historical virtual item data includes the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item; when the first historical virtual item data is not found, acquire second historical virtual item data of the client from a storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item; determine a data version of the second historical virtual item data based on the second historical acquisition time; when the data version of the second historical virtual item data is the latest data version, determine the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item; and distribute the target virtual item to the client. This solution can mark the data version of the data stored in the cache database, storage database and other databases in each time period. When performing data processing later, the data version of each historical virtual item data stored in the cache database and storage database can be determined to determine the latest data version of the historical virtual item data. Data processing can then be performed on the latest data version of the historical virtual item data, which can improve the accuracy of data processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0046] Figure 1 Schematic diagram of a scenario of a method for determining a virtual item provided in an embodiment of the present application;
[0047] Figure 2a is a flowchart of a method for determining a virtual item provided in an embodiment of the present application;
[0048] Figure 2b is a flowchart of a virtual item acquisition method provided in an embodiment of the present application;
[0049] Figure 2c This is a data reading and writing flow chart of the virtual item determination method provided by an embodiment of the present application;
[0050] Figure 2dThis is a data cache flow chart of the virtual item determination method provided by an embodiment of the present application;
[0051] Figure 2e This is a diagram of data reading and writing scenarios in a cluster of a virtual item determination method provided in an embodiment of the present application;
[0052] Figure 3 is another flow chart of the method for determining virtual items provided in an embodiment of the present application;
[0053] Figure 4a is a diagram of a device for a method for determining a virtual item provided in an embodiment of the present application;
[0054] Figure 4b is another apparatus diagram of the virtual item determination method provided by an embodiment of the present application;
[0055] Figure 4c is another apparatus diagram of the virtual item determination method provided by an embodiment of the present application;
[0056] Figure 5 It is a structural diagram of the computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0058] The embodiments of the present application provide a method, apparatus, computer device, and computer-readable storage medium for determining a virtual item. Specifically, the embodiments of the present application provide a virtual item determination apparatus suitable for a computer device. The computer device may be a terminal or a server, and the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal may be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions thereon.
[0059] refer to Figure 1Taking the computer device as a cloud server as an example, the cloud server can receive a virtual item acquisition request sent by a client, where the virtual item acquisition request indicates a target virtual item to be acquired; based on the virtual item acquisition request, query the client's first historical virtual item data from a cache database, where the first historical virtual item data includes the client's first historical virtual item and a first historical acquisition time corresponding to the first historical virtual item; when the first historical virtual item data is not found, acquire the client's second historical virtual item data from a storage database, where the cache database and the storage database are deployed on different devices, where the second historical virtual item data includes the client's second historical virtual item and a second historical acquisition time corresponding to the second historical virtual item; determine a data version of the second historical virtual item data based on the second historical acquisition time; when the data version of the second historical virtual item data is the latest data version, determine a target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item; and distribute the target virtual item to the client.
[0060] The first historical virtual item data and the second historical virtual item data can be obtained based on cloud platform technology. A cloud platform, also known as a cloud computing platform, refers to a service based on hardware and software resources, providing computing, networking, and storage capabilities. The cloud platform in this embodiment can be understood as a platform based on the aforementioned cloud servers. This platform can provide users with various services they need, such as company website construction and operation services. Users can purchase cloud server resources, such as storage resources and computing resources, on this cloud platform and complete various tasks based on the purchased resources and the various components provided by the cloud servers.
[0061] Cloud computing is a computing model that distributes computing tasks across a resource pool consisting of a large number of computers, enabling various application systems to access computing power, storage space, and information services as needed. The network that provides these resources is called the "cloud." To users, these resources appear infinitely scalable and can be accessed at any time, used on demand, expanded at any time, and paid for on a per-use basis.
[0062] From the above, it can be seen that the embodiments of the present application can mark the data version of the data stored in the cache database, storage database and other databases in each time period. When performing data processing thereafter, the data version of each historical virtual item data stored in the cache database and storage database can be determined to determine the latest data version of the historical virtual item data. Thereafter, data processing can be performed on the latest data version of the historical virtual item data, which can improve the accuracy of data processing.
[0063] The present embodiments are described in detail below. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0064] The embodiment of the present application provides a method for determining a virtual item. The method can be executed by a terminal or a server, or by both the terminal and the server. The embodiment of the present application takes the method for determining a virtual item executed by a server as an example for explanation. Specifically, the method is executed by a virtual item determination device integrated in the server. Figure 2a As shown, the specific process of the virtual item determination method can be as follows:
[0065] 201. Receive a virtual item acquisition request sent by a client, where the virtual item acquisition request indicates a target virtual item to be acquired.
[0066] The target virtual item refers to a virtual item returned to the client based on the virtual item acquisition request. For example, the target virtual item may be a consumption voucher, a cash voucher, or other virtual item.
[0067] In one embodiment, if Figure 2b The client can send a virtual item acquisition request to the virtual item acquisition module, and then the virtual item acquisition module can query the client's historical records from the cache database. For example, when the client's virtual item data of the item is not found in the cache database, the client's historical virtual item data is obtained from the storage database, and then the virtual item acquisition request is logically processed based on the obtained virtual item data to determine the target virtual item to be issued to the client.
[0068] The virtual item acquisition module and the cache database may be deployed on the same device. There may be multiple devices for deploying the virtual item acquisition module and the cache database. There may be multiple devices for deploying the storage database. The cache database and the storage database may be deployed in a distributed system.
[0069] 202. According to the virtual item acquisition request, query the cache database for first historical virtual item data of the client, where the first historical virtual item data includes the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item.
[0070] Among them, the first historical virtual item data is stored in the cache database, and the second historical virtual item data is stored in the storage database. The first historical virtual item data and the second historical virtual item data can be the same or different. For example, whether they are the same can be determined based on the data versions of the first historical virtual item data and the second virtual item data.
[0071] In one embodiment, each time virtual item data is written into the cache database and the storage database, a data version may be set for the written virtual item data, and a historical acquisition time may be added to each data version. For example, the historical acquisition time may be determined by adding a timestamp, and then when determining whether the virtual item data is the latest data, the timestamp may be used to determine it.
[0072] Among them, when operating multi-source data, the CAS data consistency write strategy (that is, the strategy of marking the data version of the written data) not only protects the consistency of data writes, but also reduces the read pressure on storage. First, the data is queried from the cache database. If the cache database does not have it, the data is obtained from the storage database. Then the new data is written to the cache database and the storage database, reducing the access volume of the storage database by half and improving performance. Read consistency ensures that the read data is consistent with the storage, and write consistency ensures that the data written to the storage is not dirty data.
[0073] The data source can be different media, such as redis+mysql, or the same medium, such as redis, redis, etc.
[0074] Among them, when cache isolation and storage are not isolated, due to the complexity of distributed network reading, such as machine abnormalities, etc., consistent routing may jump, for example, causing the same user data to be routed to different caches, resulting in inconsistencies between the cache data in the cache database and the storage data in the storage database. The time consistency read strategy (that is, the strategy of adding a timestamp to each data written to the cache database and the storage database) can ensure that the data automatically returns to normal after a certain period of time. Combined with the CAS data consistency write strategy, data writing is protected.
[0075] Isolation: The data in different isolation areas are independent. For example, in two set clusters, the cached redis data in each set is independent and stored in mysql centrally.
[0076] In one embodiment, after the step of “searching the cache database for the first historical virtual item data of the client according to the virtual item acquisition request”, the following steps may be performed:
[0077] When the first historical virtual item data is found, the historical acquisition time of the client in the reference database is obtained;
[0078] determining a data version of the first historical virtual item data based on the first historical acquisition time and the historical acquisition time;
[0079] When the data version of the first historical virtual item data is the latest data version, a target virtual item corresponding to the virtual item acquisition request is determined based on the first historical virtual item.
[0080] In one embodiment, after the step of “determining the data version of the first historical virtual item data based on the first historical acquisition time and the historical acquisition time”, the following steps may also be performed:
[0081] When the data version of the first historical virtual item data is not the latest data version, obtaining historical virtual item data within a preset time period from a reference database;
[0082] Based on historical virtual item data within a preset time period, a target virtual item corresponding to the virtual item acquisition request is determined.
[0083] In one example, each time data is written into the cache database and the storage database, such as virtual item data, it can also be stored in the reference database, and a data version can be set for the data written into the cache database, the storage database, and the reference database, and the historical acquisition time of the stored data can be recorded. For example, the historical acquisition time can be determined by writing timestamp information.
[0084] 203. When the first historical virtual item data is not found, obtain second historical virtual item data of the client from the storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item.
[0085] The second historical virtual item data may be stored in a storage database and is data on virtual items acquired by the client during a certain historical time period. The second historical virtual item data may represent historical virtual items acquired by the client during the historical time period, as well as corresponding historical acquisition time and other data.
[0086] In one embodiment, if Figure 2c As shown, the reading process may include the following steps:
[0087] (1) first read the cache data in the cache data, the cache data version number, and the write timestamp information, for example, first read the historical virtual item data in the cache database, the data version of the virtual item data, and the historical acquisition time when the historical virtual item was written into the cache database;
[0088] (2) Determine whether the timestamp needs to be updated. If not, return directly and end the process. If it needs to be updated, go to step (3);
[0089] (3) Read the CAS data version number of the actual data and the data in the reference database from MySQL (storage database). If successful, update the CAS value and time error stored in the cache database and return the data to end the process. If failed, go to step (4);
[0090] (4) Return failure to the business and end the process.
[0091] The writing process may include the following steps:
[0092] (1) First read the data version number from the cache data;
[0093] (2) Try to write to the storage. If successful, get the latest data version number and update the cached data and cached data version number, ending the process. If failed, go to step (3);
[0094] (3) Read the latest data and data version number from the storage (storage database), update the cache, and return a successful end to the process.
[0095] 204. Determine a data version of the second historical virtual item data based on the second historical acquisition time.
[0096] The version number of the data version can be used to mark each historical virtual item data, so that the user can understand whether the current historical virtual item data is the latest version.
[0097] In one embodiment, the step of “determining the data version of the second historical virtual item data based on the second historical acquisition time” may include:
[0098] Obtaining historical acquisition time of the client in the reference database, where the historical acquisition time represents the time when the client acquired the virtual item in each historical stage;
[0099] determining a target historical acquisition time from the historical acquisition times based on a time sequence of the historical acquisition times;
[0100] The second historical acquisition time is compared with the target historical acquisition time, and a data version of the second historical virtual item data is determined based on the comparison result.
[0101] In one example, based on the chronological order of the historical acquisition times, the target historical acquisition time closest to the current time can be determined, and then the target historical time can be compared with the second historical acquisition time. Based on the comparison result, it can be determined whether the second historical acquisition time is the time closest to the current time. If the second historical acquisition time is the time closest to the current time, then it can be determined that the data version of the second historical virtual item data corresponding to the second historical acquisition time is the latest data version. If the second historical acquisition time is not the time closest to the current time, then it can be determined that the data version of the second historical virtual item data is not the latest data version.
[0102] Furthermore, when the data version of the second historical virtual item data is not the latest data version, the historical virtual item data of the client corresponding to the target historical acquisition time can be obtained from the reference database to determine that the data version of the historical virtual item data is the latest data version.
[0103] In one embodiment, before the step of “when the data version of the second historical virtual item data is the latest data version, determining the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item”, the step further includes:
[0104] When the data version of the second historical virtual item data is not the latest data version, obtaining the historical virtual item data corresponding to the target historical acquisition time from the reference database;
[0105] A target virtual item corresponding to the virtual item acquisition request is determined based on historical virtual item data corresponding to the target historical acquisition time.
[0106] 205. When the data version of the second historical virtual item data is the latest data version, determine the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item, and distribute the target virtual item to the client.
[0107] Among them, the latest data version refers to the data version closest to the current time. For example, there are first historical virtual item data and second historical virtual item data. The data version of the first historical virtual item data is 1, which is 2 hours away from the current time, and the data version of the second historical virtual item data is 2, which is 1 hour away from the current time. If only the data versions of the first historical virtual item data and the second historical virtual item data are compared, the data version of the second historical virtual item data is the latest data version.
[0108] In one embodiment, the step of “determining, based on the second historical virtual item, a target virtual item corresponding to the virtual item acquisition request when the data version of the second historical virtual item data is the latest data version” may include:
[0109] When the data version of the second historical virtual item data is the latest data version, obtaining data processing logic corresponding to the virtual item acquisition request based on the second historical virtual item;
[0110] Execute data processing logic on the virtual item acquisition request to obtain data processing results;
[0111] Based on the data processing result, a target virtual item corresponding to the virtual item acquisition request is determined.
[0112] In one example, the data processing logic refers to the processing logic for a virtual item acquisition request. For example, based on the second historical virtual item, the target virtual item that the client should obtain this time is determined. That is, based on the data such as the second historical virtual item, the historical virtual items obtained by the client in the past can be determined, and then the target virtual item that the client should obtain this time can be determined.
[0113] In one embodiment, the detailed process of the step of "when the data version of the second historical virtual item data is the latest data version, obtaining data processing logic corresponding to the virtual item acquisition request based on the second historical virtual item" may include:
[0114] When the data version of the second historical virtual item data is the latest data version, obtaining historical virtual item acquisition information of the client;
[0115] Based on the historical virtual item acquisition information and the second historical virtual item, data processing logic corresponding to the virtual item acquisition request is acquired.
[0116] In one embodiment, after the step of “issuing the target virtual item to the client”, the following steps may also be performed:
[0117] Based on the distributed target virtual item, generate the target virtual item data of the client at the current time;
[0118] Storing target virtual item data in a cache database, a storage database, and a reference database;
[0119] Based on the storage result, the historical virtual item data of the client in the cache database, the storage database, and the reference database are updated.
[0120] In one embodiment, if Figure 2d As shown, when data is modified, read storage (reading data in the storage database) is optimized to read cache (reading data in the cache database), reducing the pressure on storage by half.
[0121] In one embodiment, if Figure 2eAs shown in the figure, cache isolation solves read and write consistency and simplifies business layer complexity. For example, in scenario 1, when a user accesses the Shenzhen cluster, data is directly read from the cache and modified in the Shenzhen cluster's storage and cache data. In scenario 2, when a user switches to the Guangzhou cluster, cached data is re-pulled from storage.
[0122] There are two situations when users switch back to the original Shenzhen cluster:
[0123] Scenario 3.1: When the user switches to the original Shenzhen cluster again, the data is directly retrieved from the storage when the update timestamp exceeds the synchronization interval;
[0124] Scenario 3.2: When the user jumps to the original Shenzhen cluster again, if the update timestamp does not exceed the synchronization interval, there will be a data version number conflict when the data is written to the storage. At this time, the cached data can be updated to the cache again.
[0125] Among them, hopping refers to the situation where users switch back and forth between different isolation zones.
[0126] From the above, it can be seen that the embodiments of the present application can mark the data version of the data stored in the cache database, storage database and other databases in each time period. When performing data processing thereafter, the data version of each historical virtual item data stored in the cache database and storage database can be determined to determine the latest data version of the historical virtual item data. Thereafter, data processing can be performed on the latest data version of the historical virtual item data, which can improve the accuracy of data processing.
[0127] Based on the above introduction, the following examples will further illustrate the virtual item determination method of this application. Figure 3 , a method for determining a virtual item, the specific process may be as follows:
[0128] 301. The server receives a virtual item acquisition request sent by a client, where the virtual item acquisition request indicates a target virtual item to be acquired.
[0129] In one example, if Figure 2b As shown, the client can send a virtual item acquisition request to the virtual item acquisition module. After receiving the virtual item acquisition request, the virtual item acquisition module can determine the historical virtual item data of the client from a cache database, etc., and then perform corresponding logical processing on the virtual item acquisition request based on the determined historical virtual item data of the client to obtain the target virtual item corresponding to the virtual item acquisition request, and distribute the target virtual item to the client.
[0130] 302. The server queries the cache database for first historical virtual item data of the client according to the virtual item acquisition request. The first historical virtual item data includes the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item.
[0131] In one example, if Figure 2b As shown, the client can send a virtual item acquisition request to the virtual item acquisition module to obtain the client's historical virtual item data. There may be multiple situations, and the following is one of the possible situations:
[0132] A virtual item acquisition request 1 is sent to the virtual item acquisition module. After the virtual item acquisition module receives the virtual item acquisition request 1, the virtual item acquisition module can query the client's historical records from the cache database to obtain the client's first historical virtual item data from the cache database. When the client's first historical virtual item data does not exist in the cache database, the virtual item acquisition module obtains the client's second historical virtual item data from the storage database, and then determines the data version of the second historical virtual item data. When the data version of the second historical virtual item data is the latest version, the target virtual item corresponding to the virtual item acquisition request 1 can be determined based on the second historical virtual item data, and the target virtual item is distributed to the target client.
[0133] 303. When the server fails to find the first historical virtual item data, the server obtains the second historical virtual item data of the client from the storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item.
[0134] In one example, when the server fails to retrieve the first historical virtual item data from the cache database, it can obtain the second historical virtual item data from the cache database, and then obtain the latest acquisition time of the historical virtual item data corresponding to the client in the reference database. Thereafter, the second historical acquisition time corresponding to the second historical virtual item data is compared with the latest acquisition time to determine whether the data version of the second historical virtual item data is the latest data version. When the data version of the second historical virtual item data is the latest version, the target virtual item that should currently be issued to the client can be determined based on the second historical virtual item data.
[0135] When the data version of the second historical virtual item data is not the latest data version, the historical virtual item data of the latest data version of the client can be obtained from the reference database, and then the target virtual item that should be currently issued to the client is determined based on the historical virtual item data of the latest data version.
[0136] 304. The server determines a data version of the second historical virtual item data based on the second historical acquisition time. When the data version of the second historical virtual item data is the latest data version, the server determines a target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item, and issues the target virtual item to the client.
[0137] After the target virtual item is issued to the client, a series of newly generated data such as the target virtual item and the target virtual item issuance time may be stored in the cache database, the storage database, and the reference database.
[0138] 305. When the server finds the first historical virtual item data, it obtains the historical acquisition time of the client in the reference database, and determines the data version of the first historical virtual item data based on the first historical acquisition time and the historical acquisition time.
[0139] In one example, when the server queries the first historical virtual item data from the cache database, it can obtain the first historical acquisition time corresponding to the first historical virtual item data, and then obtain the latest acquisition time of the historical virtual item data corresponding to the client in the reference database. Thereafter, the first historical acquisition time is compared with the latest acquisition time to determine whether the data version of the first historical virtual item data is the latest data version. When the data version of the first historical virtual item data is the latest version, the target virtual item that should currently be issued to the client can be determined based on the first historical virtual item data.
[0140] Among them, when the data version of the first historical virtual item data is not the latest data version, the historical virtual item data of the latest data version of the client can be obtained from the reference database, and then the target virtual item that should be currently issued to the client is determined based on the historical virtual item data of the latest data version.
[0141] 306. When the data version of the first historical virtual item data is the latest data version, the server determines a target virtual item corresponding to the virtual item acquisition request based on the first historical virtual item.
[0142] In one example, if Figure 2b As shown, the client can send a virtual item acquisition request to the virtual item acquisition module to obtain the client's historical virtual item data. There may be multiple situations, and the following is one of the possible situations:
[0143] A virtual item acquisition request 2 is sent to the virtual item acquisition module. After the virtual item acquisition module receives the virtual item acquisition request 2, the virtual item acquisition module can query the client's historical records from the cache database to obtain the client's first historical virtual item data from the cache database. When the client's first historical virtual item data exists in the cache database, the data version of the first historical virtual item data is determined. When the data version of the first historical virtual item data is the latest version, the target virtual item corresponding to the virtual item acquisition request 2 can be determined based on the first historical virtual item data, and the target virtual item is distributed to the target client.
[0144] In one example, if Figure 2b As shown, the client can send a virtual item acquisition request to the virtual item acquisition module to obtain the client's historical virtual item data. There may be multiple situations, and the following is one of the possible situations:
[0145] A virtual item acquisition request 3 is sent to the virtual item acquisition module. After the virtual item acquisition module receives the virtual item acquisition request 3, the virtual item acquisition module can query the client's historical records from the cache database to obtain the client's first historical virtual item data from the cache database. When the client's first historical virtual item data exists in the cache database, the data version of the first historical virtual item data is determined. When the data version of the first historical virtual item data is not the latest version, the historical virtual item data of the client with the latest data version is obtained from the reference database. Finally, the target virtual item corresponding to the virtual item acquisition request 3 can be determined based on the historical virtual item data with the latest data version, and the target virtual item is distributed to the target client.
[0146] From the above, it can be seen that the embodiments of the present application can mark the data version of the data stored in the cache database, storage database and other databases in each time period. When performing data processing thereafter, the data version of each historical virtual item data stored in the cache database and storage database can be determined to determine the latest data version of the historical virtual item data. Thereafter, data processing can be performed on the latest data version of the historical virtual item data, which can improve the accuracy of data processing.
[0147] In order to better implement the above method, accordingly, the embodiment of the present application further provides a virtual item determination device, wherein the virtual item determination device can be specifically integrated in the server, referring to Figure 4a The virtual item determination device may include a receiving unit 401, a query unit 402, a first obtaining unit 403, a first determining unit 404, a second determining unit 405, and a distributing unit 406, as follows:
[0148] (1) Receiving unit 401;
[0149] The receiving unit 401 is configured to receive a virtual item acquisition request sent by a client, where the virtual item acquisition request indicates a target virtual item to be acquired.
[0150] (2) query unit 402;
[0151] The query unit 402 is configured to query the client's first historical virtual item data from the cache database according to the virtual item acquisition request, where the first historical virtual item data includes the client's first historical virtual item and a first historical acquisition time corresponding to the first historical virtual item.
[0152] (3) a first acquisition unit 403;
[0153] The first acquisition unit 403 is configured to acquire, when the first historical virtual item data is not found, second historical virtual item data of the client from the storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item.
[0154] (4) a first determining unit 404;
[0155] The first determining unit 404 is configured to determine a data version of the second historical virtual item data based on the second historical acquisition time.
[0156] In one embodiment, if Figure 4b As shown, the first determining unit 404 includes:
[0157] The first acquisition subunit 4041 is used to acquire the historical acquisition time of the client in the reference database, where the historical acquisition time represents the time when the client acquired the virtual item in each historical stage;
[0158] The second acquisition subunit 4042 is configured to determine a target historical acquisition time from the historical acquisition times based on a time sequence of the historical acquisition times;
[0159] The first determining subunit 4043 is configured to compare the second historical acquisition time with the target historical acquisition time, and determine a data version of the second historical virtual item data based on the comparison result.
[0160] (5) second determining unit 405;
[0161] The second determining unit 405 is configured to determine a target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item when the data version of the second historical virtual item data is the latest data version.
[0162] In one embodiment, if Figure 4cAs shown, the second determining unit 405 includes:
[0163] The third acquisition subunit 4051 is configured to acquire data processing logic corresponding to a virtual item acquisition request based on the second historical virtual item when the data version of the second historical virtual item data is the latest data version;
[0164] The execution subunit 4052 is used to execute data processing logic on the virtual item acquisition request to obtain a data processing result;
[0165] The second determining subunit 4053 is configured to determine a target virtual item corresponding to the virtual item acquisition request based on the data processing result.
[0166] In one embodiment, the third acquisition subunit 4051 is further configured to obtain historical virtual item acquisition information of the client when the data version of the second historical virtual item data is the latest data version; and obtain data processing logic corresponding to the virtual item acquisition request based on the historical virtual item acquisition information and the second historical virtual item.
[0167] (6) issuing unit 406;
[0168] The issuing unit 406 is configured to issue the target virtual item to the client.
[0169] In one embodiment, the virtual item determination apparatus further includes:
[0170] The second acquisition unit 407 is configured to acquire the historical virtual item data corresponding to the target historical acquisition time from the reference database when the data version of the second historical virtual item data is not the latest data version;
[0171] The third determining unit 408 is configured to determine a target virtual item corresponding to the virtual item acquisition request based on the historical virtual item data corresponding to the target historical acquisition time.
[0172] In one embodiment, the virtual item determination apparatus further includes:
[0173] A generating unit 409, configured to generate target virtual item data of the client at the current time based on the distributed target virtual item;
[0174] The storage unit 410 is used to store the target virtual item data in the cache database, the storage database, and the reference database;
[0175] The updating unit 411 is configured to update the historical virtual item data of the client in the cache database, the storage database, and the reference database based on the storage result.
[0176] In one embodiment, the virtual item determination apparatus further includes:
[0177] The third obtaining unit 412 is configured to obtain the historical obtaining time of the client in the reference database when the first historical virtual item data is found;
[0178] A fourth determining unit 413 is configured to determine a data version of the first historical virtual item data based on the first historical acquisition time and the historical acquisition time;
[0179] The fifth determining unit 414 is configured to determine a target virtual item corresponding to the virtual item acquisition request based on the first historical virtual item when the data version of the first historical virtual item data is the latest data version.
[0180] In one embodiment, the virtual item determination apparatus further includes:
[0181] A fourth acquiring unit 415 is configured to acquire historical virtual item data within a preset time period from a reference database when the data version of the first historical virtual item data is not the latest data version;
[0182] The sixth determining unit 416 is configured to determine a target virtual item corresponding to the virtual item acquisition request based on historical virtual item data within a preset time period.
[0183] As can be seen from the above, the receiving unit 401 of the virtual item determination device of the embodiment of the present application receives a virtual item acquisition request sent by a client, where the virtual item acquisition request indicates a target virtual item to be acquired. Then, the query unit 402 queries the cache database for first historical virtual item data of the client based on the virtual item acquisition request. The first historical virtual item data includes the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item. If the first historical virtual item data is not found, the first acquisition unit 403 acquires second historical virtual item data of the client from the storage database. The cache database and the storage database are deployed on different devices. The second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item. The first determination unit 404 determines a data version of the second historical virtual item data based on the second historical acquisition time. If the data version of the second historical virtual item data is the latest data version, the second determination unit 405 determines a target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item. The issuing unit 406 issues the target virtual item to the client. This solution can mark the data version of the data stored in the cache database, storage database and other databases in each time period. When performing data processing later, the data version of each historical virtual item data stored in the cache database and storage database can be determined to determine the latest data version of the historical virtual item data. Data processing can then be performed on the latest data version of the historical virtual item data, which can improve the accuracy of data processing.
[0184] In addition, the embodiment of the present application also provides a computer device, which can be a terminal or a server. Figure 5 , which shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application, specifically:
[0185] The computer device may include one or more processing core processors 501, one or more storage media memories 502, a power supply 503, an input unit 504 and other components. Those skilled in the art will understand that Figure 5 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange components differently.
[0186] Processor 501 is the control center of the computer device. It connects the various components of the entire computer device using various interfaces and lines. By running or executing software programs and / or modules stored in memory 502 and accessing data stored in memory 502, it performs various functions of the computer device and processes data, thereby performing overall testing of the computer device. Optionally, processor 501 may include one or more processing cores; preferably, processor 501 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 501.
[0187] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing by running the software programs and modules stored in the memory 502. The memory 502 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 502 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 502 may also include a memory controller to provide the processor 501 with access to the memory 502.
[0188] The computer device also includes a power supply 503 for supplying power to various components. Preferably, the power supply 503 can be logically connected to the processor 501 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 503 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0189] The computer device may further include an input unit 504 , which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0190] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 501 in the computer device will load the executable files corresponding to one or more application processes into the memory 502 according to the following instructions, and the processor 501 will run the application stored in the memory 502 to implement various functions as follows:
[0191] A method of receiving a virtual item acquisition request sent by a client, wherein the virtual item acquisition request indicates a target virtual item to be acquired; querying a cache database for first historical virtual item data of the client according to the virtual item acquisition request, wherein the first historical virtual item data includes the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item; when the first historical virtual item data is not found, acquiring second historical virtual item data of the client from a storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item; determining a data version of the second historical virtual item data based on the second historical acquisition time; and determining a target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item when the data version of the second historical virtual item data is the latest data version; and issuing the target virtual item to the client.
[0192] From the above, it can be seen that the embodiments of the present application can mark the data version of the data stored in the cache database, storage database and other databases in each time period. When performing data processing thereafter, the data version of each historical virtual item data stored in the cache database and storage database can be determined to determine the latest data version of the historical virtual item data. Thereafter, data processing can be performed on the latest data version of the historical virtual item data, which can improve the accuracy of data processing.
[0193] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0194] To this end, an embodiment of the present application provides a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute the steps of any of the virtual item determination methods provided in the embodiments of the present application. For example, the instructions can execute the following steps:
[0195] A method of receiving a virtual item acquisition request sent by a client, wherein the virtual item acquisition request indicates a target virtual item to be acquired; querying a cache database for first historical virtual item data of the client according to the virtual item acquisition request, wherein the first historical virtual item data includes the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item; when the first historical virtual item data is not found, acquiring second historical virtual item data of the client from a storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item; determining a data version of the second historical virtual item data based on the second historical acquisition time; and determining a target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item when the data version of the second historical virtual item data is the latest data version; and issuing the target virtual item to the client.
[0196] The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0197] Since the instructions stored in the computer-readable storage medium can execute the steps of any virtual item determination method provided in the embodiments of the present application, the beneficial effects that can be achieved by any virtual item determination method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0198] According to one aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the virtual item determination method provided in the above-described Summary of the Invention and embodiments.
[0199] The above is a detailed introduction to a virtual item determination method, apparatus, computer device, and computer-readable storage medium provided in an embodiment of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only intended to help understand the method and core idea of the present application. At the same time, for those skilled in the art, based on the idea of the present application, there may be changes in the specific implementation methods and application scope. In summary, the contents of this specification should not be understood as limiting the present application.
Claims
1. A method for determining a virtual item, characterized in that: include: Receiving a virtual item acquisition request sent by a client, wherein the virtual item acquisition request indicates a target virtual item to be acquired; querying, from a cache database, first historical virtual item data of the client according to the virtual item acquisition request, the first historical virtual item data including the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item; When the first historical virtual item data is found, obtaining the historical acquisition time of the client in the reference database; determining a data version of the first historical virtual item data based on the first historical acquisition time and the historical acquisition time; When the data version of the first historical virtual item data is the latest data version, determining the target virtual item corresponding to the virtual item acquisition request based on the first historical virtual item; When the first historical virtual item data is not found, obtaining second historical virtual item data of the client from a storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item; Obtaining historical acquisition time of the client from a reference database, where the historical acquisition time represents the time when the client acquired the virtual item in each historical stage; Based on the time sequence of the historical acquisition times, determining a target historical acquisition time closest to the current time from the historical acquisition times; comparing the second historical acquisition time with the target historical acquisition time, and determining a data version of the second historical virtual item data based on a comparison result; When the data version of the second historical virtual item data is the latest data version, determining the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item; The target virtual item is distributed to the client.
2. The method according to claim 1, characterized in that When the data version of the second historical virtual item data is the latest data version, before determining the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item, the method further includes: When the data version of the second historical virtual item data is not the latest data version, obtaining the historical virtual item data corresponding to the target historical acquisition time from the reference database; The target virtual item corresponding to the virtual item acquisition request is determined based on the historical virtual item data corresponding to the target historical acquisition time.
3. The method according to claim 1, characterized in that When the data version of the second historical virtual item data is the latest data version, determining the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item includes: When the data version of the second historical virtual item data is the latest data version, obtaining data processing logic corresponding to the virtual item acquisition request based on the second historical virtual item; executing the data processing logic on the virtual item acquisition request to obtain a data processing result; The target virtual item corresponding to the virtual item acquisition request is determined based on the data processing result.
4. The method according to claim 3, characterized in that When the data version of the second historical virtual item data is the latest data version, obtaining data processing logic corresponding to the virtual item acquisition request based on the second historical virtual item includes: When the data version of the second historical virtual item data is the latest data version, obtaining historical virtual item acquisition information of the client; Based on the historical virtual item acquisition information and the second historical virtual item, data processing logic corresponding to the virtual item acquisition request is acquired.
5. The method according to claim 1, wherein After the target virtual item is distributed to the client, the method includes: generating target virtual item data of the client at the current time based on the distributed target virtual item; Storing the target virtual item data in the cache database, the storage database, and the reference database; Based on the storage result, the historical virtual item data of the client in the cache database, the storage database, and the reference database are updated.
6. The method according to claim 1, characterized in that After determining the data version of the first historical virtual item data based on the first historical acquisition time and the historical acquisition time, the method further includes: When the data version of the first historical virtual item data is not the latest data version, obtaining historical virtual item data within a preset time period from the reference database; The target virtual item corresponding to the virtual item acquisition request is determined based on the historical virtual item data within the preset time period.
7. A virtual item determination device, characterized in that: include: A receiving unit, configured to receive a virtual item acquisition request sent by a client, wherein the virtual item acquisition request indicates a target virtual item to be acquired; a query unit, configured to query first historical virtual item data of the client from a cache database according to the virtual item acquisition request, wherein the first historical virtual item data includes the first historical virtual item of the client and a first historical acquisition time corresponding to the first historical virtual item; a first acquisition unit configured to, when the first historical virtual item data is found, acquire a historical acquisition time of the client from a reference database, determine a data version of the first historical virtual item data based on the first historical acquisition time and the historical acquisition time, and, when the data version of the first historical virtual item data is the latest data version, determine the target virtual item corresponding to the virtual item acquisition request based on the first historical virtual item; and, when the first historical virtual item data is not found, acquire second historical virtual item data of the client from a storage database, wherein the cache database and the storage database are deployed on different devices, and the second historical virtual item data includes the second historical virtual item of the client and a second historical acquisition time corresponding to the second historical virtual item; a first determining unit configured to obtain historical acquisition times of the client from a reference database, the historical acquisition times representing the times when the client acquired virtual items at various historical stages, determine a target historical acquisition time from the historical acquisition times based on a chronological order of the historical acquisition times, compare a second historical acquisition time with the target historical acquisition time, and determine a data version of the second historical virtual item data based on the comparison result; a second determining unit configured to determine, when the data version of the second historical virtual item data is the latest data version, the target virtual item corresponding to the virtual item acquisition request based on the second historical virtual item; The issuing unit is configured to issue the target virtual item to the client.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps of the virtual item determination method according to any one of claims 1 to 6.
9. A computer program product comprising computer instructions, characterized in that The computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, so that the computer device executes the virtual item determination method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for reading data based on data cache
CN102902730A
Data reading method and device
CN111475493A