Data access method, device and electronic device

By setting data cache objects in the game process, judging and updating data validity, the problem of high-frequency access pressure on the game server is solved, and the effect of reducing access frequency and resource consumption is achieved.

CN115766866BActive Publication Date: 2025-07-18NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211340366.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-28
Publication Date
2025-07-18
Estimated Expiration
2042-10-28

AI Technical Summary

Technical Problem

In the prior art, the game server is prone to crash when facing high-frequency shared data access, which cannot effectively reduce access pressure, resulting in paralysis of service nodes.

Method used

Set up a data cache object in the game process to determine the validity of the target data in the cache. If it is invalid, request incremental data updates from the server to reduce the frequency of direct access.

Benefits of technology

By caching data in the game process, the access frequency and pressure on the server are reduced, the resource deployment needs are reduced, and the server crash is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115766866B_ABST
    Figure CN115766866B_ABST
Patent Text Reader

Abstract

The present invention provides a data access method, apparatus, and electronic device. A game process receives a data access request sent by a target client. If the target data required by the data access request is stored in a data cache object in the game process, it is determined whether the target data in the data cache object is valid. If the target data is invalid, a first data acquisition request is sent to the server so that the server returns the incremental data of the target data. The target data stored in the data cache object is updated based on the incremental data, and the updated target data is sent to the target client. In this way, for the clients under the same game process, only the game process needs to act as an agent to request the shared data from the server once, and the shared data can be saved in the data cache object of the game process, so that the client can obtain the shared data from the data cache object, thereby reducing the access frequency of the server. Moreover, due to the natural distributed structure of the game process, the access pressure on the server is also reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular, to a data access method, apparatus, and electronic device. Background Art

[0002] In a common game architecture, a player's game client connects to a game process on a game server. Usually, each game process manages a certain number of player clients. At the same time, the game processes are distributed on one server or multiple servers. And in the game, a specified service is usually provided to manage the data shared across the whole server. The specified service is usually deployed in a specific process and can be accessed by all players.

[0003] In the related art, if the access frequency of the shared data is high, in order to reduce the access pressure on the specified service, the data can be cached locally after the player obtains the shared data, or the specified service can be sharded, that is, multiple nodes of the specified service are deployed simultaneously to reduce the access pressure on each node. However, although the above two methods can reduce the access frequency of the shared data, they cannot avoid the situation where a large number of players access the specified service or a single node simultaneously in a short period of time, which may lead to service crashes. Summary of the Invention

[0004] The purpose of the present invention is to provide a data access method, apparatus, and electronic device to reduce the access pressure on the service for managing shared data and avoid service crashes.

[0005] In a first aspect, the present invention provides a data access method, which is applied to a device running a game process. The game process is respectively connected to a server and at least one client. The server stores the shared data in the game, and a data cache object is set in the game process. The data cache object is used to cache at least part of the shared data. The method includes: receiving a data access request sent by a target client; if the target data requested by the data access request is stored in the data cache object, determining whether the target data stored in the data cache object is valid; if the target data is invalid, sending a first data acquisition request to the server to enable the server to return the incremental data of the target data, where the incremental data includes the data that is different between the server and the target data stored in the data cache object; updating the target data stored in the data cache object based on the incremental data to obtain the updated target data, and sending the updated target data to the target client.

[0006] Second aspect, the present invention provides a data access device, which is arranged in a device running a game process, and the game process is respectively connected to a server and at least one client; the server stores shared data in the game, and a data cache object is arranged in the game process, and the data cache object is used to cache at least part of the shared data; the device includes: a request receiving module, configured to receive a data access request sent by a target client; a judgment module, configured to judge whether the target data saved in the data cache object is valid if the target data requested by the data access request is saved in the data cache object; a request sending module, configured to send a first data acquisition request to the server if the target data is invalid, so that the server returns incremental data of the target data; wherein, the incremental data includes data that is different between the server and the target data saved in the data cache object; a data sending module, configured to update the target data saved in the data cache object based on the incremental data to obtain updated target data, and send the updated target data to the target client.

[0007] Third aspect, the present invention provides an electronic device, which includes a processor and a memory, and the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above data access method.

[0008] Fourth aspect, the present invention provides a computer-readable storage medium, which stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the above data access method.

[0009] The embodiments of the present invention bring the following beneficial effects:

[0010] A data access method, device, and electronic device provided by the present invention first receive a data access request sent by a target client through a game process; if the target data requested by the data access request is stored in a data cache object, it is determined whether the target data stored in the data cache object is valid; if the target data is invalid, a first data acquisition request is sent to the server so that the server returns incremental data of the target data, and the incremental data includes data that is different between the server and the target data stored in the data cache object; then, based on the incremental data, the target data stored in the data cache object is updated to obtain updated target data, and the updated target data is sent to the target client. In this method, for clients under the same game process, only the game process needs to act as an agent to request shared data from the server once, and the shared data can be saved in the data cache object of the game process, enabling the client to directly obtain the shared data from the data cache object, thereby reducing the access frequency of the server; at the same time, due to the natural distributed structure of the game process, this method does not require additional resources to deploy more nodes to share the access pressure on the server, thus reducing the consumption of resource deployment and also reducing the access pressure on the server.

[0011] Other features and advantages of the present invention will be described in the following specification, or some features and advantages can be inferred from the specification or determined without doubt, or can be learned by implementing the above technologies of the present invention.

[0012] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, details are described as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0014] Figure 1 A schematic diagram of a player client directly accessing a specified service provided by an embodiment of the present invention;

[0015] Figure 2 A schematic diagram of a player client caching data after acquisition provided by an embodiment of the present invention;

[0016] Figure 3 A schematic diagram of sharding a specified service provided by an embodiment of the present invention;

[0017] Figure 4Flowchart of a data access method provided by an embodiment of the present invention;

[0018] Figure 5 Schematic structural diagram of a data access provided by an embodiment of the present invention;

[0019] Figure 6 Flowchart of another data access method provided by an embodiment of the present invention;

[0020] Figure 7 Schematic structural diagram of a data access device provided by an embodiment of the present invention;

[0021] Figure 8 Schematic structural diagram of an electronic device provided by an embodiment of the present invention. Detailed implementation manners

[0022] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention. Usually, the components of the embodiments of the present invention described and illustrated herein can be arranged and designed in various different configurations.

[0023] Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed present invention, but merely represents selected embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0024] In a common game architecture, the game client of a player will connect to the game process of the game server. Usually, each game process will manage a certain number of player clients. At the same time, the game processes will be distributed on one server or multiple servers. And in the game, a specified service is usually provided to manage the data shared across the server. This specified service is usually deployed in a specific process and can be accessed by all players.

[0025] In the related art, if the access frequency of the shared data is low, all players can directly access the specified service to request the shared data, as Figure 1 shown in the schematic diagram of a player client directly accessing the specified service. If the access frequency of the shared data is high, if players directly access the specified service, since the access frequency that the service node can bear is limited, if all players can directly access the service of the shared data and a large number of players access simultaneously in a short time, it may cause delays in player access and even lead to the server being unable to withstand so many access requests and crashing directly, resulting in the paralysis of the service node.

[0026] To reduce the access pressure on service nodes, the following two data access methods are provided:

[0027] Method 1: After the player client obtains the shared data, it caches the obtained data and requests data from the specified service after the cache expires. For example, Figure 2 The following figure shows a schematic diagram of caching after the player client obtains data. Overall, this method can effectively reduce the frequency of accessing data, but it cannot avoid the situation where a large number of players access the service node simultaneously in a short period, which may cause the service node to crash.

[0028] Method 2: Shard the specified service, that is, deploy multiple nodes of the specified service at the same time, and then disperse the access to multiple nodes according to certain rules, so as to share the access pressure of a single node. For example, Figure 3 The following figure shows a schematic diagram of sharding the specified service. Figure 3 In the figure, the specified service is dispersed to three service nodes, namely Specified Service 1, Specified Service 2, and Specified Service 3. Each game process can access any one of the three service nodes. However, on the one hand, this method requires consuming more additional resources to deploy relevant services, and on the other hand, it is necessary to design reasonable shunting rules for specific problems to evenly distribute the access pressure to each node as much as possible. However, there is still a possibility that a large number of players access a single node simultaneously in a short period.

[0029] Based on the above problems, the embodiments of the present invention provide a data access method, device, and electronic device. This method can be applied to the data access scenario in a game, especially the access scenario of shared data in a game.

[0030] To facilitate the understanding of the embodiments of the present invention, first, a data access method disclosed in the embodiments of the present invention will be introduced in detail. This method is applied to a device running a game process, and the game process is respectively connected to a server and at least one client; the server stores the shared data in the game, and a data cache object is set in the game process, and the data cache object is used to cache at least part of the shared data. For example, Figure 4 As shown in the following figure, the method includes the following specific steps:

[0031] Step S402: Receive a data access request sent by a target client.

[0032] In the game architecture, the player's client will connect to the game process, so that each game process will manage the clients of a certain number of players. The number of clients managed by each game process can be determined according to the R & D requirements and actual applications. At the same time, a data cache object needs to be created in each game process in advance. This data cache object is used to manage and cache the shared data provided by the server. The server is used to manage and save the data shared across the entire game server (equivalent to the above-mentioned shared data). As Figure 5 shown is a schematic structural diagram of data access provided by an embodiment of the present invention, Figure 5 which contains two game processes. A data object is set in each game process. When each game process is connected to the server, it is also connected to multiple player clients.

[0033] In specific implementation, when the target client needs to access the target data, it will send a data access request to the game process. The data access request carries the identifier of the target data. Specifically, each data in the shared data carries its own identifier, and this identifier is unique; the target client can be any client communicatively connected to the game process.

[0034] It should be noted that the above game process usually also runs the server, that is, the device running the game process can be one or more servers of the server.

[0035] Step S404, if the target data requested by the data access request is saved in the data cache object, determine whether the target data saved in the data cache object is valid.

[0036] When receiving the data access request sent by the target client, the game process will check whether the target data requested by the data access request is saved in the data cache object. If the target data is saved, it will also determine whether the target data saved in the data cache object is valid. If it is valid, it will send the target data saved in the data cache object to the target client; if it is invalid, it needs to access the server to request the incremental data of the target data. This increment is the part of the target data saved by the server that has changed.

[0037] If the target data requested by the data access request is not saved in the data cache object, it will request the full amount of data of the target data from the server. This full amount of data is also all the data of the target data in the shared data saved by the server; when the server returns the target data to the game process, the game process will save the received target data to the data cache object and send the target data to the target client.

[0038] In practical applications, since the shared data has been stored in the server's database, some of the shared data saved by the data cache object does not need to be persistently stored. The data cache object only responds to the data access requests sent by the client. Therefore, the data cache object only needs to store the managed data in memory. If the data stored in this memory is lost or invalidated, the data cache object only needs to obtain the data from the server again.

[0039] Step S406, if the target data is invalid, send a first data acquisition request to the server to enable the server to return the incremental data of the target data; wherein, the incremental data includes the data that is different between the data saved by the server and the data cache object for the target data.

[0040] The incremental data of the above-mentioned target data refers to: the different data of the target data saved in the data cache object and the server; whether the data in the server is modified, added, or deleted, it will be updated incrementally. For example, if a player requests the data of an article, then the modified part, the newly added part, and the deleted part of this article can all be called incremental data.

[0041] In specific implementation, if the target data saved in the data cache object is invalid, the game process will send a first data acquisition request to the server. After receiving the first data acquisition request, the server will query the incremental quantity of the target data, and then return the queried incremental data to the game process to enable the game process to update the target data cached in the data cache object.

[0042] Step S408, update the target data saved in the data cache object based on the incremental data to obtain the updated target data, and send the updated target data to the target client.

[0043] The data cache object will update the target data it saves according to the received incremental data of the target data to obtain the updated target data. The updated target data saved in the data cache object is the same as the target data saved in the server.

[0044] It should be noted that the number of game processes is often much less than the number of players in the game, that is, the number of game processes is much smaller than the number of player clients. Even in the worst case, when all game processes send data acquisition requests to the server simultaneously, the request volume is also certain and relatively controllable.

[0045] A data access method provided by an embodiment of the present invention first receives a data access request sent by a target client through a game process; if the target data requested by the data access request is stored in a data cache object, it is determined whether the target data stored in the data cache object is valid; if the target data is invalid, a first data acquisition request is sent to the server so that the server returns the incremental data of the target data, and the incremental data includes the data that is different between the server and the target data stored in the data cache object; then, based on the incremental data, the target data stored in the data cache object is updated to obtain the updated target data, and the updated target data is sent to the target client. In this way, for the clients under the same game process, only the game process needs to act as an agent to request the shared data from the server once, and the shared data can be saved in the data cache object of the game process, so that the client can directly obtain the shared data from the data cache object, thereby reducing the access frequency of the server; at the same time, due to the natural distributed structure of the game process, this method does not require additional resources to deploy more nodes to share the access pressure of the server, thus reducing the consumption of resource deployment and also reducing the access pressure of the server.

[0046] Another data access method is also provided by an embodiment of the present invention. This method is implemented on the basis of the above embodiment, and this method focuses on describing the specific process of determining whether the target data stored in the data cache object is valid (specifically implemented through the following step S606); as Figure 6 shown, this method includes the following specific steps:

[0047] Step S602, receive a data access request sent by a target client.

[0048] Step S604, determine whether the target data requested by the data access request is stored in the data cache object; if so, execute step S606, otherwise execute step S614.

[0049] In specific implementation, when the game process receives a data access request sent by a player through a target client, it will first check whether the target data requested by the data access request exists in the data cache object. If it does not exist, it will request the target data from the server through the game process, then save the requested target data in the data cache object, and send the target data to the target client; if the target data exists in the data cache object and the target data is valid, the target data will be directly sent to the target client; if the target data exists in the data cache object, but the target data is invalid, the incremental data of the target data will be obtained from the server, and the data cache object will update the target data it stores based on the incremental data, and send the updated target data to the target client.

[0050] Step S606: Determine whether the storage time of the target data in the data cache object exceeds a preset valid time. If it exceeds the preset valid time, execute Step S608; otherwise, execute Step S612.

[0051] In specific implementation, it is possible to determine whether the target data in the data cache object is valid by judging whether the storage time of the target data in the data cache object exceeds the preset valid time. Among them, the preset valid time matches the access frequency of the server. Generally, the higher the access frequency of the server, the longer the preset valid time; the lower the access frequency, the shorter the preset valid time. In this way, the maximum access frequency of each game process can be controlled, and through the adjustment of the preset valid time, the data timeliness can be controlled. If the access frequency is low, the preset valid time can be reduced to improve data real-time performance; when the access frequency is high, the preset valid time can be extended to reduce the access pressure on the server.

[0052] In specific implementation, the above-mentioned preset valid time can be determined in the following way: count the number of times the server is accessed within a preset time period, and determine the service access frequency as the ratio of the number of accesses to the preset time period. If the service access frequency is greater than the maximum frequency threshold, determine the preset valid time as the sum of the first time and the second time; if the service access frequency is less than the minimum frequency threshold, determine the preset valid time as the difference between the first time and the third time; if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, determine the preset valid time as the first time.

[0053] The specific value of the above-mentioned preset time period can be set according to R & D requirements. For example, the preset time period can be one hour or 30 minutes, etc. The specific values of the above-mentioned first time, second time, and third time can also be set according to R & D requirements. For example, the first time can be 40 minutes, the second time can be 10 minutes, and the third time can also be 10 minutes, etc.; the above-mentioned maximum frequency threshold and minimum frequency threshold can also be set according to R & D requirements.

[0054] In practical applications, the above-mentioned second time and third time may not be fixed values, but values that can change according to preset rules. Specifically, the above-mentioned second time can include: the first product of the number of times the service access frequency continuously exceeds the maximum frequency threshold and the first value. Among them, if the first product is greater than the preset maximum time, determine the second time as the preset maximum time; the above-mentioned third time can include: the second product of the number of times the service access frequency continuously is less than the minimum frequency threshold and the second value. If the second product is less than the preset minimum time, determine the third time as the preset minimum time. The specific values of the above-mentioned first value, second value, preset maximum time, and preset minimum time can be set according to R & D requirements.

[0055] For example, it is stipulated that the server calculates the service access frequency based on the number of accesses in the past t seconds. The maximum frequency threshold for the server to be accessed is max times per second, and the minimum frequency threshold is min times per second. The server will regularly take statistics on the access frequency in the past t seconds. When the server is accessed x times in the past t seconds, the service access frequency of the server is x / t times per second. When x / t is greater than max, when the server that shares data sends data to the data cache object of the game process, it will extend the preset valid time of these data. For example, if the original data valid time is a seconds (equivalent to the above-mentioned first time), and it is found in this statistics that x / t is greater than max, then the preset valid time of the data can be set to a + b seconds in the future. If x / t is greater than max in the next statistics, the preset valid time of the data is set to a + 2b. Here, b is the second time. Similarly, when x / t is less than min, the preset valid time of the data is set to a - c, a - 2c, etc., where c is equivalent to the above-mentioned third time.

[0056] At the same time, it is also necessary to set the preset maximum time to tmax and the preset minimum time to tmin to prevent the preset valid time from being too long or too short. If the time a + n*b to be set is greater than tmax, use tmax, or if a - n*b is less than tmin, use tmin. Here, n represents the number of times the service access frequency is continuously greater than the maximum frequency threshold or the number of times the service access frequency is continuously less than the minimum frequency threshold.

[0057] Step S608, determine that the target data saved in the data cache object is invalid, and send a first data acquisition request to the server to enable the server to return the incremental data of the target data; then execute step S610.

[0058] When the amount of data requested by the player is relatively large, the method of obtaining the latest data by the data cache object requesting incremental data has a much smaller transmission volume than requesting the full amount of data, thereby improving the data access speed. In specific implementation, there are many ways to obtain incremental data. For example, the server makes a time mark for each data modification, and the data cache object in the game process can pull the incremental data according to the time mark; or version control is introduced in the server, and the data cache object in the game process can also synchronize the incremental data according to its own data version.

[0059] Based on the above description, the update time of each data in the shared data can be saved in the server. The above step S608 can be implemented through the following steps 10 - 11:

[0060] Step 10, send a first data acquisition request to the server; among them, the first data acquisition request includes the most recent acquisition time of the target data in the data cache object.

[0061] Step 11: Through the server, search for the first piece of data in the target data whose update time is after the acquisition time, use the first piece of data as the incremental data, and return the incremental data.

[0062] For example, the data cache object in the game process first obtained the target data [1, 2, 3, 4] at time a; but at time b, the server expanded the target data by the data [5] to become [1, 2, 3, 4, 5], and at time c, the server modified the data [2] in the target data to data [6], and the target data became [1, 6, 3, 4, 5]. At this time, when the data cache object finds that the target data is invalid and pulls the latest incremental data, it will obtain the modified data after time a of the data it obtained, that is, the data [5] added at time b and the data [2] modified to data [6] at time c. Then the data cache object combines the modified data with the target data it holds to obtain the updated target data.

[0063] In some embodiments, the server may also store the version number of each piece of data in the shared data; based on this, the above step S608 can also be implemented through the following steps 20-21:

[0064] Step 20: Send a first data acquisition request to the server; wherein, the first data acquisition request includes the version number of the target data saved in the data cache object.

[0065] Step 21: Determine the incremental data of the target data according to the version number of the target data saved in the server and the version number carried in the first data acquisition request, and return the incremental data.

[0066] For example, the version number of the target data saved in the data cache object is 1.0. When the target data is invalid and the data cache object requests the incremental data of the target data from the server, the target data has been modified through version 2.0 and version 3.0 in the server. Then, the modifications of each version (that is, the incremental data of the target data) can be synchronized to the data cache object through the version number, so that the data cache object can update the target data it saves.

[0067] Step S610: Update the target data saved in the data cache object based on the incremental data to obtain the updated target data, and send the updated target data to the target client.

[0068] Step S612: Send the target data saved in the data cache object to the target client.

[0069] In specific implementation, if the target data exists in the data cache object and the target data is valid, the target data saved in the data cache object will be directly sent to the target client.

[0070] Step S614: Send a second data acquisition request to the server to cause the server to return the target data; save the received target data to the data cache object and send the target data to the target client.

[0071] If the target data is not included in the data cache object, the game process will send a second data acquisition request to the server to request the full amount of the target data from the server through this second acquisition request. There may be a certain transmission pressure in the process of requesting the full amount of data, but the frequency of requesting the full amount of data is very low. When the game process receives the full amount of the target data sent by the server, it will save the target data to the data cache object and send the target data to the target client.

[0072] It should be noted that when the server sends the full amount of the target data and the incremental data of the target data to the game process, it will also send the preset valid time of the target data to the game process, and the preset valid time is used to indicate whether the target data saved in the data cache object is valid at the current time. In addition, within the preset valid time of the target data, it is possible to avoid requesting the target data from the server again, thereby reducing the access pressure on the server.

[0073] The above data access method can solve the problem of frequent access to the full-server shared data in the game. This method uses a data cache object that manages the shared data cache in the game process, which can reduce the request frequency of the shared data in the server. At the same time, the number of game processes also limits the maximum simultaneous access volume to the server, thereby reducing the service pressure on the server. At the same time, by adjusting the cache valid time, it is possible to more flexibly balance between the data request frequency and the data real-time performance.

[0074] For the above method embodiments, the embodiments of the present invention further provide a data access device. This device is set in the device running the game process, and the game process is respectively connected to the server and at least one client; the server stores the shared data in the game, and a data cache object is set in the game process, and the data cache object is used to cache at least part of the shared data; as Figure 7 shown, this device includes:

[0075] A request receiving module 70, configured to receive a data access request sent by the target client.

[0076] A judgment module 71, configured to judge whether the target data saved in the data cache object is valid if the target data requested by the data access request is saved in the data cache object.

[0077] A request sending module 72, configured to send a first data acquisition request to a server if the target data is invalid, so that the server returns incremental data of the target data; wherein, the incremental data includes data that is different between the server and the target data saved in the data cache object.

[0078] A data sending module 73, configured to update the target data saved in the data cache object based on the incremental data to obtain updated target data, and send the updated target data to a target client.

[0079] The above data access device first receives a data access request sent by a target client through a game process; if the target data requested by the data access request is saved in the data cache object, it determines whether the target data saved in the data cache object is valid; if the target data is invalid, it sends a first data acquisition request to the server, so that the server returns incremental data of the target data, and the incremental data includes data that is different between the server and the target data saved in the data cache object; then it updates the target data saved in the data cache object based on the incremental data to obtain updated target data, and sends the updated target data to the target client. In this way, for clients under the same game process, only the game process needs to act as an agent to request shared data from the server once, and the shared data can be saved in the data cache object of the game process, enabling the client to directly obtain the shared data from the data cache object, thereby reducing the access frequency of the server; at the same time, due to the natural distributed structure of the game process, this method requires additional resources to deploy more nodes to share the access pressure on the server, thereby reducing the consumption of resource deployment and also reducing the access pressure on the server.

[0080] Further, the above device further includes a data acquisition module, configured to: if the target data requested by the data access request is not saved in the data cache object, send a second data acquisition request to the server, so that the server returns the target data; save the received target data to the data cache object, and send the target data to the target client.

[0081] In specific implementation, the above determination module 71 is configured to: determine whether the time for which the target data is saved in the data cache object exceeds a preset valid time; if it exceeds the preset valid time, determine that the target data is invalid; wherein, the preset valid time matches the access frequency of the server.

[0082] Specifically, the above device further includes an effective time determination module, which is used to: count the number of times the server is accessed within a preset time period, and determine the ratio of the number of accesses to the preset time period as the service access frequency; if the service access frequency is greater than the maximum frequency threshold, determine the preset effective time as the sum of the first time and the second time; if the service access frequency is less than the minimum frequency threshold, determine the preset effective time as the difference between the first time and the third time; if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, determine the preset effective time as the first time.

[0083] In practical applications, the above second time includes: the first product of the number of times the service access frequency is continuously greater than the maximum frequency threshold and a first value; wherein, if the first product is greater than the preset maximum time, determine the second time as the preset maximum time; the third time includes: the second product of the number of times the service access frequency is continuously less than the minimum frequency threshold and a second value; if the second product is less than the preset minimum time, determine the third time as the preset minimum time.

[0084] Further, each data in the shared data is stored in the above server with its update time; the above request sending module 72 is used to: send a first data acquisition request to the server; wherein, the first data acquisition request contains the most recent acquisition time of the target data in the data cache object; through the server, search for the first data in the target data whose update time is after the acquisition time, and use the first data as the incremental data and return the incremental data.

[0085] Further, each data in the shared data is stored in the above server with its version number; the above request sending module 72 is further used to: send a first data acquisition request to the server; wherein, the first data acquisition request contains the version number of the target data stored in the data cache object; determine the incremental data of the target data according to the version number of the target data stored in the server and the version number carried by the first data acquisition request, and return the incremental data.

[0086] In specific implementation, the above device further includes a data transmission module, which is used to: if the target data is valid, send the target data stored in the data cache object to the target client.

[0087] The data access device provided by the embodiments of the present invention has the same implementation principle and the same technical effects as those of the foregoing method embodiments. For the sake of brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding content in the foregoing method embodiments.

[0088] The embodiments of the present invention also provide an electronic device, such as Figure 8As shown in the figure, the electronic device includes a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above data access method.

[0089] Specifically, the above data access method is applied to a device running a game process. The game process is respectively connected to a server and at least one client; the server stores shared data in the game, and a data cache object is set in the game process. The data cache object is used to cache at least part of the shared data; the method includes: receiving a data access request sent by a target client; if the target data requested by the data access request is stored in the data cache object, determining whether the target data stored in the data cache object is valid; if the target data is invalid, sending a first data acquisition request to the server to enable the server to return the incremental data of the target data; wherein, the incremental data includes the data that is different between the server and the target data stored in the data cache object; updating the target data stored in the data cache object based on the incremental data to obtain the updated target data, and sending the updated target data to the target client.

[0090] In the above data access method, for the clients under the same game process, only the game process needs to request the shared data from the server as an agent once, and then the shared data can be saved to the data cache object of the game process, so that the client can directly obtain the shared data from the data cache object, thus reducing the access frequency of the server; at the same time, due to the natural distributed structure of the game process, this method requires additional resources to deploy more nodes to share the access pressure of the server, thereby reducing the consumption of resource deployment and also reducing the access pressure of the server.

[0091] In an alternative embodiment, the above method further includes: if the target data requested by the data access request is not stored in the data cache object, sending a second data acquisition request to the server to enable the server to return the target data; saving the received target data to the data cache object, and sending the target data to the target client.

[0092] In an alternative embodiment, the step of determining whether the target data stored in the data cache object is valid includes: determining whether the time for which the target data is stored in the data cache object exceeds a preset valid time; if it exceeds the preset valid time, determining that the target data is invalid; wherein, the preset valid time matches the access frequency of the server.

[0093] In an alternative embodiment, the above-mentioned preset valid time is determined in the following manner: the number of times the server is accessed within a preset time period is counted, and the ratio of the number of accesses to the preset time period is determined as the service access frequency; if the service access frequency is greater than the maximum frequency threshold, the preset valid time is determined as the sum of a first time and a second time; if the service access frequency is less than the minimum frequency threshold, the preset valid time is determined as the difference between the first time and a third time; if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, the preset valid time is determined as the first time.

[0094] In an alternative embodiment, the above-mentioned second time includes: the first product of the number of times the service access frequency is continuously greater than the maximum frequency threshold and a first value; wherein, if the first product is greater than the preset maximum time, the second time is determined as the preset maximum time; the third time includes: the second product of the number of times the service access frequency is continuously less than the minimum frequency threshold and a second value; if the second product is less than the preset minimum time, the third time is determined as the preset minimum time.

[0095] In an alternative embodiment, the server stores the update time of each data in the shared data; the step of sending a first data acquisition request to the server to enable the server to return the incremental data of the target data includes: sending a first data acquisition request to the server; wherein, the first data acquisition request contains the most recent acquisition time of the target data in the data cache object; through the server, search for the first data in the target data whose update time is after the acquisition time, and use the first data as the incremental data and return the incremental data.

[0096] In an alternative embodiment, the server stores the version number of each data in the shared data; the step of sending a first data acquisition request to the server to enable the server to return the incremental data of the target data includes: sending a first data acquisition request to the server; wherein, the first data acquisition request contains the version number of the target data saved in the data cache object; determine the incremental data of the target data according to the version number of the target data saved in the server and the version number carried by the first data acquisition request, and return the incremental data.

[0097] In an alternative embodiment, the above-mentioned method further includes: if the target data is valid, sending the target data saved in the data cache object to the target client.

[0098] Further, Figure 8 The illustrated electronic device further includes a bus 102 and a communication interface 103, and the processor 101, the communication interface 103, and the memory 100 are connected through the bus 102.

[0099] Among them, the memory 100 may include high-speed random access memory (RAM), and may also include non-volatile memory, such as at least one disk memory. The communication connection between this system network element and at least one other network element is realized through at least one communication interface 103 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 102 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 8 only a bidirectional arrow is used in Figure 8 , but it does not mean that there is only one bus or one type of bus.

[0100] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor 101 or instructions in software form. The above-mentioned processor 101 can be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it can also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers, etc. This storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and combines its hardware to complete the steps of the method in the foregoing embodiments.

[0101] The embodiments of the present invention also provide a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the above data access method. For the specific implementation, reference can be made to the method embodiments, which will not be elaborated here.

[0102] Specifically, the above data access method is applied to a device running a game process, and the game process is respectively connected to a server and at least one client; the server stores shared data in the game, and a data cache object is set in the game process, and the data cache object is used to cache at least part of the shared data; the method includes: receiving a data access request sent by a target client; if the target data requested by the data access request is stored in the data cache object, determining whether the target data stored in the data cache object is valid; if the target data is invalid, sending a first data acquisition request to the server to enable the server to return incremental data of the target data; wherein, the incremental data includes data that is different between the server and the target data stored in the data cache object; updating the target data stored in the data cache object based on the incremental data to obtain updated target data, and sending the updated target data to the target client.

[0103] In the above data access method, for clients under the same game process, only the game process needs to request shared data from the server as an agent once, and the shared data can be saved to the data cache object of the game process, so that the client can directly obtain the shared data from the data cache object, thereby reducing the access frequency of the server; at the same time, due to the natural distributed structure of the game process, this method requires additional resources to deploy more nodes to share the access pressure of the server, thereby reducing the consumption of resource deployment and also reducing the access pressure of the server.

[0104] In an alternative embodiment, the above method further includes: if the target data requested by the data access request is not stored in the data cache object, sending a second data acquisition request to the server to enable the server to return the target data; saving the received target data to the data cache object, and sending the target data to the target client.

[0105] In an alternative embodiment, the step of determining whether the target data stored in the data cache object is valid includes: determining whether the time when the target data is stored in the data cache object exceeds a preset valid time; if it exceeds the preset valid time, determining that the target data is invalid; wherein, the preset valid time matches the access frequency of the server.

[0106] In an alternative embodiment, the above-mentioned preset valid time is determined in the following manner: count the number of times the server is accessed within a preset time period, and determine the ratio of the number of accesses to the preset time period as the service access frequency; if the service access frequency is greater than the maximum frequency threshold, determine the preset valid time as the sum of a first time and a second time; if the service access frequency is less than the minimum frequency threshold, determine the preset valid time as the difference between the first time and a third time; if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, determine the preset valid time as the first time.

[0107] In an alternative embodiment, the above-mentioned second time includes: the first product of the number of times the service access frequency is continuously greater than the maximum frequency threshold and a first value; wherein, if the first product is greater than the preset maximum time, determine the second time as the preset maximum time; the third time includes: the second product of the number of times the service access frequency is continuously less than the minimum frequency threshold and a second value; if the second product is less than the preset minimum time, determine the third time as the preset minimum time.

[0108] In an alternative embodiment, the server stores the update time of each data in the shared data; the step of sending a first data acquisition request to the server to enable the server to return the incremental data of the target data includes: sending a first data acquisition request to the server; wherein, the first data acquisition request contains the most recent acquisition time of the target data in the data cache object; through the server, search for the first data in the target data whose update time is after the acquisition time, and use the first data as the incremental data and return the incremental data.

[0109] In an alternative embodiment, the server stores the version number of each data in the shared data; the step of sending a first data acquisition request to the server to enable the server to return the incremental data of the target data includes: sending a first data acquisition request to the server; wherein, the first data acquisition request contains the version number of the target data stored in the data cache object; determine the incremental data of the target data according to the version number of the target data stored in the server and the version number carried in the first data acquisition request, and return the incremental data.

[0110] In an alternative embodiment, the above-mentioned method further includes: if the target data is valid, send the target data stored in the data cache object to the target client.

[0111] When the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a terminal device, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0112] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation to the present invention. In addition, the terms "first", "second", "third" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance.

[0113] Finally, it should be noted that the above-mentioned embodiments are only specific embodiments of the present invention, used to illustrate the technical solutions of the present invention, rather than limiting them. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed by the present invention can still modify the technical solutions recorded in the foregoing embodiments, or can easily think of changes, or make equivalent replacements for some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A data access method, characterized in that, The method is applied to a device running a game process, and the game process is connected to a server and at least one client respectively; the server stores shared data in the game, the server is connected to multiple game processes respectively, and data cache objects are respectively set in the multiple game processes, and the data cache objects are used to cache at least part of the shared data; the method includes: Receiving a data access request sent by a target client; If the target data requested by the data access request is stored in the data cache object, determining whether the target data stored in the data cache object is valid; If the target data is invalid, sending a first data acquisition request to the server to enable the server to return incremental data of the target data; wherein, the incremental data includes data that is different between the server and the target data stored in the data cache object; Updating the target data stored in the data cache object based on the incremental data to obtain updated target data, and sending the updated target data to the target client; The step of determining whether the target data stored in the data cache object is valid includes: determining whether the time when the target data is stored in the data cache object exceeds a preset valid time; if it exceeds the preset valid time, determining that the target data is invalid; wherein, the preset valid time matches the access frequency of the server.

2. The method according to claim 1, characterized in that, The method further includes: If the target data requested by the data access request is not stored in the data cache object, sending a second data acquisition request to the server to enable the server to return the target data; Saving the received target data to the data cache object and sending the target data to the target client.

3. The method according to claim 1, wherein The preset valid time is determined by the following method: Counting the number of times the server is accessed within a preset time period, and determining the ratio of the number of accesses to the preset time period as the service access frequency; If the service access frequency is greater than the maximum frequency threshold, determining the preset valid time as the sum of a first time and a second time; If the service access frequency is less than the minimum frequency threshold, determining the preset valid time as the difference between the first time and a third time; If the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, determining the preset valid time as the first time.

4. The method according to claim 3, characterized in that The second time includes: the first product of the number of times the service access frequency is continuously greater than the maximum frequency threshold and a first value; wherein, if the first product is greater than a preset maximum time, determining the second time as the preset maximum time; The third time includes: the second product of the number of times the service access frequency is continuously less than the minimum frequency threshold and a second value; if the second product is less than a preset minimum time, determining the third time as the preset minimum time.

5. The method according to claim 1, wherein The update time of each data in the shared data is stored in the server; The step of sending a first data acquisition request to the server to enable the server to return incremental data of the target data includes: Sending a first data acquisition request to the server; wherein, the first data acquisition request contains the most recent acquisition time of the target data in the data cache object; Through the server, searching for first data in the target data whose update time is after the acquisition time, using the first data as incremental data, and returning the incremental data.

6. The method according to claim 1, characterized in that, The server stores the version number of each data in the shared data; The step of sending a first data acquisition request to the server to enable the server to return incremental data of the target data includes: Sending a first data acquisition request to the server; wherein, the first data acquisition request contains the version number of the target data saved in the data cache object; Determining the incremental data of the target data according to the version number of the target data saved by the server and the version number carried in the first data acquisition request, and returning the incremental data.

7. The method according to claim 1, wherein The method further includes: If the target data is valid, sending the target data saved in the data cache object to the target client.

8. A data access device, characterized in that, The device is disposed in a device running a game process, the game process is respectively connected to a server and at least one client; the server stores shared data in the game, the server is respectively connected to a plurality of game processes, and data cache objects are respectively disposed in the plurality of game processes, and the data cache object is used to cache at least part of the shared data; the device includes: A request receiving module, configured to receive a data access request sent by a target client; A judgment module, configured to, if the target data requested by the data access request is saved in the data cache object, judge whether the target data saved in the data cache object is valid; A request sending module, configured to, if the target data is invalid, send a first data acquisition request to the server to enable the server to return incremental data of the target data; wherein, the incremental data includes data that is different between the target data saved by the server and the data cache object; A data sending module, configured to update the target data saved in the data cache object based on the incremental data to obtain updated target data, and send the updated target data to the target client; The above-mentioned judgment module is further configured to: judge whether the time for which the target data is saved in the data cache object exceeds a preset valid time; if it exceeds the preset valid time, determine that the target data is invalid; wherein, the preset valid time matches the access frequency of the server.

9. An electronic device, characterized in that, Including a processor and a memory, the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the data access method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that, when called and executed by a processor, cause the processor to implement the data access method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data access method, device, computer equipment and storage medium

    CN110471939A

  • Game data processing method and device, server and storage medium

    CN111930740A

  • Back-end data access system, method and device and storage medium

    CN113810455A