Multi-level cache method and apparatus, computer device and storage medium
By using a multi-level caching method, client-side caching and server-side caching are separated. The server-side cache updates the client-side cache and retrieves data asynchronously from a remote database, which solves the problem of caching relying on remote networks and improves data processing performance and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2026-04-14
AI Technical Summary
In traditional computer data processing systems, the separation of caching and databases leads to remote network dependency issues, affecting data read/write performance and user access experience.
A multi-level caching approach is adopted, separating client-side caching from server-side caching. The server-side caching is used to update the client-side caching, asynchronously retrieving data from a remote database, checking the cache layer by layer, and updating it when necessary.
It improved data read and write performance, reduced the impact of remote network anomalies on user access, and enhanced the user experience.
Smart Images

Figure CN115269619B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing, and more particularly to a multi-level caching method, apparatus, computer device, and storage medium. Background Technology
[0002] In traditional computer data processing systems, data reading and writing processes are directly oriented towards the database. User data can be stored in the database instantly; for example, client-side user data can be processed and directly stored in a remote database. Using the database alone for reading and writing data heavily relies on disk read / write capabilities, severely limiting read / write performance and response speed. If thousands or even tens of thousands of read / write requests occur within a very short period, exceeding the database's capacity, it can easily cause database crashes.
[0003] To prevent database crashes under high concurrency, application caching is often used in conjunction with database systems. Caching loads frequently accessed data from a traditional remote database into memory, so that when a user accesses the same data again, it is loaded directly from memory. However, current caching methods do not deploy the memory and database systems on the same server, requiring remote network requests to read and write cached data. The performance of the cache depends on the remote network transmission rate; network failures can cause service interruptions, impacting the user experience.
[0004] Therefore, improving the read and write performance of cached data and avoiding the impact of remote service anomalies on user access is key to further enhancing data processing capabilities. Summary of the Invention
[0005] Therefore, it is necessary to provide a multi-level caching method, apparatus, computer equipment, and storage medium to address the aforementioned technical problems, thereby resolving issues such as poor data read / write performance and remote service anomalies affecting user access.
[0006] A multi-level caching method includes:
[0007] Receive a first cache update request sent by the client, which contains user application settings information; the user application settings information includes user information and application settings information of layers 1 to N;
[0008] Based on the user application settings information, the server cache is checked layer by layer to see if there is cache update data that matches the user application settings information;
[0009] If the server-side cache does not contain cache update data that matches the application settings information of layer M, a second cache update request is sent to the remote database; the second cache update request includes the user information and the application settings information of layer M; wherein M is less than or equal to N;
[0010] Obtain the database update data returned by the remote database in response to the second cache update request, and update the server cache according to the database update data;
[0011] Retrieve cache update data that matches the user application settings from the updated server cache;
[0012] The cache update data is sent to the client so that the client updates its cache based on the cache update data.
[0013] A multi-level cache device, comprising:
[0014] The first cache update request receiving module is used to receive a first cache update request sent by the client, which contains user application settings information; the user application settings information includes user information and application settings information of layers 1 to N.
[0015] The server-side cache checking module is used to check layer by layer whether there is cache update data in the server-side cache that matches the user application settings information based on the user application settings information;
[0016] The second cache update request generation module is used to send a second cache update request to the remote database when it is detected that there is no cache update data matching the M-layer application settings information in the server cache; the second cache update request includes the user information and the M-layer application settings information; wherein, M is less than or equal to N;
[0017] A server-side cache update module is used to obtain database update data returned by the remote database in response to the second cache update request, and update the server-side cache according to the database update data;
[0018] The cache update data acquisition module is used to acquire cache update data that matches the user application settings information from the updated server cache;
[0019] A client cache update module is used to send the cache update data to the client so that the client updates the client cache according to the cache update data.
[0020] A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the multi-level caching method described above when executing the computer-readable instructions.
[0021] A computer-readable storage medium storing computer-readable instructions, characterized in that, when executed by one or more processors, the computer-readable instructions cause the one or more processors to perform the multi-level caching method described above.
[0022] The aforementioned multi-level caching method, apparatus, computer equipment, and storage medium receive a first cache update request from a client containing user application settings information; check the server cache layer by layer according to the user application settings information to see if there is cache update data matching the user application settings information; when it is detected that the server cache does not have cache update data matching the Mth layer of the N-layer application settings information, a second cache update request is sent to a remote database; database update data returned by the remote database in response to the second cache update request is obtained, and the server cache is updated according to the database update data; cache update data matching the user application settings information is obtained from the updated server cache; and the cache update data is sent to the client to update the client cache. The multi-level caching method provided by this invention sets up client cache and server cache separately. The client no longer directly faces the remote database; the server connects the client and the remote database, and the server cache is used to update the client cache data. When the server cache data is updated, the client cache data can be updated synchronously. Users improve data read and write performance by prioritizing read and write operations on the locally stored client cache. Meanwhile, the server-side cache can asynchronously retrieve data updates from a remote database based on multi-layered application settings. When the data service corresponding to the application settings of one layer in the server-side cache experiences an anomaly, the server-side caches of other layers remain normal, and the client-side cache stored locally is unaffected. Even if the remote database experiences an anomaly, it does not affect the user's access to the client-side cached data or the server-side cached data. The user is unaware of the anomaly, thus improving the user experience. Attached Figure Description
[0023] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a flowchart illustrating a multi-level caching method in one embodiment of the present invention;
[0025] Figure 2 This is a schematic diagram of a multi-level caching device in one embodiment of the present invention;
[0026] Figure 3This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0027] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0028] In one embodiment, such as Figure 1 As shown, a multi-level caching method is provided, including the following steps S10~S60.
[0029] S10. Receive a first cache update request sent by the client, which includes user application settings information; the user application settings information includes user information and application settings information of layers 1 to N.
[0030] Understandably, the client is an application installed on a smartphone, tablet, or computer. Users directly interact with the client. The server connects the client to a remote database via a remote network service. The client has a client-side cache, and the server has a server-side cache. The remote database stores all data. The first cache update request refers to the cache update request sent by the client to the server, used to update the client-side cache based on the data in the server-side cache. The server-side cache merges and stores server-side cache data from multiple users, and sets application settings information from level 1 to level N that are associated with and match the server-side cache data. N is a positive integer and can be set as needed. Therefore, the first cache update request includes user information and application settings information from level 1 to level N to facilitate quick retrieval of the corresponding server-side cache data. In this embodiment, the first-level application settings information associated with and matching the server-side cache data is personal authorization information, the second-level application settings information is organizational authorization information, the third-level application settings information is version information, and the fourth-level application settings information is personal sorting information. The client cache stores the corresponding application data locally according to the user's identity information. The user logs in to the client with the user's identity information. The client receives the operation instructions of the specified user on the application data. When the application data corresponding to the specified user does not exist in the client cache, the client cache needs to be updated. The server receives the first cache update request sent by the client.
[0031] S20. Based on the user application settings information, check layer by layer whether there is cache update data in the server cache that matches the user application settings information.
[0032] Understandably, cache update data is retrieved from the server-side cache and used to update data in the client's local cache database. After receiving the first cache update request, the server extracts the multi-level application settings information from the request, checks the server-side cache layer by layer according to the specified user's application settings information, and uses the matching server-side cache data as the cache update data.
[0033] S30. When it is detected that there is no cache update data in the server cache that matches the application settings information of the Mth layer, a second cache update request is sent to the remote database; the second cache update request includes the user information and the application settings information of the Mth layer; wherein, M is less than or equal to N.
[0034] Understandably, the second cache update request refers to the cache update request sent by the server to the remote database, used to update the server cache based on the data in the remote database. During the process of checking the server cache layer by layer according to the user application settings, when it is detected that no server cache data matching the application settings information of layer M is found, the server cache of layer M needs to be updated. The server sends a second cache update request to the remote database, where M is less than or equal to N. The remote database stores all data for all users, and requires user information and specified layer application settings information to find the corresponding data. Therefore, the second cache update request includes user information and layer M application settings information to facilitate quick retrieval of the corresponding remote database data.
[0035] S40. Obtain the database update data returned by the remote database in response to the second cache update request, and update the server cache according to the database update data.
[0036] Understandably, the database update data is retrieved from a remote database and used to update the data in the server-side cache. The remote database responds to the second cache update request by retrieving the database update data and returning it to the server. The server then updates the server-side cache data corresponding to the application settings information at layer M in the server-side cache based on the database update data.
[0037] S50. Obtain cache update data that matches the user application settings information from the updated server cache.
[0038] Understandably, the server responds to the first cache update request by checking the updated server cache layer by layer. At this point, the server cache contains server cache data that matches the application settings information of layers 1 to N. The server cache data that matches the information in each layer is obtained, calculated, and assembled as cache update data.
[0039] S60. Send the cache update data to the client so that the client updates the client cache according to the cache update data.
[0040] Understandably, after the server obtains the server cache update from the remote database, it needs to send the cache update data to the client in response to the first cache update request, and also to maintain synchronization between the server cache and the client cache. The client then updates its cache based on the cache update data returned by the server.
[0041] This embodiment sets up a local cache on the client side and a multi-level cache on the server side. The client no longer directly interacts with the remote database; instead, the server connects the client and the remote database, and the server-side cache is used to update the client's local cache data. The server receives a first cache update request from the client containing user application settings information; it then checks the server-side cache layer by layer to see if there is cache update data matching the user application settings information; if no cache update data matching the Mth layer of the N-level application settings information is found in the server-side cache, a second cache update request is sent to the remote database; the server obtains database update data returned by the remote database in response to the second cache update request and updates the server-side cache accordingly; it then obtains the cache update data matching the user application settings information from the updated server-side cache and sends the cache update data to the client to update the client-side cache. On one hand, users can directly perform read and write operations from the locally stored client-side cache, improving data read and write performance. On the other hand, the client-side cache data can be updated from the server-side cache data through the first cache update request, while the server-side cache data is updated from the remote database through the second cache update request, ensuring that the client-side data is updated in real time. On the other hand, server-side caching can asynchronously retrieve data updates from a remote database based on multi-layered application settings. When the data service corresponding to one layer of application settings in the server-side cache experiences an anomaly, the server-side caches corresponding to other layers remain normal, and the client-side cache stored locally is unaffected. Furthermore, even if the remote database experiences an anomaly, it does not affect user access to client-side cached data or server-side cached data. Users are unaware of the anomaly, thus improving the user experience.
[0042] Optionally, step S10, that is, before receiving the first cache update request containing user application settings information sent by the client, includes:
[0043] S101, The client receives an operation instruction for opening the application;
[0044] S102, The client checks whether the application's client cache data exists according to the operation instruction;
[0045] S103. If the application does not have client-side cached data, the client generates the first cache update request.
[0046] Understandably, the client assigns different client cache data to different users based on user identity information. The specified user logs into the client using the user identity information. The client receives the specified user's operation instructions for the application. The client checks whether there is application data associated with the specified user in the client cache based on the operation instructions. If there is no application data associated with the specified user, the client generates a first cache update request based on the specified user's application settings information and sends it to the server.
[0047] In this embodiment, after the client receives the operation instruction, it first searches for the user's client cache data. If the data is not found, it generates a first cache update request. This enables accurate acquisition of client cache data and timely updates when client cache data is missing.
[0048] Optionally, in step S10, after the client checks whether the application's client-cached data exists according to the operation instruction, the method further includes:
[0049] S104. If client-side cached data of the application exists, the client loads the application interface of the application based on the client-side cached data, and generates the first cache update request according to the preset update trigger conditions.
[0050] Understandably, after receiving user commands to operate the application, the client first checks its cache for application data associated with the user. If the data exists, the application's interface is loaded directly from the cached data. The client's local memory space is limited, and user access to the application involves data read / write interactions; therefore, cached data is not static and has an expiration time. A first cache update request is generated based on preset update trigger conditions. Specifically, an expiration time is set for the cached data. The client automatically clears expired data based on the expiration time and generates the first cache update request based on the user's application settings. The expiration time can be a specific time point (year, month, day, hour) or a time span of minutes, hours, or days. It can be automatically set based on user access frequency, or users can set it themselves as needed. When expired data appears in the client cache, the update condition is triggered, and a first cache update request is sent to the server. When the remote service on the server fails, no error will be displayed to the client user. The user can still access the data that has not expired in the client cache. However, during the service failure period, the client data can no longer be updated from the server cache. For new users accessing the client for the first time, since there is no client cache data and no server cache data, a service failure will be displayed.
[0051] In this embodiment, when the application's client-side cached data exists based on the search results, the application's interface is loaded directly from the client-side cached data. Since the client-side cached data is stored locally and does not require remote network services, prioritizing access to the client-side cached data reduces response time and improves data processing performance. Simultaneously, by setting update trigger conditions to generate a first cache update request, asynchronous updates between client-side and server-side cached data can be achieved, maintaining the timeliness of the client-side cached data.
[0052] Optionally, the application settings information includes personal authorization information;
[0053] Step S20, namely, checking the server cache layer by layer for cache update data that matches the user application settings information, includes:
[0054] S201. Check if the server-side cache contains first cache update data that matches the personal authorization information;
[0055] S202. If the server-side cache does not contain first cache update data that matches the personal authorization information, then the first cache update data is obtained from the remote database.
[0056] Understandably, user application settings include the user's personal authorization information. The server cache stores application settings for multiple users, and the authorized applications for different users are different; that is, each user has corresponding personal authorization information. The first cache update data is the server cache data that matches the personal authorization information. Therefore, it is necessary to check the corresponding first cache update data in the server cache based on the personal authorization information of a specified user. The server cache retrieves the specified user's personal authorization information based on the user's information. If the server cache does not contain first cache update data that matches the personal authorization information, a second cache update request containing the user information and personal authorization information is sent to the remote database. The server then receives database update data returned by the remote database in response to the second cache update request, which serves as the first cache update data.
[0057] This embodiment updates the matching data associated with the personal authorization information in the server cache by checking whether there is first cache update data matching the personal authorization information in the server cache and obtaining the update from the remote database.
[0058] Optionally, the application settings information includes organization authorization information;
[0059] Step S20, that is, after checking whether the server-side cache contains first cache update data that matches the personal authorization information, further includes:
[0060] S203. If the server-side cache contains first cache update data that matches the individual authorization information, then check if the server-side cache contains second cache update data that matches the organization authorization information.
[0061] S204. If the server-side cache does not contain second cache update data that matches the organization's authorization information, then the second cache update data is obtained from the remote database.
[0062] Understandably, based on the specified user's identity information, the user's organization information and the corresponding organization authorization information can be obtained. Organization information includes the user's unit, department, and project team, etc. The server-side cache stores application settings information for multiple organizations; the authorized applications differ between different users' organizations, meaning each user has corresponding organization authorization information. The second cache update data is server-side cache data that matches the organization authorization information. Therefore, it is necessary to check the corresponding second cache update data in the server-side cache based on the specified user's organization authorization information. If the server-side cache does not contain second cache update data that matches the organization authorization information of the specified user's organization, a second cache update request containing user information and organization authorization information is sent to the remote database. The database update data returned by the remote database in response to the second cache update request is then used as the second cache update data.
[0063] When the client updates the client cache based on the cache update data, there may be some duplicate data between the first cache update data and the second cache update data for a specified user. That is, there are some duplicate applications between personal authorized applications and organizational authorized applications. It is necessary to summarize and deduplicate the first cache update data and the second cache update data, and keep only one copy of the duplicate data to obtain the user's authorized application cache update data.
[0064] This embodiment updates the matching data associated with the organization's authorization information in the server cache by checking whether there is second cache update data that matches the organization's authorization information in the server cache and obtaining the update from the remote database.
[0065] Optionally, the application settings information includes version information;
[0066] Step S20, that is, after checking whether the server-side cache contains second cache update data that matches the organization's authorization information, further includes:
[0067] S205. If the server-side cache contains second cache update data that matches the organization authorization information, then check if the server-side cache contains third cache update data that matches the version information.
[0068] S206. If the server-side cache does not contain third cache update data that matches the version information, then the third cache update data is obtained from the remote database.
[0069] Understandably, the server-side cache stores application settings information for multiple versions of the application. These different versions are distinct; each user-authorized application has its own version information, such as a gray-scale version and a release version. A gray-scale version is one version ahead of the release version. Users in the R&D department's test project team have gray-scale version authorization for a specific application. The third-party cache update data is server-side cache data that matches the version information. Therefore, it's necessary to check the server-side cache for the corresponding third-party cache update data based on the user's authorized application version information. If the server-side cache does not contain third-party cache update data matching the user's authorized application version information, a third-party cache update request containing user information and the user's authorized application version information is sent to the remote database. The server then receives database update data from the remote database in response to the third-party cache update request, which serves as the third-party cache update data.
[0070] This embodiment updates the matching data associated with the version information in the server cache by checking whether there is third cache update data that matches the version information of the user-authorized application in the server cache and obtaining the update from the remote database.
[0071] Optionally, the application settings information includes personal sorting information;
[0072] Step S20, that is, after checking whether the server-side cache contains third cache update data that matches the version information, further includes:
[0073] S207. If the server-side cache contains third cache update data that matches the version information, then check if the server-side cache contains fourth cache update data that matches the personal sorting information.
[0074] S208. If the server-side cache does not contain fourth cache update data that matches the personal sorting information, then the fourth cache update data is obtained from the remote database.
[0075] Understandably, the server-side cache stores application settings information for multiple users, and the application sorting information differs between users; each user has their own personal sorting information. For example, sorting applications based on the access frequency of a specified user's user-permitted applications yields a "list of frequently used applications" for that user; sorting based on the access popularity of multiple users' user-permitted applications or all applications yields a "list of recommended applications" for that user; or simply sorting all applications alphabetically yields a "list of all applications" for that user. The fourth cache update data is server-side cache data that matches the personal sorting information. Therefore, it is necessary to check the corresponding level of fourth cache update data in the server-side cache based on the specified user's personal sorting information. If the server-side cache does not contain fourth cache update data that matches the specified user's personal sorting information, a fourth cache update request containing user information and personal sorting information is sent to the remote database. The server then receives database update data returned by the remote database in response to the fourth cache update request, which serves as the fourth cache update data.
[0076] The server updates its cache based on the first, second, third, and fourth cache update data. It then retrieves the user-authorized application for the specified user based on the updated server cache, calculates and assembles the corresponding version of the user-authorized application according to the user's sorting information, and returns the cache update data to the client. The client updates its cache based on the cache update data and loads the application interface corresponding to the user's operation instructions based on the client-cached data.
[0077] This embodiment updates the matching data associated with the personal ranking information in the server cache by checking whether there is fourth cache update data that matches the personal ranking information in the server cache and obtaining the update from the remote database.
[0078] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0079] In one embodiment, a multi-level caching device is provided, which corresponds one-to-one with the multi-level caching method described in the above embodiments. For example... Figure 2 As shown, the multi-level caching device includes a first cache update request receiving module 10, a server-side cache checking module 20, a second cache update request generating module 30, a server-side cache update module 40, a cache update data acquisition module 50, and a client-side cache update module 60. Detailed descriptions of each functional module are as follows:
[0080] The first cache update request receiving module 10 is used to receive a first cache update request sent by the client, which contains user application setting information; the user application setting information includes user information and application setting information of layers 1 to N.
[0081] The server-side cache checking module 20 is used to check layer by layer whether there is cache update data in the server-side cache that matches the user application setting information according to the user application setting information;
[0082] The second cache update request generation module 30 is used to send a second cache update request to a remote database when it is detected that there is no cache update data matching the M-layer application setting information in the server cache; the second cache update request includes the user information and the M-layer application setting information; wherein, M is less than or equal to N;
[0083] The server-side cache update module 40 is used to obtain database update data returned by the remote database in response to the second cache update request, and update the server-side cache according to the database update data;
[0084] The cache update data acquisition module 50 is used to acquire cache update data that matches the user application settings information from the updated server cache;
[0085] The client cache update module 60 is used to send the cache update data to the client so that the client updates the client cache according to the cache update data.
[0086] Optionally, the first cache update request receiving module 10 includes:
[0087] The instruction receiving unit is used for the client to receive an operation instruction for opening the application;
[0088] A client cache data checking unit is used by the client to check whether the application's client cache data exists according to the operation instruction;
[0089] The first cache update request generation unit is used to generate the first cache update request if the client does not have client cache data for the application.
[0090] Optionally, the first cache update request receiving module 10 further includes:
[0091] The client cache data loading unit is used to load the application interface of the application according to the client cache data if the client cache data of the application exists, and generate the first cache update request according to the preset update trigger conditions.
[0092] Optionally, the server-side cache checking module 20 includes:
[0093] The first cache update data checking unit is used to check whether the server cache contains first cache update data that matches the personal authorization information;
[0094] The first cache update data acquisition unit is used to acquire the first cache update data from the remote database if the server cache does not contain first cache update data that matches the personal authorization information.
[0095] Optionally, the server-side cache checking module 20 also includes:
[0096] The second cache update data checking unit is used to check whether the server cache has second cache update data that matches the organization's authorization information if the server cache has first cache update data that matches the personal authorization information.
[0097] The second cache update data acquisition unit is used to acquire the second cache update data from the remote database if the server-side cache does not contain second cache update data that matches the organization's authorization information.
[0098] Optionally, the server-side cache checking module 20 also includes:
[0099] The third cache update data checking unit is used to check whether the server cache has third cache update data that matches the version information if the server cache has second cache update data that matches the organization authorization information.
[0100] The third cache update data acquisition unit is used to acquire the third cache update data from the remote database if the server cache does not have third cache update data that matches the version information.
[0101] Optionally, the server-side cache checking module 20 also includes:
[0102] The fourth cache update data checking unit is used to check whether the server cache has fourth cache update data that matches the personal sorting information if the server cache has third cache update data that matches the version information.
[0103] The fourth cache update data acquisition unit is used to acquire the fourth cache update data from the remote database if the server cache does not contain fourth cache update data that matches the personal sorting information.
[0104] For specific limitations regarding multi-level cache devices, please refer to the limitations of multi-level caching methods above, which will not be repeated here. Each module in the aforementioned multi-level cache device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independent of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the operations corresponding to each module.
[0105] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a readable storage medium and internal memory. The readable storage medium stores an operating system, computer-readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The database stores data related to a multi-level caching method. The network interface communicates with external terminals via a network connection. When the computer-readable instructions are executed by the processor, a multi-level caching method is implemented. The readable storage medium provided in this embodiment includes both non-volatile and volatile readable storage media.
[0106] In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor performs the following steps when executing the computer-readable instructions:
[0107] Receive a first cache update request sent by the client, which contains user application settings information; the user application settings information includes user information and application settings information of layers 1 to N;
[0108] Based on the user application settings information, the server cache is checked layer by layer to see if there is cache update data that matches the user application settings information;
[0109] If the server-side cache does not contain cache update data that matches the application settings information of layer M, a second cache update request is sent to the remote database; the second cache update request includes the user information and the application settings information of layer M; wherein M is less than or equal to N;
[0110] Obtain the database update data returned by the remote database in response to the second cache update request, and update the server cache according to the database update data;
[0111] Retrieve cache update data that matches the user application settings from the updated server cache;
[0112] The cache update data is sent to the client so that the client updates its cache based on the cache update data.
[0113] In one embodiment, one or more computer-readable storage media storing computer-readable instructions are provided. The readable storage media provided in this embodiment include non-volatile readable storage media and volatile readable storage media. The readable storage media stores computer-readable instructions, which, when executed by one or more processors, perform the following steps:
[0114] Receive a first cache update request sent by the client, which contains user application settings information; the user application settings information includes user information and application settings information of layers 1 to N;
[0115] Based on the user application settings information, the server cache is checked layer by layer to see if there is cache update data that matches the user application settings information;
[0116] If the server-side cache does not contain cache update data that matches the application settings information of layer M, a second cache update request is sent to the remote database; the second cache update request includes the user information and the application settings information of layer M; wherein M is less than or equal to N;
[0117] Obtain the database update data returned by the remote database in response to the second cache update request, and update the server cache according to the database update data;
[0118] Retrieve cache update data that matches the user application settings from the updated server cache;
[0119] The cache update data is sent to the client so that the client updates its cache based on the cache update data.
[0120] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware with computer-readable instructions. These computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When executed, these computer-readable instructions can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0121] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0122] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A multi-level caching method, characterized in that, include: Receive the first cache update request sent by the client, which contains user application settings information; The user application settings information includes user information and application settings information of layers 1 to N; Based on the user application settings information, the server cache is checked layer by layer to see if there is cache update data that matches the user application settings information; If the server-side cache does not contain cache update data that matches the application settings information of layer M, a second cache update request is sent to the remote database; the second cache update request includes the user information and the application settings information of layer M; wherein M is less than or equal to N; Obtain the database update data returned by the remote database in response to the second cache update request, and update the server cache according to the database update data; Retrieve cache update data that matches the user application settings information from the updated server cache; at this time, the server cache contains server cache data that matches the application settings information of layers 1 to N. Retrieve the server cache data that matches each layer, calculate and assemble it as the cache update data; The cache update data is sent to the client so that the client updates its cache based on the cache update data.
2. The multi-level caching method as described in claim 1, characterized in that, Before receiving the first cache update request containing user application settings information sent by the client, the process includes: The client receives an operation command to open the application; The client checks whether the application's client-cached data exists according to the operation instructions; If the application's client-side cached data does not exist, the client generates the first cache update request.
3. The multi-level caching method as described in claim 2, characterized in that, After the client checks whether the application's client-cached data exists according to the operation instruction, it also includes: If client-side cached data for the application exists, the client loads the application's interface based on the client-side cached data and generates the first cache update request according to preset update trigger conditions.
4. The multi-level caching method as described in claim 1, characterized in that, The application settings information includes personal authorization information; The step of checking the server-side cache layer by layer for cache update data that matches the user application settings information includes: Check if the server-side cache contains first cache update data that matches the personal authorization information; If the server-side cache does not contain first cache update data that matches the personal authorization information, then the first cache update data is obtained from the remote database.
5. The multi-level caching method as described in claim 4, characterized in that, The application settings information includes organization authorization information; After checking whether the server-side cache contains first cache update data that matches the personal authorization information, the method further includes: If the server-side cache contains first cache update data that matches the individual authorization information, then check if the server-side cache contains second cache update data that matches the organization authorization information. If the server-side cache does not contain second cache update data that matches the organization's authorization information, then the second cache update data is retrieved from the remote database.
6. The multi-level caching method as described in claim 5, characterized in that, The application settings information includes version information; After checking whether the server-side cache contains second cache update data that matches the organization's authorization information, the method further includes: If the server-side cache contains second cache update data that matches the organization's authorization information, then check if the server-side cache contains third cache update data that matches the version information. If the server-side cache does not contain third cache update data that matches the version information, then the third cache update data is obtained from the remote database.
7. The multi-level caching method as described in claim 6, characterized in that, The application settings information includes personal sorting information; After checking whether the server-side cache contains third cache update data that matches the version information, the method further includes: If the server-side cache contains third cache update data that matches the version information, then check if the server-side cache contains fourth cache update data that matches the personal sorting information. If the server-side cache does not contain fourth cache update data that matches the individual sorting information, then the fourth cache update data is obtained from the remote database.
8. A multi-level cache device, characterized in that, include: The first cache update request receiving module is used to receive the first cache update request sent by the client, which contains user application settings information; The user application settings information includes user information and application settings information of layers 1 to N; The server-side cache checking module is used to check layer by layer whether there is cache update data in the server-side cache that matches the user application settings information based on the user application settings information; The second cache update request generation module is used to send a second cache update request to the remote database when it is detected that there is no cache update data matching the M-layer application settings information in the server cache; the second cache update request includes the user information and the M-layer application settings information; wherein, M is less than or equal to N; A server-side cache update module is used to obtain database update data returned by the remote database in response to the second cache update request, and update the server-side cache according to the database update data; The cache update data acquisition module is used to acquire cache update data that matches the user application settings information from the updated server cache; at this time, there is server cache data that matches the application settings information of layers 1 to N. The server cache data matched in each layer is acquired, calculated and assembled as the cache update data. A client cache update module is used to send the cache update data to the client so that the client updates the client cache according to the cache update data.
9. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, characterized in that, When the processor executes the computer-readable instructions, it implements the multi-level caching method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing computer-readable instructions, characterized in that, When the computer-readable instructions are executed by one or more processors, the one or more processors cause the one or more processors to perform the multi-level caching method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Multi-layer cache data acquisition method and device
CN111400349A
Data caching method, device and system and readable storage medium
CN111563106A