Cache Management Method, Device, Medium and Equipment

By using the reference pointer table in the cache area to manage object data and perform release management according to the call frequency and time order, the problem of excessive cache space occupied under the limitation of memory resources is solved, and the optimization of cache management and stable operation of application is achieved.

CN114741335BActive Publication Date: 2025-06-24TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210417846.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-20
Publication Date
2025-06-24
Estimated Expiration
2042-04-20

AI Technical Summary

Technical Problem

How to reduce the cache space usage of the application while ensuring the performance of the application, especially when memory resources are limited.

Method used

By using a reference pointer table in the cache area to manage object data, release management is carried out according to the call frequency and time order of the object data, ensuring that the data that has been called recently or frequently is retained, and data that has not been called for a long time tends to be released.

Benefits of technology

It effectively reduces the cache usage of the application, optimizes the cache management, improves the cache hit rate and object data reading efficiency, and ensures the stable operation of the application under memory constraints.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114741335B_ABST
    Figure CN114741335B_ABST
Patent Text Reader

Abstract

This application belongs to the field of computer technology, and specifically relates to a cache management method, device, medium, and equipment. The method includes: if the object data stored in the cache area is called, a first reference pointer for pointing to the object data is created according to the object data; and the first reference pointer is stored in the first reference table, and a first value is added to the preset parameter of the object data; then, the first reference pointer is released according to the number and storage sequence of the first reference pointers in the first reference table, and the first value is subtracted from the preset parameter of the object data of the released first reference pointer; when the preset parameter of the object data is less than or equal to the first preset threshold, the object data is released from the cache area. The technical solution of the embodiment of this application can reduce the system memory occupied by the application while ensuring the application running performance, and realize the optimization of cache management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and particularly relates to a cache management method, apparatus, medium, and device. Background Art

[0002] In recent years, the memory data required by computing systems has been growing continuously, so it is necessary to provide a larger memory space for memory data computing technologies. Currently, memory data processing frameworks are widely used in applications such as machine learning, graph computing, and stream processing. Random Access Memory (RAM) is used as memory. Since the speed of accessing data in RAM is several orders of magnitude faster than accessing data from a hard disk and the network respectively, the speed of executing applications by the memory data processing framework has also been greatly improved. However, the high price of RAM results in limited memory resources, and only part of the data can be cached in memory. Based on this, it is necessary to manage memory cache resources.

[0003] Generally, the more data is cached, the more obvious the improvement in the performance of system applications. However, due to the limited space of fast devices such as memory, it is impossible to cache an infinite amount of data. For example, in the Linux operating system, when the physical memory is exhausted, the swap partition will be used. Since the performance of the swap partition is not as good as that of memory, swapping memory data to the swap partition will seriously reduce the performance of the application system.

[0004] Therefore, how to reduce the cache space occupied by an application while ensuring the running performance of the application is a technical problem that needs to be solved urgently. Summary of the Invention

[0005] The purpose of this application is to provide a cache management method, apparatus, medium, and device, which can reduce the cache occupation of an application while ensuring the running performance of the application.

[0006] Other features and advantages of this application will become obvious through the following detailed description, or be learned in part through the practice of this application.

[0007] According to one aspect of the embodiments of this application, a cache management method is provided. The method includes:

[0008] If the object data stored in the cache area is called, a first reference pointer for pointing to the object data is created according to the object data, and the object data includes a preset parameter set to a preset value;

[0009] The first reference pointer is stored in the first reference table, and the preset parameter of the object data is increased by a first value;

[0010] When the number of first reference pointers in the first reference table is greater than a preset number threshold, according to the storage order of the first reference pointers in the first reference table, release the first reference pointers in the first reference table, and subtract the first numerical value from the preset parameter of the object data pointed to by the released first reference pointers;

[0011] When the preset parameter of the object data is less than or equal to the first preset threshold, release the object data from the cache area.

[0012] According to one aspect of the embodiments of the present application, there is provided a cache management device, the device includes:

[0013] A first reference pointer creation module, configured to create a first reference pointer for pointing to the object data according to the object data if the object data stored in the cache area is called, where the object data includes a preset parameter set to a preset numerical value;

[0014] A first reference pointer storage module, configured to store the first reference pointer in a first reference table, and increase the preset parameter of the object data by a first numerical value;

[0015] A first reference pointer release module, configured to release the first reference pointers in the first reference table according to the storage order of the first reference pointers in the first reference table when the number of first reference pointers in the first reference table is greater than a preset number threshold, and subtract the first numerical value from the preset parameter of the object data pointed to by the released first reference pointers;

[0016] An object data release module, configured to release the object data from the cache area when the preset parameter of the object data is less than or equal to the first preset threshold.

[0017] In some embodiments of the present application, based on the above technical solution, the cache management device further includes:

[0018] A second reference pointer creation unit, configured to create a second reference pointer for pointing to the object data according to the object data if the object data stored in the cache area is called, send the object data to the calling party through the second reference pointer, and increase the preset parameter of the object data by a second numerical value;

[0019] A second reference pointer release unit, configured to release the second reference pointer if the calling party ends the call of the object data, and subtract the second numerical value from the preset parameter of the object data.

[0020] In some embodiments of the present application, based on the above technical solution, the cache management device further includes:

[0021] A third reference pointer creation unit, configured to create third reference pointers respectively corresponding to each object data in the cache area, and store each of the third reference pointers in a third reference table, where the third reference pointer is used to point to the object data corresponding to the third reference pointer in the cache area;

[0022] The second reference pointer creation unit includes:

[0023] An object identifier acquisition subunit, configured to acquire an object identifier of object data to be called;

[0024] A third reference pointer search unit, configured to search the third reference table according to the object identifier to obtain a third reference pointer corresponding to the object identifier;

[0025] An object data reading unit, configured to read the object data corresponding to the object identifier according to the third reference pointer, and create a second reference pointer for pointing to the read object data.

[0026] In some embodiments of the present application, based on the above technical solution, the cache management device further includes:

[0027] A first integrity parameter acquisition unit, configured to acquire a first integrity parameter of object data to be called;

[0028] An integrity parameter comparison unit, configured to acquire a second integrity parameter of the object data read by the third reference pointer, and compare the first integrity parameter with the second integrity parameter;

[0029] A missing parameter determination unit, configured to determine a missing parameter according to the first integrity parameter and the second integrity parameter when the degree of completeness of the object data indicated by the second integrity parameter does not cover the degree of completeness of the object data indicated by the first integrity parameter, where the missing parameter is used to indicate other data in the object data indicated by the first integrity parameter except the object data indicated by the second integrity parameter;

[0030] An object data update unit, configured to query a local database or a cloud database, read incremental data corresponding to the object identifier and the missing parameter, and update the object data read by the third reference pointer according to the incremental data.

[0031] In some embodiments of the present application, based on the above technical solution, the cache management device further includes:

[0032] A third reference pointer release unit, configured to release the third reference pointer corresponding to the object data that has been released from the cache area from the third reference table.

[0033] In some embodiments of the present application, based on the above technical solutions, the cache management device further includes:

[0034] A local database query unit, configured to, if the third reference pointer corresponding to the object identifier does not exist in the third reference table, read the object data corresponding to the object identifier by querying the local database, and create a second reference pointer for pointing to the read object data;

[0035] A cloud database query unit, configured to, if the object data corresponding to the object identifier does not exist in the local database, read the object data corresponding to the object identifier by querying the cloud database, and create a second reference pointer for pointing to the read object data.

[0036] In some embodiments of the present application, based on the above technical solutions, the local database query unit includes:

[0037] A first object data query unit, configured to aggregate multiple requests for querying object data from the local database within a program loop into one request and send it to the local database, and query and read the object data corresponding to the object identifiers in each request;

[0038] The cloud database query unit includes:

[0039] A second object data query unit, configured to aggregate multiple requests for querying object data from the cloud database within a program loop into one request and send it to the cloud database, and query and read the object data corresponding to the object identifiers in each request.

[0040] In some embodiments of the present application, based on the above technical solutions, the local database query unit includes:

[0041] A first object identifier recording unit, configured to send a first query request to the local database and record the first object identifier included in the first query request in a waiting list;

[0042] A first object identifier deleting unit, configured to receive the object data corresponding to the first object identifier returned by the local database and delete the first object identifier from the waiting list;

[0043] An object identifier comparing unit, configured to compare the second object identifier with the object identifiers in the waiting list before sending a second query request including the second object identifier to the local database;

[0044] The second query request stopping and sending unit is configured to stop sending the second query request when the second object identifier is the same as the target object identifier in the waiting list, and wait for the local database to return the object data corresponding to the target object identifier, and then use the object data corresponding to the target object identifier as the query result for the second query request;

[0045] The second query request continuing and sending unit is configured to continue sending the second query request to the local database and receive the object data corresponding to the second object identifier returned by the local database when the second object identifier is not the same as any object identifier in the waiting list.

[0046] In some embodiments of the present application, based on the above technical solution, the cache management device further includes:

[0047] The object data acquisition unit is configured to acquire the object data stored in the cache area when the cache area needs to be cleared;

[0048] The compression processing unit is configured to perform compression processing on the data of a preset category in the object data when the preset parameter of the object data is greater than a second preset threshold, and the second preset threshold is greater than the first preset threshold;

[0049] The data release unit is configured to release the data of a preset category in the object data from the cache area and update the integrity parameter of the object data according to the data of the preset category when the preset parameter of the object data is greater than the first preset threshold and less than or equal to the second preset threshold.

[0050] According to one aspect of the embodiments of the present application, there is provided a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processor, it implements the cache management method in the above technical solution.

[0051] According to one aspect of the embodiments of the present application, there is provided an electronic device, which includes: a processor; and a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the cache management method in the above technical solution by executing the executable instructions.

[0052] According to one aspect of the embodiments of the present application, there is provided a computer program product or a computer program, which includes computer instructions, and when the processor of a computer device executes the computer instructions, the computer device executes the cache management method in any of the above technical solutions.

[0053] In the technical solution provided by the embodiments of the present application, if the object data stored in the cache area is called, a first reference pointer for pointing to the object data is created according to the object data; and the first reference pointer is stored in the first reference table, and a first value is added to the preset parameter of the object data; then the first reference pointer is released according to the number and storage sequence of the first reference pointers in the first reference table, and the preset parameter of the object data of the released first reference pointer is subtracted by the first value; when the preset parameter of the object data is less than or equal to the first preset threshold, the object data is released from the cache area; thus, the release management of the object data in the cache area is realized through the preset parameter of the object data, and the release management of the first reference pointer is realized through the first reference table, which can keep the newly called object data or the object data called multiple times recently in the cache area without being released, while the object data that has not been called for a long time tends to be released from the cache area, so as to reduce the system memory occupied by the application while ensuring the application running performance, and realize the optimization of the cache management.

[0054] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.

[0056] Figure 1 Schematically shows an exemplary device architecture block diagram applying the technical solution of the present application.

[0057] Figure 2 Schematically shows a flowchart of the steps of the cache management method according to some embodiments of the present application.

[0058] Figure 3 Schematically shows an overall architecture diagram of the system applicable to an embodiment of the present application.

[0059] Figure 4 Schematically shows an example diagram of an application scenario that requires the use of object data in an embodiment of the present application.

[0060] Figure 5 Schematically shows a flowchart of the steps of the steps that may further be included in an embodiment of the present application.

[0061] Figure 6Schematically shows a flowchart of steps for creating a second reference pointer for pointing to object data according to object data in an embodiment of the present application.

[0062] Figure 7 Schematically shows a flowchart of steps after reading object data corresponding to an object identifier according to a third reference pointer in an embodiment of the present application.

[0063] Figure 8 Schematically shows an example diagram of specific category data stored in object data in an embodiment of the present application.

[0064] Figure 9 Schematically shows a flowchart of steps after looking up a third reference table according to an object identifier in an embodiment of the present application.

[0065] Figure 10 Schematically shows a flowchart of steps for reading object data corresponding to an object identifier by querying a local database in an embodiment of the present application.

[0066] Figure 11 Schematically shows a flowchart of steps that may further be included in an embodiment of the present application.

[0067] Figure 12 Schematically shows a structural block diagram of a cache management device provided by an embodiment of the present application.

[0068] Figure 13 Schematically shows a structural block diagram of a computer system of an electronic device for implementing an embodiment of the present application. Detailed implementation manners

[0069] Now, example embodiments will be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more complete and comprehensive, and will fully convey the concept of the example embodiments to those skilled in the art.

[0070] In addition, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of the present application. However, those skilled in the art will realize that the technical solutions of the present application can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the present application.

[0071] The block diagrams shown in the drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0072] The flowcharts shown in the drawings are only exemplary descriptions, and do not necessarily include all the contents and operations / steps, nor are they necessarily executed in the described order. For example, some operations / steps can be decomposed, while some operations / steps can be combined or partially combined. Therefore, the actual execution order may change according to the actual situation.

[0073] Before elaborating on the technical solutions such as the cache management method and cache management device provided in the embodiments of the present application, a brief introduction to the cloud technology and database technology involved in some embodiments of the present application will be given first.

[0074] Cloud storage is a new concept extended and developed from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as the storage system) refers to a storage system that combines a large number of different types of storage devices (storage devices are also called storage nodes) in the network through cluster applications, grid technology, and distributed storage file systems, etc., and collaborates through application software or application interfaces to jointly provide data storage and service access functions to the outside world.

[0075] Currently, the storage method of the storage system is as follows: create a logical volume. When creating a logical volume, physical storage space is allocated for each logical volume, and this physical storage space may be composed of the disks of a certain storage device or several storage devices. The client stores data on a certain logical volume, that is, stores the data on the file system. The file system divides the data into many parts, and each part is an object. The object not only contains data but also contains additional information such as a data identifier (ID, ID entity), etc. The file system writes each object into the physical storage space of the logical volume respectively, and the file system will record the storage location information of each object. Thus, when the client requests to access data, the file system can enable the client to access the data according to the storage location information of each object.

[0076] The process of a storage system allocating physical storage space to a logical volume is specifically as follows: According to the capacity estimation of the objects stored in the logical volume (this estimation often has a large margin relative to the actual capacity of the objects to be stored) and the group of a redundant array of independent disks (RAID), the physical storage space is pre-divided into stripes, and a logical volume can be understood as a stripe, thereby allocating physical storage space to the logical volume.

[0077] A database, in short, can be regarded as an electronic filing cabinet - a place for storing electronic files. Users can perform operations such as adding, querying, updating, and deleting data in the files. The so-called "database" is a data set stored together in a certain way, shared by multiple users, with as little redundancy as possible, and independent of application programs.

[0078] A database management system (DBMS for short) is a computer software system designed to manage a database and generally has basic functions such as storage, interception, security protection, and backup. The database management system can be classified according to the database model it supports, such as relational, XML (Extensible Markup Language); or according to the type of computer it supports, such as server clusters, mobile phones; or according to the query language it uses, such as SQL (Structured Query Language), XQuery; or according to the performance impulse focus, such as maximum scale, highest running speed; or other classification methods. Regardless of the classification method used, some DBMSs can cross categories. For example, they can support multiple query languages at the same time.

[0079] The system involved in the embodiments of the present application can be a distributed system formed by connecting a client and multiple nodes (any form of computing device accessing the network, such as a server, a terminal device) through network communication.

[0080] The following makes a detailed description of the cache management method, cache management method, and corresponding device provided by the present application in combination with specific implementation manners.

[0081] Figure 1 Schematically shows an exemplary device architecture block diagram applying the technical solution of the present application.

[0082] As Figure 1As shown, the device architecture 100 may include a terminal device 110, a network 120, and a server 130. The terminal device 110 may include various electronic devices such as a smartphone, a tablet computer, a laptop computer, and a desktop computer. The server 130 may be an independent physical server, a server cluster or a distributed device composed of multiple physical servers, or a cloud server providing cloud computing services. The network 120 may be a communication medium of various connection types capable of providing a communication link between the terminal device 110 and the server 130. For example, it may be a wired communication link or a wireless communication link.

[0083] According to the implementation requirements, the device architecture in the embodiments of the present application may have any number of terminal devices, networks, and servers. For example, the server 130 may be a server group composed of multiple server devices. In addition, the technical solutions provided in the embodiments of the present application may be applied to the terminal device 110, may also be applied to the server 130, or may be jointly implemented by the terminal device 110 and the server 130. The present application does not make special limitations on this.

[0084] For example, the server 130 may execute the cache management method provided in the present application. If the object data stored in the cache area is called, a first reference pointer for pointing to the object data is created according to the object data; and the first reference pointer is stored in the first reference table, and a first value is added to the preset parameter of the object data; then the first reference pointer is released according to the number and the storage sequence of the first reference pointers in the first reference table, and the preset parameter of the object data of the released first reference pointer is subtracted by the first value; when the preset parameter of the object data is less than or equal to the first preset threshold, the object data is released from the cache area; thus, the release management of the object data in the cache area is realized through the preset parameter of the object data, and the release management of the first reference pointer is realized through the first reference table, which can keep the newly called object data or the object data called multiple times recently from being released, and the object data that has not been called for a long time is released with a high probability. While ensuring the application running performance, the cache occupancy of the application is reduced, the optimization of cache management is realized, the hit efficiency of the cache area is improved, and thus the reading efficiency of the object data is improved.

[0085] It can be understood that enterprise-oriented communication and collaboration applications are all centered around the organizational structure. Currently, large companies and organizational groups have even reached a member scale of hundreds of thousands or even millions. Limited by the available memory capacity of the client device, especially low-end mobile devices, when facing such a super-large organizational structure, if it is difficult to manage the complete organizational structure data locally on the device, the real-time processing of the organizational structure information pull can be realized by adopting the method of storing the large-scale organizational structure in the cloud.

[0086] In the above cloud storage solution, although the client does not need to download and store the complete organizational structure, and the data can always be kept up-to-date. However, there are also corresponding disadvantages: every call to the read operation has to wait for network interaction, the user experience is poor, and it cannot be used offline in a network-free environment, the response time of the application is long, and the running performance is poor.

[0087] In some embodiments of the present application, through the preset parameters of the object data, the release management of the object data in the cache area is realized, and through the first reference table, the release management of the first reference pointer is realized, which can make the newly called object data or the object data called multiple times recently not be released, and the object data that has not been called for a long time is released with a high probability. Combined with the cloud storage solution, it can improve the response speed of the application, reduce the cache occupancy of the application while ensuring the running performance of the application, thereby greatly reducing the memory occupancy of the application on the client device, and the application can also run well on low-end devices. And in a low-network or network-free environment, it is also possible to implement relevant business activities such as reading and displaying some recently called or frequently called object data, which can improve the user experience.

[0088] The following will make a detailed description of the cache management method provided by the present application in combination with specific embodiments.

[0089] Figure 2 The step flowchart of the cache management method of some embodiments of the present application is schematically shown. The execution subject of this cache management method can be a terminal device or a server, etc., and the present application does not limit this. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The embodiments of the present invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, intelligent transportation, assisted driving, etc.

[0090] It can be understood that in the specific embodiments of the present application, when using relevant data of users, when the above embodiments of the present application are applied to specific products or technologies, relevant user permissions or consents need to be obtained, and the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards of relevant countries and regions.

[0091] As Figure 2 shown, this cache management method mainly can include the following steps S210 to S240.

[0092] S210. If the object data stored in the cache area is called, then create a first reference pointer for pointing to the object data according to the object data, and the object data includes preset parameters set to preset values.

[0093] In some embodiments, the first reference pointer may be a strong reference pointer in a smart pointer. Smart pointers include strong reference pointers and weak reference pointers. When a strong reference pointer points to a certain object data, the object data is prohibited from being released from the cache space. When a weak reference pointer points to a certain object data, the object data may be released from the cache space or may continue to be retained in the cache space.

[0094] In some embodiments, the first reference pointer may be an ordinary pointer, and the sum of the preset parameter of the object data and the first numerical value is greater than the first preset threshold.

[0095] The preset numerical value may be 0, 1, 2, 5, 10, 128, or 256, etc. The preset numerical value may also be negative values such as -1, -2, -5, -10, -128, or -256. The present application does not impose special restrictions on the specific value of the preset numerical value.

[0096] The preset parameter may be stored in the object data or may be stored in a preset area independent of the object data in the cache area. The present application does not impose special restrictions on this.

[0097] The object data may be the data of an object instance User associated with a certain object identifier. Alternatively, the object data may be the object data that can be read and stored in the cache area.

[0098] Figure 3 Schematically shows the overall architecture diagram of the system applicable to an embodiment of the present application. Please refer to Figure 3 The overall architecture of the system includes a user interface, a logic layer, an object cache manager, and a data synchronization module. Among them, the object cache manager is used to execute the cache management method of an embodiment of the present application. Both the user interface and the logic layer can call the object data to complete corresponding business operations. The object cache manager can also send query requests, synchronization requests, etc. to the local database or the cloud database to obtain the latest object data from the local database or the cloud database.

[0099] In a specific example, the object cache manager is used to manage the life cycle of the object data stored in the cache area. The interface layer can be used to externally provide a unified asynchronous interface of GetUserByID. This interface can receive the object identifier for obtaining the object data and asynchronously return the object data according to the object identifier. The object cache manager can communicate with the object data in the database managed by the data synchronization module to obtain the object data stored in the source database.

[0100] In some embodiments, the data synchronization module can communicate with the cloud server to execute a data synchronization protocol between the local database and the cloud database. The data synchronization protocol can be to upload the version number obtained when the object data in the local database was last updated to the cloud server, and download the change data between the current version and the latest version from the cloud server, store the change data in the client local database, or update the object data in the local database through the change data. Thus, the original data can be accessed from the database through the data synchronization module, so that a database access interface can be provided for the object cache manager, enabling the object cache manager to access the original object data.

[0101] Figure 4 Schematically shows an example diagram of an application scenario where object data is required in an embodiment of the present application. Please refer to Figure 4 , when business activities such as starting messages, sessions, architectures (i.e., organizational structures), calendars, mailboxes, meetings, documents, and network disks are required in the logic layer or user interface of an application, it may be necessary to call object data associated with the business in the cache.

[0102] Figure 5 Schematically shows a flowchart of steps that may further be included in an embodiment of the present application. As Figure 5 shown, based on the above embodiments, the method of an embodiment of the present application may further include the following steps S510 and S520.

[0103] S510. If the object data stored in the cache area is called, a second reference pointer for pointing to the object data is created according to the object data, the object data is sent to the caller through the second reference pointer, and a second value is added to the preset parameter of the object data;

[0104] S520. If the caller ends the call of the object data, the second reference pointer is released, and the second value is subtracted from the preset parameter of the object data.

[0105] In some embodiments, the second reference pointer may be a normal pointer, and the sum of the preset parameter of the object data and the second value is greater than the first preset threshold.

[0106] In some embodiments, the second reference pointer may be a strong reference pointer in a smart pointer.

[0107] Thus, when the object data is called and the call has not ended, the second reference pointer can be kept from being released, and at the same time, the object data pointed to by the second reference pointer continues to be stored in the cache for the business activities of the application to read at any time. It can be understood that the reading efficiency of the cache is relatively high, so that the normal and efficient operation of the application can be guaranteed.

[0108] Based on the above embodiments, in some embodiments, before step S310, the following steps may further be included:

[0109] Create third reference pointers respectively corresponding to each object data in the cache area, and store each third reference pointer in a third reference table. The third reference pointer is used to point to the object data in the cache area corresponding to the third reference pointer.

[0110] Figure 6 Schematically shows a flowchart of steps for creating a second reference pointer for pointing to object data according to object data in an embodiment of the present application. As Figure 6 shown, based on the above embodiments, step S410 of creating a second reference pointer for pointing to object data according to object data may further include the following steps S610 to S630.

[0111] S610. Obtain the object identifier of the object data to be called;

[0112] S620. Search the third reference table according to the object identifier to obtain the third reference pointer corresponding to the object identifier;

[0113] S630. Read the object data corresponding to the object identifier according to the third reference pointer, and create a second reference pointer for pointing to the read object data.

[0114] Specifically, the third reference pointer may be a smart pointer or an ordinary pointer. In a specific embodiment, the third reference pointer may be a weak reference pointer.

[0115] The third reference table may be established in the form of a Map object, which is convenient for recording and searching the third reference pointer. The third reference table may establish a mapping relationship between each third reference pointer and the object identifier of the object data pointed to by the third reference pointer, so that the corresponding third reference pointer can be quickly found in the third reference table through the object identifier. And, since the third reference table stores the third reference pointers respectively corresponding to each object data in the cache area, the object data stored in the cache area can be quickly found through the third reference table, which can improve the application running efficiency.

[0116] Figure 7 Schematically shows a flowchart of steps after reading the object data corresponding to the object identifier according to the third reference pointer in an embodiment of the present application. As Figure 7 shown, based on the above embodiments, the object data further includes an integrity parameter, and the integrity parameter is used to indicate the integrity degree of the object data; after step S630 of reading the object data corresponding to the object identifier according to the third reference pointer, the following steps S710 to S740 may further be included.

[0117] S710. Obtain the first integrity parameter of the object data to be called;

[0118] S720. Obtain the second integrity parameter of the object data read by the third reference pointer, and compare the first integrity parameter with the second integrity parameter;

[0119] S730. When the degree of completeness of the object data indicated by the second integrity parameter does not cover the degree of completeness of the object data indicated by the first integrity parameter, determine the missing parameter according to the first integrity parameter and the second integrity parameter, and the missing parameter is used to indicate the other data in the object data indicated by the first integrity parameter except the object data indicated by the second integrity parameter;

[0120] S740. Query the local database or the cloud database, read the incremental data corresponding to the object identifier and the missing parameter, and update the object data read by the third reference pointer according to the incremental data.

[0121] Thus, it is possible to, through the degree of completeness of the object data indicated by the integrity parameter, when the degree of completeness of the read object data is insufficient, simply query and read the incremental data corresponding to the missing parameter from the local database or the cloud database to update the original object data, thereby optimizing the reading process of the object data, avoiding duplicate reading of the same data, improving the data reading efficiency, and enhancing the running performance of the application.

[0122] Figure 8 Schematically shows an example diagram of the specific category data stored in the object data of an embodiment of the present application. Please refer to Figure 8 , the object data may store an object identifier, an integrity parameter, compressed data, and uncompressed data. Among them, the uncompressed data may include the basic information of the object, the detailed information of the object, the extended information of the object, etc. The basic information may be, for example, the avatar, nickname, etc. of an object in the organizational structure; the detailed information may be, for example, the contact information, job title, etc. of an object in the organizational structure; the extended information may be, for example, the superior information, attendance status of an object in the organizational structure. Among them, the attendance status may include normal arrival at work, working from home, on a business trip, on vacation, etc. The compressed data may be formed by compressing and converting some of the data in the uncompressed data.

[0123] Thus, a large number of data information included in the object data can be divided into different categories, and an integrity parameter of the object data can be generated according to the presence or absence of data in each field. Therefore, when an application calls the object data, it is not necessary to call the entire object data, but to call a part of the object data by setting the integrity parameter, which is conducive to realizing the lazy loading of the object data, optimizing the calling method of the object data, avoiding the calling of unnecessary data, improving the data reading efficiency, and improving the running performance of the application.

[0124] For example, please combine Figure 3 , when the user interface or logic layer of the application calls the object data through the GetUserByID interface, an integrity parameter loaded representing the data category to be called can be carried in the call request. Then, the object cache manager can perform a bitwise AND operation on the integrity parameter loaded and the object data read from the cache area to check whether the integrity of the object data read from the cache area meets the requirements of the caller. If it meets the requirements, the object data can be directly returned to the caller; if it does not meet the requirements, the missing data needs to be obtained from the local database or the cloud database, and the object data read from the cache area is updated according to the obtained incremental data, and the updated object data return value is called by the caller.

[0125] Figure 9 Schematically shows the step flow chart after finding the third reference table according to the object identifier in an embodiment of the present application. As Figure 9 shown, on the basis of the above embodiment, after finding the third reference table according to the object identifier in step S620, the following steps S910 and S920 can be further included.

[0126] S910. If there is no third reference pointer corresponding to the object identifier in the third reference table, read the object data corresponding to the object identifier by querying the local database, and create a second reference pointer pointing to the read object data;

[0127] S920. If there is no object data corresponding to the object identifier in the local database, read the object data corresponding to the object identifier by querying the cloud database, and create a second reference pointer pointing to the read object data.

[0128] Therefore, since there is no third reference pointer corresponding to the object identifier in the third reference table, it indicates that the object data corresponding to the object identifier is not stored in the cache area. At this time, by querying the local database to read the object data corresponding to the object identifier and creating a second reference pointer pointing to the read object data, the object data corresponding to the object identifier can be successfully returned to the caller, and the object data corresponding to the object data can be stored in the cache area to save the call time for the next call.

[0129] Similarly, if the object data corresponding to the object identifier does not exist in the local database, then by querying the cloud database to read the object data corresponding to the object identifier and creating a second reference pointer pointing to the read object data, the object data corresponding to the object identifier can be successfully returned to the caller, and the latest object data corresponding to the object data can be stored in the cache area to save the call time for the next call.

[0130] It can be understood that when the object data corresponding to the object identifier does not exist in the local database, instead of waiting for the data synchronization protocol between the local database and the cloud database to execute and update the local database, the object data corresponding to the object identifier can be directly queried and read in the cloud database by directly sending a single-point query to the cloud database, which can improve the system response efficiency and thus improve the application running performance.

[0131] In some embodiments, if the object data corresponding to the object identifier is not found in the third reference table, the present application does not search for the object data in the first reference table, but directly reads the object data corresponding to the object identifier from the local database. It can be understood that when the first reference pointer is a strong reference pointer in the smart pointer, or when the sum of the preset parameters of the object data and the first value is greater than the first preset threshold, the object data pointed to by the pointer in the first reference table must be stored in the cache area. Therefore, there must be a corresponding third reference pointer recorded in the third reference table for the object data pointed to by the pointer in the first reference table. Thus, the step of searching for the corresponding third reference pointer according to the object identifier in the third reference table can be skipped, and the query and read efficiency of the object data can be improved.

[0132] Based on the above embodiments, in some embodiments, the step of reading the object data corresponding to the object identifier by querying the local database in step S910 may include the following steps:

[0133] Aggregate multiple requests for querying object data from the local database within a program loop into one request and send it to the local database to query and read the object data corresponding to the object identifier in each request.

[0134] Based on the above embodiments, in some embodiments, the step of reading the object data corresponding to the object identifier by querying the cloud database in step S920 may include the following steps:

[0135] Aggregate multiple requests for querying object data from the cloud database within a program loop into one request, and then send it to the cloud database to query and read the object data corresponding to the object identifiers in each request.

[0136] Thus, multiple local database requests within a program loop can be aggregated into a single batch local database request; multiple cloud database requests within a program loop, or a single batch of cloud database requests; thereby reducing the number of data transmissions, reducing the number of IO operations, reducing the system consumption of the application, and improving the running performance of the application.

[0137] Figure 10 Schematically shows the step flowchart of reading the object data corresponding to the object identifier by querying the local database in an embodiment of the present application. As Figure 10 shown, based on the above embodiments, the step of reading the object data corresponding to the object identifier by querying the local database in step S910 may further include the following steps S1010 to S1050.

[0138] S1010. Send the first query request to the local database, and record the first object identifier included in the first query request in the waiting list;

[0139] S1020. Receive the object data corresponding to the first object identifier returned by the local database, and delete the first object identifier from the waiting list;

[0140] S1030. Before sending the second query request including the second object identifier to the local database, compare the second object identifier with the object identifiers in the waiting list;

[0141] S1040. When the second object identifier is the same as the target object identifier in the waiting list, stop sending the second query request, and wait for the object data corresponding to the target object identifier returned by the local database, and then use the object data corresponding to the target object identifier as the query result for the second query request;

[0142] S1050. When the second object identifier is not the same as any object identifier in the waiting list, continue to send the second query request to the local database, and receive the object data corresponding to the second object identifier returned by the local database.

[0143] Thus, before the query result of a database query request based on an object identifier is returned to the cache area, a data call request initiated again by the caller for the object identifier will not generate a corresponding database request again. Instead, after waiting for the query result of the previous database query request, the query result is returned to the caller. The query result can be a flag bit indicating successful query and the object data read; the query result can also be a flag bit indicating failed query and the reason for the failed query. Thus, it is possible to avoid database crashes caused by high-concurrency queries on the database and improve the stability of application operation.

[0144] S220. Store the first reference pointer in the first reference table and increase the preset parameter of the object data by the first value.

[0145] The third reference table can be established in the form of an LRUCache (Least Recently Used Cache) object, or it can also be established in the form of other objects. This application does not make special restrictions on this.

[0146] Thus, storing the first reference pointer in the first reference table and increasing the preset parameter of the object data by the first value can make the first reference pointer be stored in the first reference table and have a newer storage order in terms of time, thereby realizing the update of the priority of the object data pointed to by the first reference pointer in the cache, so that the object data can be preferentially retained in the cache area and avoid being cleared.

[0147] Thus, it is beneficial to ensure that object data called recently is more likely to be kept in the cache area without being released. It can be understood that object data called recently is more likely to be called again, thereby improving the hit rate of the cache area. Since the reading speed of the cache area is fast and the cumbersome database query can be avoided, the operation efficiency of the application can be improved.

[0148] S230. When the number of first reference pointers in the first reference table is greater than the preset number threshold, release the first reference pointers in the first reference table according to the storage sequence of the first reference pointers in the first reference table, and subtract the first value from the preset parameter of the object data pointed to by the released first reference pointers.

[0149] It can be understood that when the number of first reference pointers in the first reference table is greater than a preset number threshold, it indicates that there is a relatively large amount of called object data stored in the cache area. At this time, according to the storage order of the first reference pointers in the first reference table, release the first reference pointers in the first reference table, and subtract the first value from the preset parameters of the object data pointed to by the released first reference pointers, which can clear the object data with an older call time and not recently called again from the cache area, and keep the object data with a newer call time or frequently called multiple times in history in the cache area. It can be understood that the probability of the object data with an older call time and not recently called again being called in the future is relatively low, while the probability of the object data with a newer call time or frequently called multiple times in history being called in the future is relatively high. Therefore, the above steps of the solution can store the object data most likely to be called in the cache area, improve the hit rate of the cache area, and thus improve the running efficiency of the application.

[0150] S240. When the preset parameter of the object data is less than or equal to the first preset threshold, release the object data from the cache area.

[0151] When the preset parameter of the object data is less than or equal to the first preset threshold, it indicates that the object data can be speculated not to be recorded in the first reference table and is not in a called state, and the possibility of being called again is relatively low. At this time, releasing the object data from the cache area can reduce the used space of the cache space, and can reduce the system memory occupied by the application while ensuring the running performance of the application, and improve the efficiency of cache management.

[0152] In some embodiments, based on the above embodiments, after releasing the object data from the cache area in step S240, the following steps may further be included:

[0153] Release the third reference pointer corresponding to the object data that has been released from the cache area from the third reference table.

[0154] Thus, releasing the third reference pointer corresponding to the object data that has been released from the cache area from the third reference table can reduce the memory occupied space of the third reference table and also avoid being unable to find the object data corresponding to the object identifier in the cache area through the third reference table, and can improve the running performance of the application.

[0155] It can be understood that since the third reference table is added and pointed to by the third reference pointer, the preset parameters of the object data will not be increased. Therefore, when the object data is neither pointed to by the second reference pointer and is not in the called state, nor pointed to by the first reference pointer and does not belong to the object data that is relatively new in terms of call time or has been frequently called multiple times in history, it is very likely that when there is a large amount of cached data, the cache will clear the object data. At this time, the third reference pointer corresponding to the object data that has been released from the cache area will also be released from the third reference table.

[0156] Figure 11 The step flow chart of the steps that can also be included in an embodiment of the present application is schematically shown. As Figure 11 shown, based on the above embodiments, the method of an embodiment of the present application may further include the following steps S1110 to S1130.

[0157] S1110. When it is necessary to clear the cache area, obtain the object data stored in the cache area;

[0158] S1120. When the preset parameter of the object data is greater than the second preset threshold, perform compression processing on the data of the preset category in the object data, and the second preset threshold is greater than the first preset threshold;

[0159] S1130. When the preset parameter of the object data is greater than the first preset threshold and less than or equal to the second preset threshold, release the data of the preset category in the object data from the cache area, and update the integrity parameter of the object data according to the data of the preset category.

[0160] Specifically, the data of the preset category may be the category data that is frequently called in the object data. Specifically, the category data that is frequently called in the object data can be determined according to the integrity parameters carried in each call request in the historical calls to determine the preset category.

[0161] Thus, it is possible to further reduce the occupancy of the cache space through the solution steps of performing compression processing on the data of the preset category in the object data, thereby reducing the system memory occupied by the application and further optimizing the efficient management of the cache.

[0162] In some embodiments, when the application switches to the background or the operating system receives a memory warning, the cache occupancy of the object data can be optimized according to the method steps shown in the above steps S1110 to S1130.

[0163] In some embodiments, the second value may be greater than the first value, the sum of the preset value and the first value may be greater than the first preset threshold and less than or equal to the second preset threshold, and the sum of the preset value and the second value may be greater than the second preset threshold. Thus, it is possible to compress and store the data of the preset category of the object data that is in the called state in the compressed data of the object data, and delete the data of the preset category that was originally stored in the uncompressed data. Moreover, it is possible to release other object data in the cache area except for the object data that is in the called state from the cache area. Therefore, when the application switches to the background or when the operating system receives a memory warning or other situations that require cleaning the cache area, it is possible to safely release the recently called object data in the cache area, avoiding the object data in the called state from being cleared and triggering a database query operation, which may affect the application performance or even cause the application to malfunction.

[0164] In some embodiments, the method of an embodiment of the present application may further include the following steps: when it is necessary to clean the cache area, obtain the object data stored in the cache area; when the preset parameter of the object data is greater than the first preset threshold and less than or equal to the second preset threshold, perform compression processing on the data of the preset category in the object data, where the second preset threshold is greater than the first preset threshold. When the preset parameter of the object data is greater than the second preset threshold, do not perform any processing on the object data. Thus, it is possible to compress the recently called object data in the cache area, retain the object data in the called state, and thereby improve the application running efficiency.

[0165] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that these steps must be executed in that specific order, or that all the steps shown must be executed to achieve the desired result. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc.

[0166] The following introduces the apparatus embodiments of the present application, which can be used to execute the cache management method in the above embodiments of the present application. Figure 12 Schematically shows a structural block diagram of a cache management apparatus provided by an embodiment of the present application. As Figure 12 shown, the cache management apparatus 1200 includes:

[0167] A first reference pointer creation module 1210, configured to create a first reference pointer for pointing to the object data according to the object data if the object data stored in the cache area is called, where the object data includes a preset parameter set to a preset value;

[0168] The first reference pointer storage module 1220 is configured to store the first reference pointer in the first reference table and increase a preset parameter of the object data by a first value;

[0169] The first reference pointer release module 1230 is configured to, when the number of first reference pointers in the first reference table is greater than a preset number threshold, release the first reference pointers in the first reference table according to the storage sequence of the first reference pointers in the first reference table, and subtract the first value from the preset parameter of the object data pointed to by the released first reference pointers;

[0170] The object data release module 1240 is configured to release the object data from the cache area when the preset parameter of the object data is less than or equal to a first preset threshold.

[0171] In some embodiments of the present application, based on the above technical solutions, the cache management device further includes:

[0172] The second reference pointer creation unit is configured to, if the object data stored in the cache area is called, create a second reference pointer for pointing to the object data according to the object data, send the object data to the caller through the second reference pointer, and increase the preset parameter of the object data by a second value;

[0173] The second reference pointer release unit is configured to release the second reference pointer if the caller ends the call of the object data, and subtract the second value from the preset parameter of the object data.

[0174] In some embodiments of the present application, based on the above technical solutions, the cache management device further includes:

[0175] The third reference pointer creation unit is configured to create third reference pointers corresponding to each object data in the cache area, and store each third reference pointer in a third reference table, where the third reference pointer is used to point to the object data in the cache area corresponding to the third reference pointer;

[0176] The second reference pointer creation unit includes:

[0177] The object identifier acquisition subunit is configured to acquire the object identifier of the object data to be called;

[0178] The third reference pointer search unit is configured to search the third reference table according to the object identifier to obtain the third reference pointer corresponding to the object identifier;

[0179] The object data reading unit is configured to read the object data corresponding to the object identifier according to the third reference pointer, and create a second reference pointer for pointing to the read object data.

[0180] In some embodiments of the present application, based on the above technical solutions, the cache management device further includes:

[0181] A first integrity parameter acquisition unit, configured to acquire a first integrity parameter of object data to be called;

[0182] An integrity parameter comparison unit, configured to acquire a second integrity parameter of the object data read by the third reference pointer, and compare the first integrity parameter with the second integrity parameter;

[0183] A missing parameter determination unit, configured to determine a missing parameter according to the first integrity parameter and the second integrity parameter when the integrity degree of the object data indicated by the second integrity parameter does not cover the integrity degree of the object data indicated by the first integrity parameter, where the missing parameter is used to indicate other data in the object data indicated by the first integrity parameter except the object data indicated by the second integrity parameter;

[0184] An object data update unit, configured to query the local database or the cloud database, read incremental data corresponding to the object identifier and the missing parameter, and update the object data read by the third reference pointer according to the incremental data.

[0185] In some embodiments of the present application, based on the above technical solutions, the cache management device further includes:

[0186] A third reference pointer release unit, configured to release the third reference pointer corresponding to the object data that has been released from the cache area from the third reference table.

[0187] In some embodiments of the present application, based on the above technical solutions, the cache management device further includes:

[0188] A local database query unit, configured to, if the third reference pointer corresponding to the object identifier does not exist in the third reference table, read the object data corresponding to the object identifier by querying the local database, and create a second reference pointer for pointing to the read object data;

[0189] A cloud database query unit, configured to, if the object data corresponding to the object identifier does not exist in the local database, read the object data corresponding to the object identifier by querying the cloud database, and create a second reference pointer for pointing to the read object data.

[0190] In some embodiments of the present application, based on the above technical solutions, the local database query unit includes:

[0191] The first object data query unit is configured to aggregate multiple requests for querying object data from the local database within a program loop into one request and send it to the local database, and query and read the object data corresponding to the object identifiers in each request;

[0192] The cloud database query unit includes:

[0193] The second object data query unit is configured to aggregate multiple requests for querying object data from the cloud database within a program loop into one request and send it to the cloud database, and query and read the object data corresponding to the object identifiers in each request.

[0194] In some embodiments of the present application, based on the above technical solution, the local database query unit includes:

[0195] The first object identifier recording unit is configured to send the first query request to the local database and record the first object identifier included in the first query request in the waiting list;

[0196] The first object identifier deletion unit is configured to receive the object data corresponding to the first object identifier returned by the local database and delete the first object identifier from the waiting list;

[0197] The object identifier comparison unit is configured to compare the second object identifier with the object identifiers in the waiting list before sending the second query request including the second object identifier to the local database;

[0198] The second query request stop sending unit is configured to stop sending the second query request when the second object identifier is the same as the target object identifier in the waiting list, and wait for the object data corresponding to the target object identifier returned by the local database, and use the object data corresponding to the target object identifier as the query result for the second query request;

[0199] The second query request continue sending unit is configured to continue sending the second query request to the local database and receive the object data corresponding to the second object identifier returned by the local database when the second object identifier is not the same as any object identifier in the waiting list.

[0200] In some embodiments of the present application, based on the above technical solution, the cache management device further includes:

[0201] The object data acquisition unit is configured to acquire the object data stored in the cache area when the cache area needs to be cleared;

[0202] A compression processing unit, configured to perform compression processing on data of a preset category in object data when a preset parameter of the object data is greater than a second preset threshold, where the second preset threshold is greater than a first preset threshold;

[0203] A data release unit, configured to release data of a preset category in object data from a cache area and update an integrity parameter of the object data according to the data of the preset category when the preset parameter of the object data is greater than the first preset threshold and less than or equal to the second preset threshold.

[0204] The specific details of the cache management device provided in each embodiment of the present application have been described in detail in the corresponding related method embodiments, and will not be elaborated here.

[0205] Figure 13 Schematically shows a block diagram of a computer system of an electronic device for implementing the embodiments of the present application.

[0206] It should be noted that Figure 13 The computer system 1300 of the shown electronic device is only an example, and should not bring any limitations to the functions and usage scopes of the embodiments of the present application.

[0207] As Figure 13 shown, the computer system 1300 includes a central processing unit 1301 (Central Processing Unit, CPU), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1302 (Read-Only Memory, ROM) or a program loaded from a storage section 1308 into a random access memory 1303 (Random Access Memory, RAM). In the random access memory 1303, various programs and data required for system operations are also stored. The central processing unit 1301, the read-only memory 1302, and the random access memory 1303 are connected to each other through a bus 1304. An input / output interface 1305 (Input / Output interface, i.e., I / O interface) is also connected to the bus 1304.

[0208] The following components are connected to the input / output interface 1305: an input section 1306 including a keyboard, a mouse, etc.; an output section 1307 including such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 1308 including a hard disk, etc.; and a communication section 1309 including a network interface card such as a local area network card, a modem, etc. The communication section 1309 performs communication processing via a network such as the Internet. The drive 1310 is also connected to the input / output interface 1305 as needed. A removable medium 1311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1310 as needed so that a computer program read therefrom is installed into the storage section 1308 as needed.

[0209] Specifically, according to an embodiment of the present application, the processes described in each method flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1309, and / or installed from the removable medium 1311. When the computer program is executed by the central processing unit 1301, various functions defined in the system of the present application are executed.

[0210] It should be noted that the computer-readable medium shown in the embodiments of the present application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0211] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0212] It should be noted that although several modules or units of a device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of the two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0213] Through the description of the above embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software or by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (such as a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.

[0214] After considering the specification and practicing the invention disclosed herein, those skilled in the art will readily conceive of other embodiments of the present application. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common knowledge or conventional technical means in the technical field not disclosed in the present application.

[0215] It should be understood that the present application is not limited to the exact structures already described and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.

Claims

1. A cache management method, characterized in that, The method includes: Creating third reference pointers respectively corresponding to each object data in the cache area, and storing each of the third reference pointers in a third reference table, where the third reference pointer is used to point to the object data corresponding to the third reference pointer in the cache area; If the object data stored in the cache area is called, a first reference pointer for pointing to the object data is created according to the object data, and the object data includes preset parameters set to preset values; Storing the first reference pointer in a first reference table, and increasing the preset parameter of the object data by a first value; When the number of first reference pointers in the first reference table is greater than a preset number threshold, releasing the first reference pointers in the first reference table according to the storage sequence of the first reference pointers in the first reference table, and subtracting the first value from the preset parameter of the object data pointed to by the released first reference pointers; If the object data stored in the cache area is called, obtain the object identifier of the object data to be called; Search the third reference table according to the object identifier to obtain the third reference pointer corresponding to the object identifier; Read the object data corresponding to the object identifier according to the third reference pointer, create a second reference pointer for pointing to the read object data, send the object data to the calling party through the second reference pointer, and increase the preset parameter of the object data by a second value; If the calling party ends calling the object data, release the second reference pointer, and subtract the second value from the preset parameter of the object data; When the preset parameter of the object data is less than or equal to a first preset threshold, release the object data from the cache area.

2. The method according to claim 1, wherein The object data further includes an integrity parameter, and the integrity parameter is used to indicate the integrity degree of the object data; after reading the object data corresponding to the object identifier according to the third reference pointer, the method includes: Obtaining a first integrity parameter of the object data to be called; Obtaining a second integrity parameter of the object data read by the third reference pointer, and comparing the first integrity parameter with the second integrity parameter; When the integrity degree of the object data indicated by the second integrity parameter does not cover the integrity degree of the object data indicated by the first integrity parameter, determining missing parameters according to the first integrity parameter and the second integrity parameter, where the missing parameters are used to indicate other data in the object data indicated by the first integrity parameter except the object data indicated by the second integrity parameter; Querying a local database or a cloud database, reading incremental data corresponding to the object identifier and the missing parameters, and updating the object data read by the third reference pointer according to the incremental data.

3. The method according to claim 1, wherein After releasing the object data from the cache area, the method further includes: Releasing the third reference pointer corresponding to the object data that has been released from the cache area from the third reference table.

4. The method according to claim 1, wherein After searching the third reference table according to the object identifier, the method further includes: If there is no third reference pointer corresponding to the object identifier in the third reference table, read the object data corresponding to the object identifier by querying the local database, and create a second reference pointer for pointing to the read object data; If there is no object data corresponding to the object identifier in the local database, read the object data corresponding to the object identifier by querying the cloud database, and create a second reference pointer for pointing to the read object data.

5. The method according to claim 4, characterized in that, Reading the object data corresponding to the object identifier by querying the local database includes: Aggregate multiple requests for querying object data from the local database within a program loop into one request, and then send the aggregated request to the local database to query and read the object data corresponding to the object identifiers in each request; Reading the object data corresponding to the object identifier by querying the cloud database includes: Aggregate multiple requests for querying object data from the cloud database within a program loop into one request, and then send the aggregated request to the cloud database to query and read the object data corresponding to the object identifiers in each request.

6. The method according to claim 4, characterized in that Reading the object data corresponding to the object identifier by querying the local database includes: Send a first query request to the local database, and record the first object identifier included in the first query request in a waiting list; Receive the object data corresponding to the first object identifier returned by the local database, and delete the first object identifier from the waiting list; Before sending a second query request including a second object identifier to the local database, compare the second object identifier with the object identifiers in the waiting list; When the second object identifier is the same as the target object identifier in the waiting list, stop sending the second query request, and wait for the local database to return the object data corresponding to the target object identifier, and then use the object data corresponding to the target object identifier as the query result for the second query request; When the second object identifier is not the same as any object identifier in the waiting list, continue to send the second query request to the local database, and receive the object data corresponding to the second object identifier returned by the local database.

7. The method according to any one of claims 1-6, characterized in that The object data includes an integrity parameter, and the integrity parameter is used to indicate the degree of completeness of the object data; the method further includes: When it is necessary to clean the cache area, obtain the object data stored in the cache area; When the preset parameter of the object data is greater than a second preset threshold, perform compression processing on the data of a preset category in the object data, and the second preset threshold is greater than the first preset threshold; When the preset parameter of the object data is greater than the first preset threshold and less than or equal to the second preset threshold, release the data of the preset category in the object data from the cache area, and update the integrity parameter of the object data according to the data of the preset category.

8. A cache management device, characterized in that, The device includes: A first reference pointer creation module, configured to create a first reference pointer for pointing to object data if the object data stored in a cache area is called, where the object data includes a preset parameter set to a preset value; A first reference pointer storage module, configured to store the first reference pointer in a first reference table and increase the preset parameter of the object data by a first value; A first reference pointer release module, configured to, when the number of first reference pointers in the first reference table is greater than a preset number threshold, release the first reference pointers in the first reference table according to the storage order of the first reference pointers in the first reference table, and subtract the first value from the preset parameter of the object data pointed to by the released first reference pointers; An object data release module, configured to release the object data from the cache area when the preset parameter of the object data is less than or equal to a first preset threshold; The cache management device further includes: A second reference pointer creation unit, configured to create a second reference pointer for pointing to the object data if the object data stored in the cache area is called, send the object data to a calling party through the second reference pointer, and increase the preset parameter of the object data by a second value; A second reference pointer release unit, configured to release the second reference pointer if the calling party ends calling the object data, and subtract the second value from the preset parameter of the object data; A third reference pointer creation unit, configured to create third reference pointers respectively corresponding to the respective object data in the cache area, and store each of the third reference pointers in a third reference table, where the third reference pointer is used to point to the object data in the cache area corresponding to the third reference pointer; The second reference pointer creation unit includes: An object identifier acquisition subunit, configured to acquire an object identifier of object data to be called; A third reference pointer search unit, configured to search the third reference table according to the object identifier to obtain a third reference pointer corresponding to the object identifier; An object data reading unit, configured to read the object data corresponding to the object identifier according to the third reference pointer and create a second reference pointer for pointing to the read object data.

9. A computer-readable medium, characterized in that, A computer program is stored thereon, and when the computer program is executed by a processor, the cache management method according to any one of claims 1 to 7 is implemented.

10. An electronic device, characterized in that, Including: A processor; And A memory for storing executable instructions of the processor; Wherein, the processor is configured to execute the cache management method according to any one of claims 1 to 7 by executing the executable instructions.

11. A computer program product, characterized in that, The computer program product includes computer instructions, and when the processor of a computer device executes the computer instructions, the computer device executes the cache management method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for data access

    CN108228649A

  • KR20200092745A