Method, apparatus, client, and storage medium for applying a multi-level caching method
By interacting with the application server and selecting a cache strategy according to the application level, the problem of instability of applications in the weak network environment in the existing technology is solved, and rapid response and storage space are achieved.
Patent Information
- Application Number
- CN202010600213.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-28
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2040-06-28
AI Technical Summary
The network instability of existing Internet applications in weak network environments, resulting in intermittent application interruption and slow network speed, and the existing cache solutions fail to adopt different cache strategies for different applications.
A multi-level caching method is proposed to execute different caching strategies according to the application level by interacting with the application server. When accessing for the first time, send the application identification to the server, receive the application level and resources, and select a long-period or short-period cache policy based on the level to cache the resources to the hard disk or memory.
It implements different cache strategies according to the application level, quickly respond to applications with high access frequency, while saving client storage space.
Smart Images

Figure CN111752861B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of caching technologies, and particularly to an application multi-level caching method, device, client, and storage medium. Background Art
[0002] Most existing Internet applications rely on the network as a necessary condition. In a weak network environment, such as in an elevator, high-speed train, or densely built area, the network is unstable, resulting in intermittent interruption of the application, slow network speed, etc. Once the network is interrupted, the entire application becomes unavailable, and all information related to the application cannot be obtained.
[0003] In various existing caching solutions, all application resources are cached locally, and different caching strategies are not adopted for different applications. Summary of the Invention
[0004] In view of the above, it is necessary to provide an application multi-level caching method, device, client, and storage medium that can interact with an application server and implement different caching strategies according to the level of the application.
[0005] The first aspect of the present invention provides an application multi-level caching method, and the application multi-level caching method includes:
[0006] Respond to an access request of an application to start the application, and detect an operation signal received on the application;
[0007] Determine whether the access request is a first access request;
[0008] When it is determined that the access request is a first access request, send the application identifier of the application to the corresponding application server, and receive the level of the application and the application resources corresponding to the operation signal returned by the application server;
[0009] When the level of the application is the first level, cache the application resources to the hard disk using a long-cycle caching strategy;
[0010] When the level of the application is the second level, cache the application resources to the memory using a short-cycle caching strategy.
[0011] According to an optional embodiment of the present invention, the caching of the application resources using the long-cycle caching strategy includes:
[0012] Mark the page ID of each page of the application according to the tags of the page;
[0013] Record the interaction data when the user accesses each page, and the interaction data includes: scroll position, interaction status, and access parameters;
[0014] Persist the page ID, the corresponding interaction data, and the application resources to the hard disk and set a timer for the interaction data in the hard disk;
[0015] When the timer expires, clear the interaction data in the hard disk.
[0016] According to an optional embodiment of the present invention, caching the application resources by using a short-cycle caching strategy includes:
[0017] Cache the DOM nodes of the application in the memory;
[0018] When receiving a shutdown signal of the application, release the DOM nodes in the memory.
[0019] According to an optional embodiment of the present invention, the application multi-level caching method further includes:
[0020] When determining that the access request is a secondary access request, map the application resources in the hard disk to the memory;
[0021] Determine whether there is a target resource corresponding to the operation signal in the memory;
[0022] When there is the target resource in the memory, hit the target resource from the memory;
[0023] When there is no the target resource in the memory, obtain the target resource from the corresponding application server.
[0024] According to an optional embodiment of the present invention, mapping the application resources stored in the hard disk to the memory includes:
[0025] Find the storage directory corresponding to the application from the hard disk;
[0026] Determine whether there are application resources stored in the storage directory;
[0027] When there are application resources stored in the storage directory, map the application resources in the hard disk to the memory.
[0028] According to an optional embodiment of the present invention, the application multi-level caching method further includes:
[0029] Send a resource version query request to the application server so that the application server queries whether the resource version has been updated;
[0030] When receiving the result that the resource version returned by the application server has been updated, download the updated resources;
[0031] After the resource update is successful, update the application.
[0032] According to an optional embodiment of the present invention, determining whether the access request is a first access request includes:
[0033] Search the local database to see if the application identifier of the application is recorded;
[0034] When the application identifier is not found, determine that the access request is a first access request;
[0035] When the application identifier is found, determine that the access request is not a first access request.
[0036] A second aspect of the present invention provides an application multi-level caching device, the device includes:
[0037] An application startup module, configured to start the application in response to an access request received for the application, and detect an operation signal received on the application;
[0038] A request judgment module, configured to judge whether the access request is a first access request;
[0039] A resource receiving module, configured to, when it is determined that the access request is a first access request, send the application identifier of the application to the corresponding application server, and receive the level of the application and the application resources corresponding to the operation signal returned by the application server;
[0040] A first caching module, configured to, when the level of the application is the first level, cache the application resources to the hard disk using a long-cycle caching strategy;
[0041] A second caching module, configured to, when the level of the application is the second level, cache the application resources to the memory using a short-cycle caching strategy.
[0042] A third aspect of the present invention provides a client, the client includes a processor, and the processor is used to implement the application multi-level caching method when executing a computer program stored in a memory.
[0043] A fourth aspect of the present invention provides a computer-readable storage medium, on which a computer program is stored, and the computer program implements the application multi-level caching method when executed by a processor.
[0044] In summary, the application multi-level caching method, device, client, and storage medium of the present invention determine whether the accessed application is a high-frequency application through the interaction between the client and the server, and adopt different caching strategies to achieve hierarchical caching of different applications, which can not only quickly respond to applications with high access frequencies, but also save the storage space of the client. Brief Description of the Drawings
[0045] Figure 1 is a flowchart of the multi - level caching method provided in the first embodiment of the present invention.
[0046] Figure 2 is a structural diagram of the multi - level caching device provided in the second embodiment of the present invention.
[0047] Figure 3 is a schematic structural diagram of the client provided in the third embodiment of the present invention. Detailed Description of the Embodiments
[0048] In order to more clearly understand the above - mentioned objects, features and advantages of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other.
[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs. The terms used in the description of the present invention herein are only for the purpose of describing specific embodiments, and are not intended to limit the present invention.
[0050] Embodiment 1
[0051] Figure 1 is a flowchart of the multi - level caching method provided in the first embodiment of the present invention.
[0052] The multi - level caching method specifically includes the following steps. According to different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.
[0053] S11, in response to an access request received for an application, start the application and detect an operation signal received on the application.
[0054] One or more applications are installed in the client. A user can send an access request for an application by clicking or touching or voice control. When the client receives the access request for the application, it responds and starts the application.
[0055] The user can access one or more pages of the application and perform operations on one or more pages of the application, for example, watching videos, browsing pictures, reading pages, etc.
[0056] S12, determine whether the access request is a first - time access request.
[0057] The first access request to an application made by a user is called the first-time access request, and the non-first access request to an application made by a user is called the second-time access request.
[0058] In an optional embodiment, determining whether the access request is a first-time access request includes:
[0059] Searching whether the application identifier of the application is recorded in the local database;
[0060] When the application identifier is not searched out, determining that the access request is a first-time access request;
[0061] When the application identifier is searched out, determining that the access request is not a first-time access request.
[0062] Different applications in the client correspond to different application identifiers. When the client receives an access request for an application, it can record the application identifier of the application in the local database, and when it subsequently receives an access request for the application, it first determines whether to access the application for the first time or the second time according to the application identifier of the application. When the application identifier of the application has not been recorded, it indicates that the application is accessed for the first time; when the application identifier of the application has been recorded, it indicates that the application is accessed for the second time.
[0063] S13, when it is determined that the access request is a first-time access request, sending the application identifier of the application to the corresponding application server, and receiving the level of the application and the application resources corresponding to the operation signal returned by the application server.
[0064] Sending the application identifier to the application server corresponding to the application, so that the application server judges the access frequency of the application and determines the level of the application according to the access frequency. The higher the access frequency (the access frequency is greater than the preset frequency threshold), the level of the corresponding application is the first level. The lower the access frequency (the access frequency is less than or equal to the preset frequency threshold), the level of the corresponding application is the second level.
[0065] The application server can determine the application level of the application according to the number of access requests for the application sent by multiple clients. The more access requests for the application received, the application level is determined to be the first level, and the fewer access requests for the application received, the application level is determined to be the second level.
[0066] When the client detects an operation signal from the user on the application, it sends the operation signal to the application server. The application server obtains the resources corresponding to the operation signal and returns them to the client. The application server can return both the level of the application and the application resources corresponding to the first operation signal to the client. The application server can also first return the application resources corresponding to the first operation signal to the client, and then return the level of the application when it receives the application identifier.
[0067] S14. When the level of the application is the first level, the application resources are cached to the hard disk using a long-cycle caching strategy.
[0068] When it is determined that the application accessed by the user is a first-level application, a long-cycle caching strategy is used for caching, which is convenient for the user to directly hit the cache subsequently and saves time.
[0069] S15. When the level of the application is the second level, the application resources are cached to the memory using a short-cycle caching strategy.
[0070] When it is determined that the application accessed by the user is a second-level application, a short-cycle caching strategy is used for caching, which is convenient for saving storage space.
[0071] In this embodiment, by interacting between the client and the server to determine whether the accessed application is a high-frequency application and adopting different caching strategies, hierarchical caching of different applications is achieved. It can not only quickly respond to applications with high access frequencies but also save the storage space of the client.
[0072] In an optional embodiment, the caching of the application resources using the long-cycle caching strategy includes:
[0073] Mark the page ID of each page of the application according to the tags of the page;
[0074] Record the interaction data when the user accesses each page, where the interaction data includes: scroll position, interaction status, and access parameters;
[0075] Persist the page ID, the corresponding interaction data, and the application resources to the hard disk and set a timer for the interaction data in the hard disk;
[0076] When the timer expires, clear the interaction data in the hard disk.
[0077] In this optional embodiment, the tags of the page can be tab tags or a tags. The tab tags or a tags in different pages are different.
[0078] In the prior art, the caching of a page only saves DOM nodes, without saving interactive data such as the scroll position, interactive state, and access parameters of the page. Therefore, the access state of the accessed page cannot be truly saved. Moreover, in the prior art, if the same page is accessed again, only the latest access state of the page is recorded, that is, the historical access state is overwritten, resulting in chaos.
[0079] In this embodiment, by caching the scroll position, interactive state, access parameters, and page ID of each access of each page to the hard disk without destroying them, the caching of the access state at the page level is realized. When the user accesses the page again, instead of reloading the page and obtaining multiple data in the page, multiple data of the page are directly obtained from the hard disk, and the access state of the page is restored according to the multiple data. In this way, not only can the response and reuse capabilities of the page be greatly improved, but also the experience of seamless page switching can be obtained.
[0080] The timer is used to set the valid time of the interactive data in the hard disk, so that the data in the hard disk can be cleared to avoid occupying the hard disk space for a long time and affecting the performance of the client.
[0081] It should be emphasized that to further ensure the privacy and security of the above interactive data, the above interactive data can also be stored in a node of a blockchain.
[0082] The blockchain referred to in the present invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a string of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity (anti-counterfeiting) of the information and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer, etc.
[0083] In an optional embodiment, the caching of the application resources by adopting a short-cycle caching strategy includes:
[0084] Caching the DOM nodes of the application in the memory;
[0085] When a shutdown signal of the application is received, releasing the DOM nodes in the memory.
[0086] In this optional embodiment, since the short-cycle caching strategy caches the application resources in the memory, the memory data will be released when the application is closed. Therefore, it is valid during a single opening, while the long-cycle caching strategy can ensure that the caching is valid for multiple starts of the application.
[0087] In an optional embodiment, the application multi-level caching method further includes:
[0088] When it is determined that the access request is a secondary access request, map the application resources in the hard disk to the memory;
[0089] Determine whether there is a target resource in the memory corresponding to the operation signal;
[0090] When there is the target resource in the memory, hit the target resource from the memory;
[0091] When there is no such target resource in the memory, obtain the target resource from the corresponding application server.
[0092] In this optional embodiment, after the initial access, multiple data of the application page are cached. During the secondary access, no network request is initiated. Even if the user is completely offline, the pages that have been accessed can be fully accessed again, achieving the effect of instantly opening the page, greatly improving the user experience and user stickiness. Map the resources in the hard disk to the memory, so the step of first checking whether there is a target resource for the same request will be performed in the memory instead of reading the hard disk each time, which can avoid the damage to the hard disk caused by frequent hard disk reading, and the efficiency of hitting the target resource from the memory is higher than that from the hard disk.
[0093] In an optional embodiment, the mapping of the application resources in the hard disk to the memory includes:
[0094] Find the storage directory corresponding to the application from the hard disk;
[0095] Determine whether there are application resources stored in the storage directory;
[0096] When there are application resources stored in the storage directory, map the stored application resources in the hard disk to the memory.
[0097] In this optional embodiment, when there are application resources stored in the storage directory, it indicates that the application resources have not expired, so the application resources can be mapped to the memory first for easy reading from the memory.
[0098] In an optional embodiment, the application multi-level caching method further includes:
[0099] Send a resource version query request to the application server to enable the application server to query whether the resource version has been updated;
[0100] When receiving the result that the resource version has been updated returned by the application server, download the updated resources;
[0101] Update the application after the resource update is successful.
[0102] In this alternative embodiment, the service working thread of the client will request the server to query whether there is an update to the static resource version. If the server queries that there is an updated version of the static resource, it will send the updated version of the static resource to the client. The client silently downloads the updated version of the static resource in the background and, after the update is successful, updates the application the next time the application is opened. Alternatively, the client prompts the user to update the application after the update is successful.
[0103] Figure 2 It is the structural diagram of the application multi-level caching device provided in the second embodiment of the present invention.
[0104] In some embodiments, the application multi-level caching device 20 may include multiple functional modules composed of computer program segments. The computer programs of each program segment in the application multi-level caching device 20 may be stored in the memory of the client and executed by the at least one processor to execute (see details in Figure 1 the description) the functions of application multi-level caching.
[0105] In this embodiment, the application multi-level caching device 20 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: an application startup module 201, a request judgment module 202, a resource receiving module 203, a first caching module 204, a second caching module 205, a resource mapping module 206, a resource hit module 207, and a version update module 208. The module referred to in the present invention means a series of computer program segments that can be executed by at least one processor and can complete fixed functions, and are stored in the memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0106] The application startup module 201 is used to start the application in response to the received access request of the application and detect the operation signal received on the application.
[0107] One or more applications are installed in the client. The user can send an access request to the application by clicking or touching or voice control. When the client receives the access request of the application, it responds and starts the application.
[0108] The user can access one or more pages of the application and perform operations on one or more pages of the application, such as watching videos, browsing pictures, reading pages, etc.
[0109] The request judgment module 202 is used to judge whether the access request is a first access request.
[0110] The first access request to an application made by a user is called the first-time access request, and the non-first access request to an application made by a user is called the second-time access request.
[0111] In an optional embodiment, the request determination module 202 determines whether the access request is a first-time access request, including:
[0112] Search whether the application identifier of the application is recorded in the local database;
[0113] When the application identifier is not searched, it is determined that the access request is a first-time access request;
[0114] When the application identifier is searched, it is determined that the access request is not a first-time access request.
[0115] Different applications in the client correspond to different application identifiers. When the client receives an access request for an application, it can record the application identifier of the application in the local database, and when it subsequently receives an access request for the application, it first determines whether to access the application for the first time or the second time according to the application identifier of the application. When the application identifier of the application has not been recorded, it indicates that the application is accessed for the first time; when the application identifier of the application has been recorded, it indicates that the application is accessed for the second time.
[0116] The resource receiving module 203 is configured to, when it is determined that the access request is a first-time access request, send the application identifier of the application to the corresponding application server and receive the level of the application and the application resources corresponding to the operation signal returned by the application server.
[0117] Send the application identifier to the application server corresponding to the application, so that the application server judges the access frequency of the application and determines the level of the application according to the access frequency. The higher the access frequency (the access frequency is greater than the preset frequency threshold), the level of the corresponding application is the first level. The lower the access frequency (the access frequency is less than or equal to the preset frequency threshold), the level of the corresponding application is the second level.
[0118] The application server can determine the application level of the application according to the number of access requests for the application sent by multiple clients. The more access requests for the application received, the application level is determined to be the first level, and the fewer access requests for the application received, the application level is determined to be the second level.
[0119] When the client detects an operation signal from the user on the application, it sends the operation signal to the application server. The application server retrieves the resources corresponding to the operation signal and returns them to the client. The application server can return both the level of the application and the application resources corresponding to the first operation signal to the client. The application server can also first return the application resources corresponding to the first operation signal to the client and then return the level of the application when it receives the application identifier.
[0120] The first cache module 204 is used to cache the application resources to the hard disk using a long-cycle cache policy when the level of the application is the first level.
[0121] When it is determined that the application accessed by the user is a first-level application, a long-cycle cache policy is used for caching, which facilitates the user to directly hit the cache subsequently and saves time.
[0122] The second cache module 205 is used to cache the application resources to the memory using a short-cycle cache policy when the level of the application is the second level.
[0123] When it is determined that the application accessed by the user is a second-level application, a short-cycle cache policy is used for caching, which facilitates saving storage space.
[0124] In this embodiment, by interacting between the client and the server to determine whether the accessed application is a high-frequency application and adopting different cache policies, hierarchical caching of different applications is achieved. It can not only quickly respond to applications with high access frequencies but also save the storage space of the client.
[0125] In an alternative embodiment, the first cache module 204 caching the application resources using a long-cycle cache policy includes:
[0126] Marking the page ID of each page of the application according to the tags of the page;
[0127] Recording the interaction data when the user accesses each page, where the interaction data includes: scroll position, interaction status, and access parameters;
[0128] Persisting the page ID, the corresponding interaction data, and the application resources to the hard disk and setting a timer for the interaction data in the hard disk;
[0129] When the timer expires, clearing the interaction data in the hard disk.
[0130] In this alternative embodiment, the tags of the page can be tab tags or a tags. The tab tags or a tags in different pages are different.
[0131] In the prior art, the caching of a page only saves DOM nodes, without saving interactive data such as the scroll position, interactive state, and access parameters of the page. Therefore, the access state of the accessed page cannot be truly saved. Moreover, in the prior art, if the same page is accessed again, only the latest access state of the page is recorded, that is, the historical access state is overwritten, resulting in chaos.
[0132] In this embodiment, by caching the scroll position, interactive state, access parameters, and page ID at each access of each page to the hard disk without destroying them, caching of the access state at the page level is achieved. When the user accesses the page again, instead of reloading the page and obtaining multiple data in the page, multiple data of the page are directly obtained from the hard disk, and the access state of the page is restored according to the multiple data. In this way, not only can the response and reuse capabilities of the page be greatly improved, but also the experience of seamless switching of the page can be obtained.
[0133] The timer is used to set the valid time of the interactive data in the hard disk, so that the data in the hard disk can be cleared, avoiding occupying the hard disk space for a long time and affecting the performance of the client.
[0134] It should be emphasized that to further ensure the privacy and security of the above interactive data, the above interactive data can also be stored in a node of a blockchain.
[0135] The blockchain referred to in the present invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain, in essence, is a decentralized database, a string of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity (anti-counterfeiting) of the information and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer, etc.
[0136] In an optional embodiment, the second caching module 205 caches the application resources by adopting a short-cycle caching strategy, including:
[0137] Caching the DOM nodes of the application into the memory;
[0138] When receiving a closing signal of the application, releasing the DOM nodes in the memory.
[0139] In this optional embodiment, since the short-cycle caching strategy caches the application resources into the memory, the memory data will be released when the application is closed. Therefore, it is valid during a single opening, while the long-cycle caching strategy can ensure the validity of caching for multiple starts of the application.
[0140] The resource mapping module 206 is configured to map the application resources in the hard disk to the memory when it is determined that the access request is a secondary access request.
[0141] The resource hit module 207 is configured to determine whether there is a target resource in the memory corresponding to the operation signal; when there is the target resource in the memory, hit the target resource from the memory; when there is no target resource in the memory, obtain the target resource from the corresponding application server.
[0142] In this alternative embodiment, after the initial access, multiple data of the application page are cached. During the secondary access, no network request is initiated. Even if the user is completely offline, the pages that have been accessed can be fully accessed again, achieving the effect of instantly opening the pages, which greatly improves the user experience and user stickiness. The resources in the hard disk are mapped to the memory, so the step of first checking whether there is a target resource for the same request will be performed in the memory instead of reading the hard disk each time, which can avoid damaging the hard disk due to frequent hard disk reads, and the efficiency of hitting the target resource from the memory is higher than that from the hard disk.
[0143] In an alternative embodiment, the resource mapping module 206 mapping the application resources in the hard disk to the memory includes:
[0144] Search for the storage directory corresponding to the application in the hard disk;
[0145] Determine whether there are application resources stored in the storage directory;
[0146] When there are application resources stored in the storage directory, map the application resources stored in the hard disk to the memory.
[0147] In this alternative embodiment, when there are application resources stored in the storage directory, it indicates that the application resources have not expired, so the application resources can be first mapped to the memory for easy reading from the memory.
[0148] The version update module 208 is configured to send a resource version query request to the application server to enable the application server to query whether the resource version has been updated; when receiving the result that the resource version has been updated returned by the application server, download the updated resources; after the resource update is successful, update the application.
[0149] In this alternative embodiment, the service worker thread of the client requests the server to query whether there is an update to the static resource version. If the server finds an updated version of the static resource, it sends the updated version of the static resource to the client. The client silently downloads the updated version of the static resource in the background and, after the update is successful, updates the application the next time the application is opened. Alternatively, after the update is successful, the client prompts the user to update the application.
[0150] Refer to Figure 3 As shown, it is a schematic structural diagram of the client provided by Embodiment 3 of the present invention. In a preferred embodiment of the present invention, the client 3 includes a memory 31, at least one processor 32, at least one communication bus 33, and a transceiver 34.
[0151] Those skilled in the art should understand that Figure 3 The structure of the client shown does not constitute a limitation on the embodiments of the present invention. It can be a bus structure or a star structure. The client 3 may further include more or fewer other hardware or software than shown, or different component arrangements.
[0152] In some embodiments, the client 3 is a client capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits, programmable gate arrays, digital signal processors, and embedded devices, etc. The client 3 may further include a client device, and the client device includes, but is not limited to, any electronic product that can interact with the client through means such as a keyboard, mouse, remote control, touchpad, or voice control device. For example, personal computers, tablet computers, smart phones, digital cameras, etc.
[0153] It should be noted that the client 3 is only an example. Other existing or future electronic products that can be adapted to the present invention should also be included within the protection scope of the present invention and are hereby incorporated by reference.
[0154] In some embodiments, the memory 31 is used to store computer programs and various data, such as the devices installed in the client 3, and to achieve high-speed and automatic access to programs or data during the operation of the client 3. The memory 31 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electrically-erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM), or other optical disc memories, magnetic disk memories, tape memories, or any other computer-readable medium capable of carrying or storing data.
[0155] In some embodiments, the at least one processor 32 may be composed of integrated circuits. For example, it may be composed of a single packaged integrated circuit, or may be composed of multiple packaged integrated circuits with the same or different functions, including a combination of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The at least one processor 32 is the control core of the client 3, connecting various components of the entire client 3 through various interfaces and lines, and by running or executing the programs or modules stored in the memory 31, and calling the data stored in the memory 31, to perform various functions of the client 3 and process data.
[0156] In some embodiments, the at least one communication bus 33 is provided to enable connection communication between the memory 31 and the at least one processor 32, etc.
[0157] Although not shown, the client 3 may also include a power supply (such as a battery) for powering each component. Preferably, the power supply can be logically connected to the at least one processor 32 through a power management device, so as to realize functions such as management of charging, discharging, and power consumption management through the power management device. The power supply may also include any components such as one or more DC or AC power supplies, a recharge device, a power failure detection circuit, a power converter or inverter, a power status indicator, etc. The client 3 may also include various sensors, a Bluetooth module, a Wi-Fi module, etc., which will not be elaborated here.
[0158] It should be understood that the above embodiments are only for illustrative purposes and are not limited by this structure in the scope of the patent application.
[0159] The integrated units implemented in the form of software function modules as described above can be stored in a computer-readable storage medium. The above software function modules are stored in a storage medium and include several instructions for causing a client (which may be a personal computer or a network device, etc.) or a processor to execute a part of the application multi-level caching method described in each embodiment of the present invention.
[0160] In a further embodiment, in combination with Figure 2 , the at least one processor 32 can execute the operating device of the client 3 and various installed application programs, computer programs, etc., for example, the above-mentioned various modules.
[0161] A computer program is stored in the memory 31, and the at least one processor 32 can call the computer program stored in the memory 31 to execute related functions. For example, Figure 2 each of the modules described in
[0162] is a computer program stored in the memory 31 and is executed by the at least one processor 32 to implement the functions of each module.
[0163] Specifically, for the specific implementation method of the above instructions by the at least one processor 32, reference can be made to Figure 1 the description of the relevant steps in the corresponding embodiment, which will not be elaborated here.
[0164] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0165] The module described as a separation component may or may not be physically separated. The component shown as a module may or may not be a physical unit, that is, it may be located in one place or may be distributed over multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0166] In addition, in each embodiment of the present invention, the functional modules can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a combination of hardware and software functional modules.
[0167] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and without departing from the spirit or basic characteristics of the present invention, the present invention can be implemented in other specific forms. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be included in the present invention. Any reference signs in the claims should not be regarded as limiting the claimed rights. In addition, it is obvious that the word "comprising" does not exclude other units, and the singular does not exclude the plural. The multiple units or devices stated in the device claims can also be implemented by one unit or device through software or hardware. The words such as first and second are used to indicate names and do not indicate any specific order.
[0168] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. An application multi-level caching method, characterized in that, The described multi-level caching method for applications includes: Upon receiving an access request for an application, start the application and detect the operation signals received on the application; Determine whether the access request is a first access request; When it is determined that the access request is a first access request, send the application identifier of the application to the corresponding application server and receive the level of the application and the application resources corresponding to the operation signals returned by the application server; When the level of the application is the first level, cache the application resources to the hard disk using a long-cycle caching strategy, including: marking the page ID of each page of the application according to the tags of the page; recording the interaction data when the user accesses each page, where the interaction data includes: scroll position, interaction status, and access parameters; persist the page ID, the corresponding interaction data, and the application resources to the hard disk and set a timer for the interaction data in the hard disk; when the timer expires, clear the interaction data in the hard disk; When the level of the application is the second level, cache the application resources to the memory using a short-cycle caching strategy; When it is determined that the access request is a second access request, map the application resources in the hard disk to the memory; determine whether there is a target resource corresponding to the operation signal in the memory; when there is the target resource in the memory, hit the target resource from the memory; when there is no target resource in the memory, obtain the target resource from the corresponding application server.
2. The application multi-level caching method according to claim 1, characterized in that, The caching of the application resources using the short-cycle caching strategy includes: Cache the DOM nodes of the application to the memory; When receiving a close signal for the application, release the DOM nodes in the memory.
3. The application multi-level caching method according to claim 1, characterized in that, The mapping of the application resources in the hard disk to the memory includes: Search for the storage directory corresponding to the application in the hard disk; Determine whether there are application resources stored in the storage directory; When there are application resources stored in the storage directory, map the application resources stored in the hard disk to the memory.
4. The application multi-level caching method according to any one of claims 1 to 3, characterized in that, The multi-level caching method for applications further includes: Send a resource version query request to the application server to enable the application server to query whether the resource version has been updated; When receiving the result that the resource version has been updated returned by the application server, download the updated resources; After the resource update is successful, update the application.
5. The application multi-level caching method according to any one of claims 1 to 3, characterized in that, The determination of whether the access request is a first access request includes: Search whether the application identifier of the application is recorded in the local database; When the application identifier is not searched, determine that the access request is a first access request; When the application identifier is searched, determine that the access request is not a first access request.
6. An application multi-level caching device, characterized in that, The multi-level caching device for applications includes: An application start module, configured to start the application upon receiving an access request for the application and detect the operation signals received on the application; A request judgment module, configured to determine whether the access request is a first access request; A resource receiving module, configured to, when determining that the access request is a first access request, send the application identifier of the application to the corresponding application server, and receive the level of the application and the application resources corresponding to the operation signal returned by the application server; A first caching module, configured to, when the level of the application is the first level, cache the application resources to the hard disk by using a long-cycle caching strategy, including: marking the page ID of each page of the application according to the label of the page; recording the interaction data when the user accesses each page, where the interaction data includes: scroll position, interaction status, and access parameters; persisting the page ID, the corresponding interaction data, and the application resources to the hard disk and setting a timer for the interaction data in the hard disk; when the timer expires, clearing the interaction data in the hard disk; A second caching module, configured to, when the level of the application is the second level, cache the application resources to the memory by using a short-cycle caching strategy; A resource mapping module, configured to, when determining that the access request is a secondary access request, map the application resources in the hard disk to the memory; A resource hit module, configured to determine whether there is a target resource corresponding to the operation signal in the memory; when there is the target resource in the memory, hitting the target resource from the memory; when there is no target resource in the memory, obtaining the target resource from the corresponding application server.
7. A client, characterized in that, The client includes a processor, and the processor is configured to implement the application multi-level caching method according to any one of claims 1 to 5 when executing a computer program stored in a memory.
8. A computer-readable storage medium, on which a computer program is stored, characterized in that, The computer program, when executed by the processor, implements the application multi-level caching method according to any one of claims 1 to 5.
Citation Information
Patent Citations
A file processing method and a terminal
CN109947367A