CN115766866A - Data access method and device and electronic equipment - Google Patents

Data access method and device and electronic equipment Download PDF

Info

Publication number
CN115766866A
CN115766866A CN202211340366.4A CN202211340366A CN115766866A CN 115766866 A CN115766866 A CN 115766866A CN 202211340366 A CN202211340366 A CN 202211340366A CN 115766866 A CN115766866 A CN 115766866A
Authority
CN
China
Prior art keywords
data
server
target
time
cache object
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211340366.4A
Other languages
Chinese (zh)
Inventor
陈颖
李晓天
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202211340366.4A priority Critical patent/CN115766866A/en
Publication of CN115766866A publication Critical patent/CN115766866A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a data access method, a data access device and electronic equipment.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 the data cache object in the game process, judging whether the target data in the data cache object is valid; if the target data is invalid, sending a first data acquisition request to the server so that the server returns incremental data of the target data; and updating the target data stored in the data cache object based on the incremental data, and sending the updated target data to the target client. In the mode, the client in the same game process can store the shared data into the data cache object of the game process only by taking the game process as an agent to request the server for sharing data once, so that the client can obtain the shared data from the data cache object, and the access frequency of the server is reduced; and due to the natural distributed structure of the game process, the access pressure of the server is also relieved.

Description

Data access method and device and electronic equipment
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a data access method, an apparatus, and an electronic device.
Background
In a common game architecture, a game client of a player is connected to a game process of a game server, each game process usually manages a certain number of player clients, the game processes are distributed on one server or a plurality of servers, and a specified service is usually provided in a game for managing data shared by all the servers, the specified service is usually deployed in a specific process, and all the players can access the specified service.
In the related art, if the access frequency of the shared data is high, in order to reduce the access pressure of the specified service, the player can cache the data after obtaining the shared data, and can also perform fragmentation processing on the specified service, so that the specified service is deployed with a plurality of nodes at the same time, and the access pressure of each node is reduced; however, although the above two methods can reduce the access frequency of shared data, it is inevitable that a specific service or a large number of players access a single node at the same time in a short time, which may result in a service breakdown.
Disclosure of Invention
The invention aims to provide a data access method, a data access device and electronic equipment, so as to reduce the access pressure of a service for managing shared data and avoid service breakdown.
In a first aspect, the present invention provides a data access method, which is applied to a device running a game process, where the game process is connected to a server and at least one client respectively; the server side stores shared data in a game, a data cache object is arranged in the game process, and the data cache object is used for caching at least part of the shared data; the method comprises the following steps: 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, judging 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 so that the server returns incremental data of the target data; the incremental data comprises data with difference in target data stored by the server and the data cache object; and 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.
In a second aspect, the present invention provides a data access apparatus, which is disposed on a device running a game process, wherein the game process is respectively connected to a server and at least one client; the server side stores shared data in a game, a data cache object is arranged in the game process, and the data cache object is used for caching at least part of the shared data; the device includes: the request receiving module is used for receiving a data access request sent by a target client; the judging module is used for judging whether the target data stored by the data cache object is valid or not if the target data requested by the data access request is stored in the data cache object; the request sending module is used for sending a first data acquisition request to the server side if the target data is invalid so as to enable the server side to return incremental data of the target data; the incremental data comprises data with difference in target data stored by the server and the data cache object; and the data sending module is used for 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.
In a third aspect, the present invention provides an electronic device comprising a processor and a memory, the memory storing machine executable instructions capable of being executed by the processor, the processor executing the machine executable instructions to implement the data access method described above.
In a fourth aspect, the present invention provides a computer-readable storage medium having stored thereon computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the above-described data access method.
The embodiment of the invention has the following beneficial effects:
the invention provides a data access method, a data access device and electronic equipment.A data access request sent by a target client is received through a game process; if the target data requested by the data access request is stored in the data cache object, judging 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 so that the server returns incremental data of the target data, wherein the incremental data comprises data which is different from the target data stored by the server and the data cache object; the target data stored in the data cache object is then updated based on the delta data, and obtaining the updated target data, and sending the updated target data to the target client. In the mode, the client under the same game process can store the shared data into the data cache object of the game process only by taking the game process as an agent to request the server for sharing data once, so that the client can directly acquire the shared data from the data cache object, and the access frequency of the server is reduced; meanwhile, due to the natural distributed structure of the game process, the mode needs to consume additional resources to deploy more nodes to share the access pressure of the server, so that the resource deployment consumption is reduced, and the access pressure of the server is also reduced.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention as set forth above.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a diagram illustrating a player client directly accessing a specified service according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a player client caching data after acquiring data according to an embodiment of the present invention;
fig. 3 is a schematic diagram of performing fragmentation processing on a specific service according to an embodiment of the present invention;
fig. 4 is a flowchart of a data access method according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a data access according to an embodiment of the present invention;
FIG. 6 is a flow chart of another data access method provided by an embodiment of the invention;
fig. 7 is a schematic structural diagram of a data access device according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, 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 drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In a common game architecture, a game client of a player is connected to a game process of a game server, each game process usually manages a certain number of player clients, the game processes are distributed on one server or a plurality of servers, and a specified service is usually provided in a game for managing data shared by all the servers, the specified service is usually deployed in a specific process, and all the players can access the specified service.
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 shown in fig. 1, which is a schematic diagram of a player client directly accessing the specified service. If the access frequency of the shared data is high, if the player directly accesses the specified service, because the access frequency carried by the service node is limited, if all players can directly access the service of the shared data and a large number of players simultaneously access in a short time, the access delay of the player can be caused, and even the server can not bear the direct breakdown of so many access requests, and the service node is paralyzed.
In order to reduce the access pressure of the service node, the following two data access modes are provided:
in a first manner, after obtaining the shared data, the player client caches the obtained data, and requests the specified service for data after the cache fails, as shown in fig. 2, which is a schematic diagram of caching after the player client obtains the data. As a whole, this approach can effectively reduce the frequency of accessing data, but cannot avoid a situation where a large number of players simultaneously access the service node in a short time, which may cause the service node to crash.
In a second manner, the designated service is fragmented, that is, the designated service is deployed at the same time by a plurality of nodes, so that access is distributed to the plurality of nodes according to a certain rule, and thus the access pressure of a single node is shared, as shown in fig. 3, a schematic diagram of fragmenting the designated service is shown, in fig. 3, the designated service is distributed to three service nodes, that is, a designated service 1, a designated service 2, and a designated service 3, and each game process can access any one of the three service nodes. But this approach needs to consume more extra resources to deploy related services on one hand, and needs to design a reasonable distribution rule for specific problems to distribute the access pressure to each node as evenly as possible on the other hand, but there is still a possibility that a large number of players access the node simultaneously in a short time.
Based on the above problem, embodiments of the present invention provide a data access method, an apparatus, and an electronic device, where the method may be applied in a data access scenario in a game, especially in an access scenario of shared data in a game.
In order to facilitate understanding of the embodiment of the present invention, a data access method disclosed in the embodiment of the present invention is first described in detail, where 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 a game, and a data cache object is arranged in the game process and used for caching at least part of the shared data; as shown in fig. 4, the method includes the following specific steps:
step S402, receiving a data access request sent by a target client.
In the game architecture, the client terminals of the players are connected to the game processes, so that each game process manages a certain number of client terminals of the players, and the number of the client terminals managed by each game process can be determined according to research and development requirements and practical application. Meanwhile, a data cache object is created in advance in each game process, and the data cache object is used for managing and caching shared data provided by a server. The server manages and stores data (corresponding to the shared data) shared by all game servers. Fig. 5 is a schematic structural diagram of data access according to an embodiment of the present invention, where fig. 5 includes two game processes, each game process is provided with a data object, and each game process is connected to a server and a plurality of player clients.
In specific implementation, when a target client needs to access target data, a data access request is sent to a game process, and the data access request carries an identifier of the target data. Specifically, each piece of data in the shared data carries a respective identifier, and the identifier has uniqueness; the target client may be any client communicatively connected to the game process.
It should be noted that, the game process is also generally executed on the server side, that is, the device running the game process may be one server or multiple servers on the server side.
Step S404, 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.
When a data access request sent by a target client is received, the game process checks whether target data requested by the data access request is stored in a data cache object, if so, judges whether the target data stored in the data cache object is valid, and if so, sends the target data stored in the data cache object to the target client; and if the target data is invalid, the server needs to be accessed to request the incremental data of the target data, wherein the increment is the changed data part in the target data stored by the server.
If the target data requested by the data access request is not stored in the data cache object, requesting the server for the full data of the target data, wherein the full data is all the data of the target data in the shared data stored by the server; when the server returns the target data to the game process, the game process stores the received target data into the data cache object and sends the target data to the target client.
In practical application, since the shared data is already stored in the database of the server, part of the shared data stored by the data cache object does not need to be stored persistently, and the data cache object is only responsible for responding to a data access request sent by the client, so that the data cache object only needs to store the managed data in the memory, and the data stored in the memory is lost or invalid, and only needs to obtain the data from the server again by the data cache object.
Step S406, if the target data is invalid, sending a first data acquisition request to the server so that the server returns incremental data of the target data; the incremental data comprises data with difference in target data stored by the server and the data cache object.
The incremental data of the target data is: difference data of target data stored in the data cache object and the server side; whether the data in the server is modified or added or deleted data, the data is updated in an incremental manner, for example, a player requests data of an article, and the modified part, the added part and the deleted part of the article can be called incremental data.
In specific implementation, if the target data stored in the data cache object is invalid, the game process sends a first data acquisition request to the server, and after receiving the first data acquisition request, the server queries the increment number of the target data and then returns the queried increment data to the game process, so that the game process updates the target data cached in the data cache object.
Step S408, 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 data cache object updates the target data stored by the data cache object according to the received incremental data of the target data to obtain the updated target data. The updated target data stored in the data cache object is the same as the target data stored in the server.
It should be noted that the number of game processes is often much smaller than the number of players in the game, that is, the number of game processes is much smaller than the number of player clients, and in the worst case, all game processes simultaneously send data acquisition requests to the server, and the request amount is also certain and relatively controllable.
The data access method provided by the embodiment of the invention comprises the steps of firstly receiving 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 the data cache object, judging 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 so that the server returns incremental data of the target data, wherein the incremental data comprises data which is different from the target data stored by the server and the data cache object; and then 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. In the mode, the client under the same game process can store the shared data into the data cache object of the game process only by taking the game process as an agent to request the server for sharing data once, so that the client can directly acquire the shared data from the data cache object, and the access frequency of the server is reduced; meanwhile, due to the natural distributed structure of the game process, the mode needs to consume additional resources to deploy more nodes to share the access pressure of the server, so that the consumption of resource deployment is reduced, and the access pressure of the server is also reduced.
The embodiment of the present invention further provides another data access method, which is implemented on the basis of the above embodiment, and the method mainly describes a specific process for judging whether target data stored in a data cache object is valid (specifically, implemented by the following step S606); as shown in fig. 6, the method includes the following specific steps:
step S602, receiving a data access request sent by a target client.
Step S604, judging whether the target data requested by the data access request is stored in the data cache object; if yes, go to step S606, otherwise go to step S614.
In specific implementation, when a game process receives a data access request sent by a player through a target client, whether target data requested by the data access request exists in a data cache object or not is checked, if the target data does not exist, the target data is requested from a server through the game process, then the requested target data is stored in the data cache object, and the target data is sent to the target client; if the target data exists in the data cache object and is valid, the target data is 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 can be obtained from the server, the data cache object can update the target data stored in the data cache object based on the incremental data, and the updated target data is sent to the target client.
Step S606, judging whether the time of the target data stored in the data cache object exceeds the preset effective time; if the preset effective time is exceeded, executing step S608; otherwise, step S612 is performed.
In specific implementation, whether the target data in the data cache object is valid or not can be judged by judging whether the time for storing the target data in the data cache object exceeds the preset valid time or not. The preset effective time is matched with the accessed frequency of the server, and generally the higher the accessed frequency of the server is, the longer the preset effective time is; the lower the frequency of access, the shorter the preset validity time. Therefore, the highest access frequency of each game process can be controlled, the timeliness of the data can be controlled by adjusting the preset effective time, and if the access frequency is low, the preset effective time can be reduced, so that the real-time performance of the data is improved; when the access frequency is higher, the preset effective time can be prolonged, so that the access pressure of the server is reduced.
In a specific implementation, the preset valid time may be determined by: counting the accessed times of the server in a preset time period, and determining the ratio of the accessed times to the preset time period as service access frequency; if the service access frequency is larger than the maximum frequency threshold value, determining the preset effective time as the sum of the first time and the second time; if the service access frequency is smaller than the minimum frequency threshold, determining the preset effective time as the difference value between the first time and the third time; and if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, determining the preset effective time as the first time.
The specific value of the preset time period may be set according to the research and development requirement, for example, the preset time period may be one hour or 30 minutes. The specific values of the first time, the second time and the third time may also be set according to research and development requirements, for example, the first time may be 40 minutes, the second time may be 10 minutes, the third time may be 10 minutes, and the like; the maximum frequency threshold and the minimum frequency threshold can also be set according to research and development requirements.
In practical applications, the second time and the third time may not be fixed data, but may be data that changes according to a preset rule. Specifically, the second time may include: a first product of a 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, determining the second time as the preset maximum time; the third time may include: a second product of a number of times the service access frequency is successively less than the minimum frequency threshold and a second value; and if the second product is less than the preset minimum time, determining the third time as the preset minimum time. The specific values of the first numerical value, the second numerical value, the preset maximum time and the preset minimum time can be set according to research and development requirements.
For example, the server calculates the service access frequency according to the number of times of access within the past t seconds, the maximum frequency threshold value of access of the server is max times per second, and the minimum frequency threshold value is min times per second. The server side can periodically count the access frequency of the past t seconds, and when the server side is accessed for x times in the past t seconds, the service access frequency of the server side is x/t times per second. When x/t is larger than max, the preset effective time of the data can be prolonged when the server side sharing the data sends the data to the data cache object of the game process; for example, the original data valid time is a seconds (equivalent to the first time), and x/t is found to be greater than max in the current statistics, then the preset valid time of the data can be set to a + b seconds, x/t is greater than max in the next statistics, and the preset valid time of the data is set to a +2b; wherein 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 third time.
Meanwhile, a preset maximum time is needed to be set as tmax and a preset minimum time is needed to be set as tmin, so that the preset effective time process is prevented from being too short, if the time a + n & ltb & gt needed to be set is greater than tmax, the tmax is used, or if a-n & ltb & gt is less than tmin, the tmin is used; where 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.
Step S608, determining that the target data stored in the data cache object is invalid, and sending a first data acquisition request to the server so that the server returns incremental data of the target data; step S610 is performed.
When the data volume requested by the player is larger, the data cache object obtains the latest data by requesting the incremental data, and the data cache object is much smaller than the transmission volume of the requested full data, so that the data access speed can be improved. In specific implementation, there are many ways to obtain incremental data, for example, a server makes a time stamp for each data modification, and a data cache object in a game process can pull the incremental data according to the time stamp; or version control is introduced into the server, and the data cache object in the game process can synchronize incremental data according to the data version of the data cache object.
Based on the above description, the update time of each data in the shared data may be saved in the server; the step S608 can be implemented by the following steps 10 to 11:
step 10, sending a first data acquisition request to a server; the first data acquisition request comprises the latest acquisition time of the target data in the data cache object.
And 11, searching first data of which the updating time is after the acquisition time in the target data through the server, taking the first data as incremental data, and returning the incremental data.
For example, the data cache object in the game process takes the target data of time a for the first time [1,2,3,4]; however, in time b, the server expands the target data by data [5] to [1,2,3,4,5], and in time c, the server modifies data [2] in the target data to data [6] and the target data to [1,6,3,4,5]. At this time, when the data cache object finds that the target data is invalid to pull the latest incremental data, the modified data after the data a time acquired by the data cache object is taken, namely the data [5] with the time increased by the time b, and the modified data [2] with the time c is taken as the data [6]. And then the data cache object synthesizes the modified data and the target data held by the data cache object to obtain the updated target data.
In some embodiments, the server may further store a version number of each piece of data in the shared data; based on this, the above step S608 can also be realized by the following steps 20 to 21:
step 20, sending a first data acquisition request to a server; the first data acquisition request comprises a version number of target data stored in the data cache object.
And step 21, determining incremental data of the target data according to the version number of the target data stored by the server and the version number carried by the first data acquisition request, and returning the incremental data.
For example, the version number of the target data stored in the data cache object is 1.0, when the target data is invalid and the server requests the incremental data of the target data, the target data is modified by version 2.0 and version 3.0 in the server, and then the modification 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 updates the target data stored in itself.
Step S610, 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.
Step S612, sending the target data stored in the data cache object to the target client.
In specific implementation, if the target data exists in the data cache object and is valid, the target data stored in the data cache object is directly sent to the target client.
Step S614, sending a second data acquisition request to the server so as to enable the server to return the target data; and storing the received target data to a data cache object, and sending the target data to a target client.
If the data cache object does not contain the target data, the game process sends a second data acquisition request to the server to request the server for the full amount of data of the target data through the second data acquisition request, a certain transmission pressure may exist in the transmission 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 data of the target data sent by the server, the target data is stored in the data cache object, and the target data is sent to the target client.
It should be noted that, when the server sends the full amount data of the target data and the incremental data of the target data to the game process, the server sends a preset valid time of the target data to the game process, where the preset valid time is used to indicate whether the target data stored in the data cache object is valid at the current time. In addition, the target data can be prevented from being requested again from the server within the preset effective time of the target data, so that the access pressure of the server can be reduced.
The data access method can solve the problem of frequent access of the full-service shared data in the game, and the mode can reduce the request frequency of the shared data in the server by setting the data cache object for managing the cache of the shared data in the game process, and simultaneously the number of the game process also limits the highest simultaneous access amount to the server, thereby reducing the service pressure of the server. Meanwhile, the data request frequency and the data real-time performance can be balanced more flexibly by utilizing the adjustment of the effective time of the cache.
For the above method embodiment, an embodiment of the present invention further provides a data access device, where the data access device is disposed in a device running a game process, and the game process is connected to a server and at least one client respectively; the server side stores shared data in a game, a data cache object is arranged in the game process, and the data cache object is used for caching at least part of the shared data; as shown in fig. 7, the apparatus includes:
the request receiving module 70 is configured to receive a data access request sent by a target client.
The determining module 71 is configured to determine whether the target data stored in the data cache object is valid if the target data requested by the data access request is stored in the data cache object.
A request sending module 72, configured to send a first data obtaining request to the server if the target data is invalid, so that the server returns incremental data of the target data; the incremental data comprises data with difference in target data stored by the server and the data cache object.
And the data sending module 73 is configured to update the target data stored in the data cache object based on the incremental data, obtain updated target data, and send the updated target data to the target client.
The data access device firstly 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 the data cache object, judging 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 so that the server returns incremental data of the target data, wherein the incremental data comprises data which is different from the target data stored by the server and the data cache object; and then 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. In the mode, the client under the same game process can store the shared data into the data cache object of the game process only by taking the game process as an agent to request the server for sharing data once, so that the client can directly acquire the shared data from the data cache object, and the access frequency of the server is reduced; meanwhile, due to the natural distributed structure of the game process, the mode needs to consume additional resources to deploy more nodes to share the access pressure of the server, so that the consumption of resource deployment is reduced, and the access pressure of the server is also reduced.
Further, the apparatus further includes a data acquisition module configured to: 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 so as to enable the server to return target data; and storing the received target data to a data cache object, and sending the target data to a target client.
In a specific implementation, the determining module 71 is configured to: judging whether the time of the target data stored in the data cache object exceeds the preset effective time or not; if the preset valid time is exceeded, determining that the target data is invalid; the preset effective time is matched with the accessed frequency of the server.
Specifically, the apparatus further includes an effective time determining module, configured to: counting the accessed times of the server in a preset time period, and determining the ratio of the accessed times to the preset time period as service access frequency; if the service access frequency is greater than the maximum frequency threshold, determining the preset effective time as the sum of the first time and the second time; if the service access frequency is smaller than the minimum frequency threshold, determining the preset effective time as the difference value between the first time and the third time; and if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, determining the preset effective time as the first time.
In practical applications, the second time period includes: a first product of a 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, determining the second time as the preset maximum time; the third time includes: a second product of a number of times the service access frequency is successively less than the minimum frequency threshold and a second value; and determining the third time as the preset minimum time if the second product is less than the preset minimum time.
Furthermore, the server stores the update time of each piece of data in the shared data; the request sending module 72 is configured to: sending a first data acquisition request to a server; the first data acquisition request comprises the latest acquisition time of the target data in the data cache object; and searching first data of the target data after the updating time is acquired through the server, taking the first data as incremental data, and returning the incremental data.
Further, the server stores the version number of each data in the shared data; the request sending module 72 is further configured to: sending a first data acquisition request to a server; the first data acquisition request comprises a version number of target data stored in the data cache object; and determining incremental data of the target data according to the version number of the target data stored by the server and the version number carried by the first data acquisition request, and returning the incremental data.
In a specific implementation, the apparatus further includes a data transmission module, configured to: and if the target data is valid, sending the target data stored in the data cache object to the target client.
The data access device provided by the embodiment of the present invention has the same implementation principle and technical effect as the foregoing method embodiments, and for the sake of brief description, reference may be made to the corresponding contents in the foregoing method embodiments for the parts of the device embodiments that are not mentioned.
An embodiment of the present invention further provides an electronic device, as shown in fig. 8, where the electronic device includes a processor and a memory, where the memory stores machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the data access method.
Specifically, the data access method is applied to equipment running with a game process, and the game process is respectively connected with a server and at least one client; the server side stores shared data in a game, a data cache object is arranged in the game process, and the data cache object is used for caching at least part of the shared data; the method comprises the following steps: 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, judging 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 so that the server returns incremental data of the target data; the incremental data comprises data with difference in target data stored by the server and the data cache object; and 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.
In the data access method, the client side in the same game process can store the shared data into the data cache object of the game process only by taking the game process as an agent to request the server side for sharing data once, so that the client side can directly acquire the shared data from the data cache object, and the access frequency of the server side is reduced; meanwhile, due to the natural distributed structure of the game process, the mode needs to consume additional resources to deploy more nodes to share the access pressure of the server, so that the resource deployment consumption is reduced, and the access pressure of the server is also reduced.
In an optional embodiment, the method further comprises: 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 so that the server returns the target data; and storing the received target data to a data cache object, and sending the target data to a target client.
In an optional embodiment, the step of determining whether the target data stored in the data cache object is valid includes: judging whether the time of the target data stored in the data cache object exceeds the preset effective time or not; if the preset valid time is exceeded, determining that the target data is invalid; the preset effective time is matched with the accessed frequency of the server.
In an alternative embodiment, the preset effective time is determined by: counting the accessed times of the server in a preset time period, and determining the ratio of the accessed times to the preset time period as service access frequency; if the service access frequency is greater than the maximum frequency threshold, determining the preset effective time as the sum of the first time and the second time; if the service access frequency is smaller than the minimum frequency threshold, determining the preset effective time as the difference value between the first time and the third time; and if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, determining the preset effective time as a first time.
In an alternative embodiment, the second time includes: a first product of a 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, determining the second time as the preset maximum time; the third time includes: a second product of a number of times that the service access frequency is continuously less than the minimum frequency threshold and a second value; and determining the third time as the preset minimum time if the second product is less than the preset minimum time.
In an optional embodiment, the server stores an update time of each piece of data in the shared data; the step of sending the 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 a server; the first data acquisition request comprises the latest acquisition time of the target data in the data cache object; and searching first data of the target data after the updating time is acquired through the server, taking the first data as incremental data, and returning the incremental data.
In an optional embodiment, the server stores a version number of each piece of data in the shared data; the step of sending the 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 a server; the first data acquisition request comprises a version number of target data stored in the data cache object; and determining incremental data of the target data according to the version number of the target data stored by the server and the version number carried by the first data acquisition request, and returning the incremental data.
In an alternative embodiment, the method further comprises: and if the target data is valid, sending the target data stored in the data cache object to the target client.
Further, the electronic device shown in fig. 8 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.
The memory 100 may include a high-speed Random Access Memory (RAM) and may further include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, and the like can be used. The bus 102 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 8, but that does not indicate only one bus or one type of bus.
The processor 101 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 101. The processor 101 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, or discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100, and completes the steps of the method of the foregoing embodiment in combination with the hardware thereof.
Embodiments of the present invention further provide a computer-readable storage medium, where the computer-readable storage medium 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 data access method, and specific implementation may refer to method embodiments, which are not described herein again.
Specifically, the data access method is applied to equipment running with a game process, and the game process is respectively connected with a server and at least one client; the server side stores shared data in a game, a data cache object is arranged in the game process, and the data cache object is used for caching at least part of the shared data; the method comprises the following steps: 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, judging 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 so that the server returns incremental data of the target data; the incremental data comprises data with difference in target data stored by the server and the data cache object; and 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.
In the data access method, the client side in the same game process can store the shared data into the data cache object of the game process only by taking the game process as an agent to request the server side for sharing data once, so that the client side can directly acquire the shared data from the data cache object, and the access frequency of the server side is reduced; meanwhile, due to the natural distributed structure of the game process, the mode needs to consume additional resources to deploy more nodes to share the access pressure of the server, so that the resource deployment consumption is reduced, and the access pressure of the server is also reduced.
In an optional embodiment, the method further comprises: 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 so that the server returns the target data; and storing the received target data to a data cache object, and sending the target data to a target client.
In an optional embodiment, the step of determining whether the target data stored in the data cache object is valid includes: judging whether the time of the target data stored in the data cache object exceeds the preset effective time or not; if the preset valid time is exceeded, determining that the target data is invalid; the preset effective time is matched with the accessed frequency of the server.
In an alternative embodiment, the preset effective time is determined by: counting the accessed times of the server in a preset time period, and determining the ratio of the accessed times to the preset time period as service access frequency; if the service access frequency is greater than the maximum frequency threshold, determining the preset effective time as the sum of the first time and the second time; if the service access frequency is smaller than the minimum frequency threshold, determining the preset effective time as the difference value between the first time and the third time; and if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold, determining the preset effective time as the first time.
In an alternative embodiment, the second time includes: a first product of a 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, determining the second time as the preset maximum time; the third time includes: a second product of a number of times that the service access frequency is continuously less than the minimum frequency threshold and a second value; and determining the third time as the preset minimum time if the second product is less than the preset minimum time.
In an optional embodiment, the server stores an update time of each piece of data in the shared data; the step of sending the 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 a server; the first data acquisition request comprises the latest acquisition time of the target data in the data cache object; and searching first data of the target data after the updating time is acquired through the server, taking the first data as incremental data, and returning the incremental data.
In an optional embodiment, the server stores a version number of each piece of data in the shared data; the step of sending the 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 a server; the first data acquisition request comprises a version number of target data stored in the data cache object; and determining incremental data of the target data according to the version number of the target data stored by the server and the version number carried by the first data acquisition request, and returning the incremental data.
In an alternative embodiment, the method further comprises: and if the target data is valid, sending the target data stored in the data cache object to the target client.
The functions may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a terminal device, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (11)

1. A data access method is characterized in that the method is applied to equipment running with game processes, and the game processes are respectively connected with a server side and at least one client side; the server side stores shared data in a game, a data cache object is arranged in the game process, and the data cache object is used for caching at least part of the shared data; the method comprises the following steps:
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, judging whether the target data stored in the data cache object is valid;
if the target data are invalid, sending a first data acquisition request to the server so that the server returns incremental data of the target data; the incremental data comprises data with difference in target data stored by the server and the data cache object;
and 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.
2. The method of claim 1, further comprising:
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 so that the server returns the target data;
and storing the received target data to the data cache object, and sending the target data to the target client.
3. The method of claim 1, wherein the step of determining whether the target data stored by the data cache object is valid comprises:
judging whether the time for storing the target data in the data cache object exceeds preset effective time or not; if the preset valid time is exceeded, determining that the target data is invalid;
and the preset effective time is matched with the accessed frequency of the server.
4. The method according to claim 3, characterized in that the preset effective time is determined by:
counting the accessed times of the server in a preset time period, and determining the ratio of the accessed times to the preset time period as service access frequency;
if the service access frequency is greater than a maximum frequency threshold value, determining the preset effective time as the sum of a first time and a second time;
if the service access frequency is smaller than a minimum frequency threshold value, determining the preset effective time as the difference value of the first time and a third time;
determining the preset valid time as the first time if the service access frequency is not greater than the maximum frequency threshold and not less than the minimum frequency threshold.
5. The method of claim 4, wherein the second time comprises: a first product of a number of times that 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: a second product of a number of times the service access frequency is successively less than the minimum frequency threshold and a second value; and if the second product is smaller than the preset minimum time, determining the third time as the preset minimum time.
6. The method according to claim 1, wherein the server keeps an 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; the first data acquisition request comprises the latest acquisition time of the target data in the data cache object;
and searching first data of the target data after the updating time is acquired through the server, taking the first data as incremental data, and returning the incremental data.
7. The method according to claim 1, wherein the server holds a 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; the first data acquisition request comprises the version number of the target data stored in the data cache object;
and determining incremental data of the target data according to the version number of the target data stored by the server and the version number carried by the first data acquisition request, and returning the incremental data.
8. The method of claim 1, further comprising:
and if the target data is valid, sending the target data stored in the data cache object to the target client.
9. A data access device is characterized in that the device is arranged on equipment running with game processes, and the game processes are respectively connected with a server side and at least one client side; the server side stores shared data in a game, a data cache object is arranged in the game process, and the data cache object is used for caching at least part of the shared data; the device comprises:
the request receiving module is used for receiving a data access request sent by a target client;
the judging module is used for judging whether the target data stored by the data cache object is valid or not if the target data requested by the data access request is stored in the data cache object;
a request sending module, configured to send a first data obtaining request to the server if the target data is invalid, so that the server returns incremental data of the target data; the incremental data comprises data with difference in target data stored by the server and the data cache object;
and the data sending module is used for 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.
10. An electronic device comprising a processor and a memory, the memory storing machine executable instructions executable by the processor, the processor executing the machine executable instructions to implement the data access method of any one of claims 1 to 8.
11. A computer-readable storage medium having stored thereon computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the data access method of any of claims 1 to 8.
CN202211340366.4A 2022-10-28 2022-10-28 Data access method and device and electronic equipment Pending CN115766866A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211340366.4A CN115766866A (en) 2022-10-28 2022-10-28 Data access method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211340366.4A CN115766866A (en) 2022-10-28 2022-10-28 Data access method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN115766866A true CN115766866A (en) 2023-03-07

Family

ID=85354229

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211340366.4A Pending CN115766866A (en) 2022-10-28 2022-10-28 Data access method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN115766866A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117112268A (en) * 2023-10-23 2023-11-24 深圳市七彩虹禹贡科技发展有限公司 Memory sharing management method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117112268A (en) * 2023-10-23 2023-11-24 深圳市七彩虹禹贡科技发展有限公司 Memory sharing management method and system
CN117112268B (en) * 2023-10-23 2024-02-13 深圳市七彩虹禹贡科技发展有限公司 Memory sharing management method and system

Similar Documents

Publication Publication Date Title
CN108696895B (en) Resource acquisition method, device and system
EP3668063A1 (en) Domain name resolution method, server and system
CN109040190B (en) Scheduling method, device and computer readable storage medium
CN114827145B (en) Server cluster system, metadata access method and device
KR20180099841A (en) Method and apparatus for handling short-cut links,
CN111294390B (en) Block data rapid synchronization method, device, equipment and storage medium
CN115766866A (en) Data access method and device and electronic equipment
CN112751847A (en) Interface call request processing method and device, electronic equipment and storage medium
CN109871498B (en) Rear-end interface response method and device, electronic equipment and storage medium
CN111597213A (en) Caching method, software server and storage medium
CN111597259B (en) Data storage system, method, device, electronic equipment and storage medium
CN106878030B (en) Charging method and device
CN110995881A (en) Domain name storage method and device
CN111654379B (en) Multi-server unified token generation method and authentication method
CN110460486B (en) Service node monitoring method and system
CN113835905B (en) Message queue load balancing method and device, electronic equipment and medium
CN111565195A (en) Challenge black hole attack defense method of distributed system and distributed system
CN110839166A (en) Data sharing method and device
CN113918776B (en) Data caching method and device, electronic equipment and data query method
CN113268327A (en) Transaction request processing method and device and electronic equipment
CN110555040A (en) Data caching method and device and server
CN112839070B (en) Data processing method and device and node equipment in CDN (content delivery network)
CN111125580B (en) Network resource acquisition method and device, electronic equipment and storage medium
CN112751912A (en) Configuration adjustment method and device and electronic equipment
WO2020098773A1 (en) Request response method and device, edge node and authentication system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination