A mobile game server data caching method and system

By calculating the importance, risks and user preferences of data in the mobile game server cache system and determining the elimination priority, the problem that existing cache elimination algorithms cannot effectively reflect the importance of data is solved, and data processing efficiency and user experience are improved.

CN119248675BActive Publication Date: 2025-03-18WUHAN WOYOU NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411763761.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-03-18
Estimated Expiration
2044-12-03

AI Technical Summary

Technical Problem

Existing cache-out algorithms, such as LRU, cannot effectively reflect the importance of data, resulting in the elimination of important but low access frequency data, increasing data request time and reducing user experience.

Method used

By counting the number of requested times and request time intervals of each data in the cache server, combining the operation risks under different request methods, determining the importance, risk degree and memory differences of data, calculating the elimination priority of each data, and managing data elimination based on user preferences.

Benefits of technology

Effectively evaluate the importance and risks of data, avoid improper elimination of important data, improve data processing efficiency, reduce data request time, and improve user's gaming experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248675B_ABST
    Figure CN119248675B_ABST
Patent Text Reader

Abstract

The present application relates to the field of data caching technology, and specifically to a method and system for caching data on a mobile game server, the method comprising: obtaining the data to be cached requested by the user at the current moment, and the request time, number of requests and request method of each user in the cache server at the current moment for each piece of data, as well as the data tag type of each piece of data in the cache server, including private data and public data; determining the importance, risk level, memory difference, and elimination priority of each piece of data in the cache server at the current moment; determining the user identification and criticality of each piece of private data; determining the user preference for each piece of data in the cache server at the current moment; determining the elimination value of each piece of data in the cache server at the current moment, and performing elimination management on the data in the cache server. The present application can improve the processing efficiency of cached data, reduce the time for users to request data, and enhance the user's gaming experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data caching, and in particular to a method and system for caching data for a mobile game server. Background Art

[0002] Data caching is a computer technology used to improve data access speed and system performance. It reduces the number of direct accesses to the original data source, such as a database or disk, by storing frequently accessed data in a fast storage medium, thereby reducing the latency of data retrieval and improving the efficiency of data processing. The data of mobile game servers has high concurrency and needs to process data interactions of a large number of players at the same time. It is also real-time and needs to respond to data changes in real time, so caching technology is essential.

[0003] The size of the cache server is limited. When the cache server reaches the storage limit, some data needs to be eliminated. Traditional cache elimination algorithms, such as the Least Recently Used (LRU) algorithm, are the most commonly used. It is an elimination mechanism based on data access time. If the data has been accessed recently, it is more likely to be accessed in the future, so the data that has been used the longest is eliminated. This algorithm is simple to implement, but it cannot reflect the importance of the data. Although some data has not been accessed for a long time, it may still be important in the future. If this data is eliminated directly according to the access time, the original database needs to be operated when it is requested again, which reduces the efficiency of data processing, resulting in longer data request time and reduced user gaming experience. Summary of the invention

[0004] In order to solve the above technical problems, a mobile game server data caching method and system are provided to solve the existing problems.

[0005] The solution to the technical problem of this application is to provide a mobile game server data caching method and system, including the following steps:

[0006] In a first aspect, an embodiment of the present application provides a method for caching data on a mobile game server, the method comprising the following steps:

[0007] Obtain the cached data requested by the user at the current moment, and the request time, number of requests and request method of each user in the cache server for each piece of data at the current moment, the request method includes read operation and write operation, and the data tag type of each piece of data in the cache server, the data tag type includes private data and public data;

[0008] Count the number of times each piece of data in the cache server is requested, and determine the importance of each piece of data in the cache server at the current moment by combining the current moment and the interval between the first request time and the last request time of each piece of data;

[0009] Determine the risk level of each piece of data according to the operational risk generated by different request modes when each piece of data in the cache server is requested; analyze the difference in memory size between each piece of data in the cache server and the data to be cached, determine the memory difference of each piece of data, and determine the elimination priority of each piece of data in the cache server at the current moment in combination with the risk level and the importance level;

[0010] Determine the user ID of each piece of private data based on the number of requests for data by each user in the cache server; analyze the activity of each piece of private data in the cache server by the corresponding user and the interval time when the private data was recently requested, and determine the criticality of each piece of private data in combination with the user ID; determine the user preference of each piece of data in the cache server at the current moment in combination with all the requests for each piece of private data by the corresponding user;

[0011] Based on the elimination priority and the user preference, the elimination value of each piece of data in the cache server at the current moment is determined, and elimination management is performed on the data in the cache server.

[0012] Preferably, the calculation formula for determining the importance of each piece of data in the cache server at the current moment is: ,in, The cache server at the current moment The importance of the data, The cache server at the current moment The data is The number of requests per user, The cache server at the current moment The number of users that can request a piece of data by all users, The cache server at the current moment The last time the data was requested. The cache server at the current moment The time when the data is first requested. For the current moment.

[0013] Preferably, determining the risk level of each piece of data includes:

[0014] If each data in the cache server is requested as a read operation each time, the operation risk of each data each time it is requested is a preset first threshold; if each data in the cache server is requested as a write operation, the operation risk of each data each time it is requested is a preset second threshold, wherein the preset second threshold is greater than the preset first threshold;

[0015] The sum of the operation risks of each piece of data when being requested all the times is calculated as the risk level of each piece of data in the cache server at the current moment.

[0016] Preferably, the memory difference of each piece of data is the difference between the memory size occupied by each piece of data in the cache server at the current moment and the memory size occupied by the data to be cached.

[0017] Preferably, determining the elimination priority of each piece of data in the cache server at the current moment includes:

[0018] The product of the importance degree and the memory difference is calculated, and a normalized result of the ratio of the risk degree to the product is used as the elimination priority of each piece of data in the cache server at the current moment.

[0019] Preferably, determining the user identifier of each piece of private data includes:

[0020] Count the sum of the number of requests for all data by each user in the cache server as the total number of requests for each user;

[0021] Calculate the average of the total number of requests of all users in the cache server; record the users whose total number of requests is greater than the average as active users, otherwise, record them as inactive users;

[0022] If the user corresponding to each piece of private data is an active user, the user ID is assigned a value of 0; if the user corresponding to each piece of private data is an inactive user, the user ID is assigned a value of 1.

[0023] Preferably, the criticality of each piece of private data is determined by calculating: ,in, The cache server at the current moment The criticality of the private data. The cache server at the current moment The number of times a piece of private data is requested by the corresponding user, The cache server at the current moment The private data corresponds to the user ID of the user; For the current moment, The cache server at the current moment The time when the private data was last requested.

[0024] Preferably, the method for obtaining the user preference is:

[0025] The normalized result of the ratio of the criticality of each piece of private data in the cache server to the total number of requests of its corresponding user is used as the user preference of each piece of private data in the cache server;

[0026] Among them, the user preference value of public data in the cache server is assigned to 0.

[0027] Preferably, the elimination value of each piece of data in the cache server at the current moment is the difference between the elimination priority and the user preference.

[0028] In a second aspect, an embodiment of the present application also provides a mobile game server data caching system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of any one of the above-mentioned mobile game server data caching methods when executing the computer program.

[0029] This application has at least the following beneficial effects:

[0030] The present application counts the number of times each piece of data in the cache server is requested, and determines the importance of each piece of data in the cache server at the current moment in combination with the current moment and the interval between the first request time and the last request time of each piece of data. The beneficial effect is that the number of times the data is requested and the time interval between the most recent requests are taken into account to reflect the importance of the data; the risk level of each piece of data is determined according to the operational risks generated under different request modes when each piece of data in the cache server is requested; the difference in the memory size occupied by each piece of data in the cache server and the data to be cached is analyzed to determine the memory difference of each piece of data, and the elimination priority of each piece of data in the cache server at the current moment is determined. The beneficial effect is that the reading and writing operations of each piece of data are taken into account to reflect the risk corresponding to the data. Secondly, the matching of the memory occupied by the data and the data to be cached is analyzed. Compared with the traditional cache elimination algorithm, the elimination of data with low request times but high importance is avoided; according to the data requested by each user in the cache server The number of requests for each private data is used to determine the user identification of each private data; the activity of each private data in the cache server by the corresponding user and the interval time when the private data was recently requested are analyzed to determine the criticality of each private data; combined with all the request times of each private data by the corresponding user, the user preference of each data in the cache server at the current moment is determined, which has the beneficial effect of taking into account the request situation of inactive users for private data, so as to reflect the possibility that the corresponding private data is the key data of the inactive user, and then reflect the preference of the inactive user for the private data, reduce the elimination value of the key data of the inactive user, avoid eliminating the key data of the inactive user, resulting in the extension of the data request time of the inactive user, and cause the loss of inactive users; based on the elimination priority and the user preference, the elimination value of each data in the cache server at the current moment is determined, and the data in the cache server is eliminated. The beneficial effect is that data caching through elimination value can improve data processing efficiency, reduce data request time, and enhance the user's gaming experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] A mobile game server data caching method of the present application is further described in detail below in conjunction with the accompanying drawings.

[0032] Figure 1 A flowchart of a method for caching data in a mobile game server provided in an embodiment of the present application;

[0033] Figure 2 A flowchart of the steps of a method for obtaining the elimination priority of each piece of data in a cache server at the current moment provided in an embodiment of the present application;

[0034] Figure 3A flowchart of the steps of a method for obtaining the user preference for each piece of data in a cache server at the current moment provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solution and advantages of this application more clear, the following is a further detailed description of a mobile game server data caching method and system proposed in this application in conjunction with the accompanying drawings and implementation examples. It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit this application.

[0036] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.

[0037] See also Figure 1 , which shows a flowchart of a method for caching data in a mobile game server provided by an embodiment of the present application, the method comprising the following steps:

[0038] Step 1, obtain the cached data requested by the user at the current moment, and the request time, number of requests and request method of each user in the cache server for each data at the current moment, the request method includes read operation and write operation, and the data tag type of each data in the cache server, the data tag type includes private data and public data.

[0039] Caching is a technology used in computers to store temporary data so that it can be retrieved faster when the same data is accessed later. After the data is cached, it will be temporarily stored in memory or other high-speed storage media, such as computer memory or dedicated cache memory. By caching data, frequent queries to the database or other data sources can be avoided, thereby reducing the number of database accesses and reducing the database load.

[0040] The mobile game server cache system consists of a cache server, a database server and an application server. The database server stores all data and is responsible for data persistence to avoid data errors. The cache server is responsible for managing the cache and storing data with high request frequency and high importance to avoid frequent read and write operations on the database, resulting in low data processing efficiency and reduced user experience. The application server is responsible for processing user data requests and reading and writing data from the cache or database.

[0041] When the cache server caches the stored data, it adds a tag to the stored data to determine the data tag type of each piece of data to reflect whether the data is private data of a specific user or public data of all users;

[0042] It should be noted that private data can only be requested by specific users, while public data can be requested by all users.

[0043] Through the log management tool in the cache server, count the data cached in the cache server for T days at the current moment, the request method of each user when sending a request to each data in the cache server, that is, including read operation or write operation, request time and request number, and obtain the data tag type of each data in the cache server. The cache in the cache server is data cached for T days, so the cached data of the 1st day will be discarded on the T+1 day.

[0044] Secondly, when the user makes a data request, the cache server is first checked to see whether the requested data exists. If so, the read and write operations are performed directly in the cache server. If not, the requested data needs to be read from the database server and stored in the cache server. If a write operation is required, it is performed in the cache server.

[0045] When storing new request data in the cache server, if the cache server is not full, it can be directly stored. If the cache server has reached the storage limit, some historical cached data needs to be eliminated. Therefore, when the cache server has reached the storage limit, the cache server needs to store the user's new request data and record it as the cached data requested by the user at the current moment;

[0046] Preferably, in this embodiment, the log management tool adopts the Graylog log monitoring system, wherein the construction of Graylog is a well-known technology and will not be repeated here. As other implementation methods, implementers can adopt other methods of the prior art, such as Filebeat, LogDNA, etc., and this embodiment does not impose special restrictions on this; secondly, the collection period is 30 days, so the cached data of the 1st day will be discarded on the 31st day.

[0047] At this point, the cached data requested by the user at the current moment, as well as the request time, number of requests and request method of each user in the cache server for each piece of data at the current moment are obtained. The request method includes read operations and write operations, as well as the data tag type of each piece of data in the cache server. The data tag type includes private data and public data.

[0048] Step 2, count the number of times each piece of data in the cache server is requested, and determine the importance of each piece of data in the cache server at the current moment by combining the current moment and the interval between the first request time and the last request time of each piece of data.

[0049] If the cache server has reached its storage limit, it needs to eliminate some historical cached data. The traditional LRU (Least Recently Used) algorithm cache elimination strategy is to eliminate the data that has not been requested for the longest time. However, if the data that has not been requested for the longest time is relatively important and it takes a long time to read from the original database in the database server, it will increase the time for the original database to process the data.

[0050] Based on the above analysis, the importance of each piece of data in the cache server is analyzed. In the mobile game server, some data needs to be updated in real time, such as the ranking list. This kind of data will be read and written many times in a short period of time, which is called hot data. In order to reduce the read and write operations on the original database, the importance of hot data in the cache server should be greater and should not be eliminated first; on the contrary, the less the number of requests for data, the less important it should be, and it should be eliminated first when the cache is insufficient. Therefore, the importance of data can be determined by the number of requests for each piece of data, specifically:

[0051] The calculation formula for the importance of each piece of data in the cache server at the current moment is: ,in, The cache server at the current moment The importance of the data, The cache server at the current moment The data is The number of requests per user, The cache server at the current moment The number of users that can request a piece of data by all users, The cache server at the current moment The last time the data was requested. The cache server at the current moment The time when the data is first requested. For the current moment.

[0052] It should be noted that if a certain data in the cache server is only requested once at the current moment, that is, , then the importance of the data Assign a value of 0.

[0053] It should be noted that the more times each piece of data is requested, the more important the data is and the more it should be stored in the cache server. The smaller it is, the more important the corresponding data is, because the closer the last requested data is to the current moment, the higher the probability of being requested in the future; the greater the importance level, the more important the data is, and the more it should be stored in the cache server to avoid direct interaction with the database when requesting the data, resulting in inefficient data processing; conversely, the less important the data is, the data should be eliminated first when the cache is replaced and eliminated.

[0054] At this point, the importance of each piece of data in the cache server at the current moment is obtained.

[0055] Step 3, determine the risk level of each piece of data according to the operational risks generated under different request modes when each piece of data in the cache server is requested; analyze the difference in memory size occupied by each piece of data in the cache server and the data to be cached, determine the memory difference of each piece of data, and determine the elimination priority of each piece of data in the cache server at the current moment in combination with the risk level and the importance level.

[0056] When the data in the cache server needs to be eliminated and replaced, the process of elimination and replacement is as follows: the user sends a data request, the requested data does not exist in the cache server, the original database in the database server is read, and the requested data read from the original database is stored in the cache server. If the cache server is full at this time, the data in the cache server needs to be eliminated.

[0057] The risks of read and write operations in data requests are different. The risk of write operations is greater than that of read operations because the data in the cache server is not persistent data and errors may occur, causing data changes. Therefore, data with more write operations in the cache server should be eliminated first, and the data should be synchronized to the original database to avoid cache pollution. Therefore, data with more write operations in the cache server should be eliminated first.

[0058] In addition, the memory size occupied by the eliminated data in the cache server should be close to the memory size occupied by the data to be cached, and larger than the memory size occupied by the data to be cached. If the memory size occupied by the eliminated data is smaller than the memory size occupied by the data to be cached, other data will need to be eliminated. Therefore, when the memory size occupied by the eliminated data in the cache server is larger than the memory size occupied by the data to be cached, the corresponding eliminated data should be eliminated first.

[0059] Based on the above analysis, based on the request mode of the data in the cache server and the memory size of the data, combined with the importance, the elimination priority is determined, specifically:

[0060] If each data in the cache server is requested as a read operation each time, the operation risk of each data each time it is requested is a preset first threshold; if each data in the cache server is requested as a write operation, the operation risk of each data each time it is requested is a preset second threshold, wherein the preset second threshold is greater than the preset first threshold;

[0061] Preferably, in this embodiment, the preset first threshold value is 1, and the preset second threshold value is 2. It should be noted that since the risk of write operation is higher than that of read operation, the preset second threshold value is greater than the preset first threshold value.

[0062] Calculate the sum of the operation risks of each piece of data in the cache server when it is requested all times, as the risk level of each piece of data in the cache server at the current moment;

[0063] The difference between the memory size occupied by each piece of data in the cache server at the current moment and the memory size occupied by the data to be cached is used as the memory difference of each piece of data;

[0064] Calculate the product of the importance degree and the memory difference, and use the normalized result of the ratio of the risk degree to the product as the elimination priority of each piece of data in the cache server at the current moment;

[0065] Preferably, in this embodiment, the calculation formula for the elimination priority of each piece of data in the cache server at the current moment is: ,in, The cache server at the current moment The elimination priority of the data. The cache server at the current moment The data is in Operational risk when requested for the first time, The cache server at the current moment The number of times a piece of data is requested. The cache server at the current moment The importance of the data. The cache server at the current moment The memory size of the data. is the memory size of the data to be cached at the current moment, is a normalization function. In this embodiment, a sigmoid function is used for normalization. As other implementation methods, the implementer may use other methods of the prior art. Secondly, For memory differences, For the degree of risk.

[0066] It should be noted that if the memory size occupied by the data in the cache server is the same as the memory occupied by the data to be cached, If it is 0, the elimination priority cannot be calculated. In this case, the elimination priority of the corresponding data in the cache server is assigned a value of 0.5.

[0067] It should be noted that, in the case where the memory size occupied by the eliminated data in the cache server is larger than the memory size occupied by the data to be cached, if the memory size occupied by the existing data in the cache server is closer to the memory size occupied by the data to be cached, the memory difference The smaller it is, the more the corresponding data in the cache server should be eliminated, and the greater the elimination priority. Secondly, because the risk of write operations is greater than that of read operations, the greater the risk level, the more frequently the data is written, and the more the corresponding data in the cache server should be eliminated first, and the greater the elimination priority. The greater the importance level, the more important the corresponding data is, the less it should be eliminated first, and the smaller the elimination priority is.

[0068] Further, the step flow chart of the method for obtaining the elimination priority of each data in the cache server at the current moment provided by the embodiment of the present application is as follows: Figure 2 shown.

[0069] At this point, the elimination priority of each piece of data in the cache server at the current moment is obtained.

[0070] Step 4: determine the user ID of each piece of private data based on the number of requests for data by each user in the cache server; analyze the activity of each piece of private data in the cache server by the corresponding user, as well as the interval time when the private data was recently requested, and determine the criticality of each piece of private data in combination with the user ID; determine the user preference of each piece of data in the cache server at the current moment in combination with all the requests for each piece of private data by the corresponding user.

[0071] Based on the above analysis, the elimination of data is analyzed based on the number of times each piece of data is requested. However, the cache server not only contains data that can be requested by all users, i.e., public data, but also contains some data that can only be requested by specific users, i.e., private data requested by specific users. If data is eliminated directly according to the elimination priority as the cache elimination strategy, the cache server will store more data of active users because of the high number of active users requesting data. At this time, the average time for active users to request data is shorter. However, inactive users store less data in the cache server, which will result in a longer average time for requesting data, which will reduce the gaming experience of inactive users and lead to user loss.

[0072] Secondly, the elimination priority is based on the public data in the cache server. The importance of the data is analyzed by the request frequency of the data in the cache server, and the data with high elimination priority is eliminated and replaced by comparing it with the memory size occupied by the cached data. However, the data request pattern of each user is different. For example, some users like to play PvP (player against player), so the user requests PvP data more frequently. Some users like to play PvE (player against environment, that is, fighting boss), so the user requests PvE data more frequently. Therefore, for private data, data that users request more frequently is critical data and should be kept in the cache server.

[0073] Therefore, when eliminating data in the cache server, we must not only consider the overall situation of the cached data and the relationship between the size of the data to be eliminated and the size of the data to be cached, but also consider the user's preference for data, that is, retain the data with a large number of requests from inactive users in the private data, and only eliminate the data with a small number of requests, so as to improve the user experience and avoid user loss.

[0074] First, based on the number of user requests, we distinguish between active users and inactive users, specifically:

[0075] Count the sum of the number of requests for all data by each user in the cache server at the current moment as the total number of requests for each user;

[0076] Calculate the average of the total number of requests of all users in the cache server at the current moment; record the users whose total number of requests is greater than the average as active users, and record the users whose total number of requests is less than or equal to the average as inactive users;

[0077] Furthermore, for data in a cache server, if it is public data, generally all users can read it but cannot write it. If it is private data, the data can only be read and written by the corresponding user, so most public data will be retained in the cache server.

[0078] For a private data in the cache server, the preference of inactive users for the private data is analyzed to determine the user preference, so as to avoid that all the data about the inactive users in the cache server is eliminated. Specifically:

[0079] If the user corresponding to each piece of private data is an active user, the user ID is assigned a value of 0; if the user corresponding to each piece of private data is an inactive user, the user ID is assigned a value of 1;

[0080] Calculate the criticality of each private data in the cache server at the current moment. The calculation formula is: ,in, The cache server at the current moment The criticality of the private data. The cache server at the current moment The number of times a piece of private data is requested by the corresponding user, The cache server at the current moment The private data corresponds to the user ID of the user; For the current moment, The cache server at the current moment The time when the private data was last requested.

[0081] The normalized result of the ratio of the criticality of each private data in the cache server at the current moment to the total number of requests of its corresponding user is used as the user preference of each private data in the cache server at the current moment; wherein, the user preference of public data in the cache server at the current moment is assigned to 0.

[0082] Preferably, in this embodiment, the method for calculating the user preference of each piece of data in the cache server at the current moment is: ,in, The cache server at the current moment The user preference of the data, The cache server at the current moment The criticality of the private data. The cache server at the current moment The total number of requests for the user corresponding to the private data, is a normalization function. In this embodiment, a sigmoid function is used for normalization. As other implementation methods, the implementer may use other methods of the prior art.

[0083] It should be noted that the number of requests for all data by users corresponding to the private data in the cache server at the current moment is 0, that is, When the user is determined to have left, all private data of the user in the cache server will be eliminated.

[0084] It should be noted that, for inactive users, the greater the proportion of requests for a certain private data in the cache server to all data requests, and the smaller the time interval from the current moment to the last request for the key data, the more critical the corresponding private data is, and the more the key data of inactive users should be retained in the cache server. Therefore, the greater the obtained user preference, the more times the corresponding data is requested by inactive users, and the smaller the time interval from the last request, the more likely it is that the data is key data of inactive users, and the less it should be eliminated.

[0085] Further, the step flow chart of the method for obtaining the user preference of each data in the cache server at the current moment provided by the embodiment of the present application is as follows: Figure 3 shown.

[0086] At this point, the user preference for each piece of data in the cache server at the current moment is obtained.

[0087] Step 5: Based on the elimination priority and the user preference, determine the elimination value of each piece of data in the cache server at the current moment, and perform elimination management on the data in the cache server.

[0088] Further, the elimination priority is calculated by considering the elimination strategy of all data in the cache server, the user preference is calculated by considering the elimination strategy of private data in the cache server, and the elimination value is determined based on the elimination priority and the user preference of each data, specifically:

[0089] The difference between the elimination priority and the user preference is used as the elimination value of each piece of data in the cache server at the current moment;

[0090] Preferably, in this embodiment, the difference between the elimination priority and the user preference is used as the elimination value of each piece of data in the current cache server.

[0091] It should be noted that the larger the elimination value is, the more the corresponding data should be eliminated first. If a certain data in the cache server is not private data, the user preference is 0, that is, the elimination value of the corresponding data is the elimination priority.

[0092] Further, based on the elimination value, the data in the cache server is eliminated and managed, specifically:

[0093] The cache server temporarily stores data through HashMap and bidirectional linked list. Each data value corresponds to a Key. HashMap is used to find the node of the bidirectional linked list corresponding to the Key, and each data value is stored in the node position corresponding to the bidirectional linked list Key to achieve fast reading and writing of data. The elimination value of each data is calculated and sorted in order from small to large elimination values ​​to achieve the stack function, where the data with the largest elimination value is at the bottom of the stack.

[0094] If the cache server is not full, it can be directly stored in the doubly linked list. If the cache server has reached the storage limit, when the user requests data, if there is a node corresponding to the key of the corresponding data in the doubly linked list in the cache server, it is directly read and written, and the elimination value of the data corresponding to the node is updated and calculated, and the node position is moved according to the elimination value; if there is no node corresponding to the key of the corresponding data in the doubly linked list, the data corresponding to the bottom of the stack in the removed doubly linked list is written to the database, and the key of the corresponding data at the bottom of the stack is removed from the HashMap, and the user's request data is read from the original database and put into the top of the doubly linked list. At the same time, the key corresponding to the request data is added to the HashMap, and the data requested by the user is cached.

[0095] Based on the same inventive concept as the above method, an embodiment of the present application also provides a mobile game server data caching system, including a memory, a processor, and a computer program stored in the memory and running on the processor, and when the processor executes the computer program, the steps of any one of the above-mentioned mobile game server data caching methods are implemented.

[0096] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0097] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0098] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the present application. It should be pointed out that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application without departing from the content of the technical solution of the present application, shall fall within the protection scope of the technical solution of the present application.

Claims

1. A mobile game server data caching method, characterized in that: The method comprises the following steps: Obtain the cached data requested by the user at the current moment, and the request time, number of requests and request method of each user in the cache server for each piece of data at the current moment, the request method includes read operation and write operation, and the data tag type of each piece of data in the cache server, the data tag type includes private data and public data; Count the number of times each piece of data in the cache server is requested, and determine the importance of each piece of data in the cache server at the current moment by combining the current moment and the interval between the first request time and the last request time of each piece of data; Determine the risk level of each piece of data according to the operational risk generated by different request modes when each piece of data in the cache server is requested; analyze the difference in memory size between each piece of data in the cache server and the data to be cached, determine the memory difference of each piece of data, and determine the elimination priority of each piece of data in the cache server at the current moment in combination with the risk level and the importance level; Determine the user ID of each piece of private data based on the number of requests for data by each user in the cache server; analyze the activity of each piece of private data in the cache server by the corresponding user and the interval time when the private data was recently requested, and determine the criticality of each piece of private data in combination with the user ID; determine the user preference of each piece of data in the cache server at the current moment in combination with all the requests for each piece of private data by the corresponding user; Based on the elimination priority and the user preference, the elimination value of each piece of data in the cache server at the current moment is determined, and elimination management is performed on the data in the cache server.

2. A mobile game server data caching method as claimed in claim 1, characterized in that: The calculation formula for determining the importance of each piece of data in the cache server at the current moment is: ,in, The cache server at the current moment The importance of the data, The cache server at the current moment The data is The number of requests per user, The cache server at the current moment The number of users that can request a piece of data by all users, The cache server at the current moment The last time the data was requested. The cache server at the current moment The time when the data is first requested. For the current moment.

3. A mobile game server data caching method as claimed in claim 1, characterized in that: Determining the risk level of each piece of data includes: If each data in the cache server is requested as a read operation each time, the operation risk of each data each time it is requested is a preset first threshold; if each data in the cache server is requested as a write operation, the operation risk of each data each time it is requested is a preset second threshold, wherein the preset second threshold is greater than the preset first threshold; The sum of the operation risks of each piece of data when being requested all the times is calculated as the risk level of each piece of data in the cache server at the current moment.

4. A mobile game server data caching method as claimed in claim 1, characterized in that: The memory difference of each piece of data is the difference between the memory size occupied by each piece of data in the cache server at the current moment and the memory size occupied by the data to be cached.

5. A mobile game server data caching method as claimed in claim 1, characterized in that: Determining the elimination priority of each piece of data in the cache server at the current moment includes: The product of the importance degree and the memory difference is calculated, and a normalized result of the ratio of the risk degree to the product is used as the elimination priority of each piece of data in the cache server at the current moment.

6. A mobile game server data caching method as claimed in claim 1, characterized in that: Determining the user identification of each piece of private data includes: Count the sum of the number of requests for all data by each user in the cache server as the total number of requests for each user; Calculate the average of the total number of requests of all users in the cache server; record the users whose total number of requests is greater than the average as active users, otherwise, record them as inactive users; If the user corresponding to each piece of private data is an active user, the user ID is assigned a value of 0; if the user corresponding to each piece of private data is an inactive user, the user ID is assigned a value of 1.

7. A mobile game server data caching method as claimed in claim 1, characterized in that: The criticality of each piece of private data is determined by: ,in, The cache server at the current moment The criticality of the private data. The cache server at the current moment The number of times a piece of private data is requested by the corresponding user, The cache server at the current moment The private data corresponds to the user ID of the user; For the current moment, The cache server at the current moment The time when the private data was last requested.

8. A mobile game server data caching method as claimed in claim 6, characterized in that: The method for obtaining the user preference is: The normalized result of the ratio of the criticality of each piece of private data in the cache server to the total number of requests of its corresponding user is used as the user preference of each piece of private data in the cache server; Among them, the user preference value of public data in the cache server is assigned to 0.

9. A mobile game server data caching method as claimed in claim 1, characterized in that: The elimination value of each piece of data in the cache server at the current moment is the difference between the elimination priority and the user preference.

10. A mobile game server data cache system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of a mobile game server data caching method as described in any one of claims 1-9 are implemented.

Citation Information

Patent Citations

  • Progressive cache elimination method and device, electronic equipment and storage medium

    CN112487029A

  • Hierarchical caching system and method and server

    CN117785034A