Dynamic caching method and device based on annotation, equipment, storage medium and program product
By establishing an annotated dynamic cache table on the database side and using aspect classes to determine the validity of the cache table, the problems of high memory usage, non-shared cache and data consistency in existing cache methods in complex data processing and multi-instance deployment are solved. , achieving efficient cache management and system performance optimization.
Patent Information
- Application Number
- CN202411543484.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-01-21
AI Technical Summary
When faced with complex data processing and multi-instance deployment, existing caching methods have problems with high memory footprint, no cache sharing, data consistency and response time performance.
Adopt a dynamic cache method based on annotations, by establishing the first cache data table and the second cache data table at the database, and using the preset cutting surface to determine the effectiveness of the cache table, update the cache data table asynchronous Sex and consistency.
Effectively manage cache, reduce memory occupation, ensure the sharing of cache data in all instances, optimize memory use, shorten the time of cache effectiveness, avoid invalid or redundant update operations, and improve system performance and stability.
Smart Images

Figure CN119336763A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, can be applied to the financial field, and more specifically to an annotation-based dynamic caching method, device, equipment, storage medium and program product. Background Art
[0002] With the advent of the big data era, the efficiency of data storage and access has increasingly become an important performance indicator in enterprise information systems. In existing application systems, most functional interaction modules have query functions. As business needs gradually become richer, more and more semi-statistical functional modules are required to implement real-time queries. However, because the risk field involves a large amount of customer data and there may be multiple associations between tables, real-time queries and processing have response time performance issues. When the system concurrency increases, the average system response time will increase due to multiple long-term queries, which will trigger system alarms. In order to increase data access speed and reduce database load, caching technology came into being. Especially in dynamic data processing scenarios, how to efficiently manage caches and ensure the real-time and consistency of cached data has become one of the core challenges of technology development.
[0003] There are many problems in traditional caching methods: the first-level cache is insufficiently configured and lacks automatic adaptation capabilities when faced with different query requirements; the second-level cache is limited to database query results and is powerless for complex data processing or multiple query combinations, and cannot significantly improve overall performance; there is also a lack of cache sharing between multiple instances, which can easily lead to inconsistent cache status of the same data in different instances, thus affecting data accuracy and consistency; when the cache increases dramatically in a short period of time, it may cause memory management problems, resulting in high application memory usage and affecting system stability and performance. Summary of the invention
[0004] In view of the above problems, the present disclosure provides an annotation-based dynamic caching method, apparatus, device, storage medium and program product.
[0005] According to a first aspect of the present disclosure, there is provided an annotation-based dynamic caching method, which is applied to a database side, and includes: using a database to establish a first cache data table and a second cache data table, wherein the first cache data table is a data table containing a first annotation, and the first cache data table is associated with the second cache data table; based on a preset aspect class, the first cache data table is judged to be a valid data table to complete the update of the first cache data table, wherein: when a target field containing a second annotation exists in the first cache data table, the first cache data table is determined to be a valid data table; when the first cache data table does not contain a target field containing the second annotation, the target field is added to the second cache data table through an asynchronous thread to perform an update on the first cache data table.
[0006] According to an embodiment of the present disclosure, the first cache data table includes storage type, storage parameters, storage effective time, storage expiration time and storage ID, wherein; the storage type is used to identify the type of the first cache data table; the storage parameters are parameters corresponding to the storage request; the storage effective time and the storage expiration time are used to control the storage timeliness of each field; the storage ID is used to associate with the second cache data table.
[0007] According to an embodiment of the present disclosure, the first cache data table is associated with the second cache data table, wherein the second cache data table is associated with the first cache data table through a storage ID, and the second cache data table stores a plurality of fields.
[0008] According to an embodiment of the present disclosure, the first cache data table is a data table including a first annotation, and adding the first annotation to the first cache data table includes: recording the type of the first cache data table; recording the data of the second cache data table; recording multiple entity objects in each first cache data table; and setting the storage effectiveness time and the storage expiration time.
[0009] According to an embodiment of the present disclosure, a target field containing a second annotation is obtained by the following method, including: adding a second annotation to a target field to be cached to obtain a target field containing the second annotation, and setting a non-static field within a first range in an entity object to be cached as a target field.
[0010] According to an embodiment of the present disclosure, the target field containing the second annotation can be mapped with the original field in the database.
[0011] According to an embodiment of the present disclosure, when there is a target field containing a second annotation in the first cache data table, determining that the first cache data table is a valid data table also includes: the target field of the second annotation is mapped to an entity object, returns list data or returns paginated data and stores it in the first cache data table.
[0012] The second aspect of the present disclosure provides an annotation-based dynamic cache device, including: a cache data table establishment module, used to use a database to establish a first cache data table and a second cache data table, wherein the first cache data table is a data table containing a first annotation, and the first cache data table is associated with the second cache data table; a cache data table update module, used to complete the update of the first cache data table by judging that the first cache data table is a valid data table based on a preset aspect class, wherein: when there is a target field containing the second annotation in the first cache data table, the first cache data table is determined to be a valid data table; when the first cache data table does not contain a target field containing the second annotation, the target field is added to the second cache data table through an asynchronous thread to perform an update on the first cache data table.
[0013] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.
[0014] The fourth aspect of the present disclosure further provides a computer-readable storage medium on which a computer program or instruction is stored, and when the computer program or instruction is executed by a processor, the steps of the above method are implemented.
[0015] The fifth aspect of the present disclosure also provides a computer program product, including a computer program or instructions, which implement the steps of the above method when the computer program or instructions are executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0017] Figure 1 The application scenario diagram of the annotation-based dynamic caching method according to the embodiment of the present disclosure is schematically shown;
[0018] Figure 2 A flowchart of a dynamic caching method based on annotations according to an embodiment of the present disclosure is schematically shown;
[0019] Figure 3 A flowchart of adding a first annotation to a first cache data table according to an embodiment of the present disclosure is schematically shown;
[0020] Figure 4 A flowchart for updating the first cache data table according to an embodiment of the present disclosure is schematically shown;
[0021] Figure 5 Schematically shows a flow chart of obtaining a target field containing a second annotation according to an embodiment of the present disclosure;
[0022] Figure 6 A structural block diagram of an annotation-based dynamic cache device according to an embodiment of the present disclosure is schematically shown; and
[0023] Figure 7 A block diagram of an electronic device suitable for implementing an annotation-based dynamic caching method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0024] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0025] In the technical solution of the present disclosure, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0026] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0027] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present disclosure provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating a person's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.
[0028] The embodiment of the present disclosure provides an annotation-based dynamic caching method, which is applied to a database side, including: using a database to establish a first cache data table and a second cache data table, wherein the first cache data table is a data table containing a first annotation, and the first cache data table is associated with the second cache data table; based on a preset aspect class, the first cache data table is judged to be a valid data table to complete the update of the first cache data table, wherein: when there is a target field containing a second annotation in the first cache data table, the first cache data table is determined to be a valid data table; when there is no target field containing the second annotation in the first cache data table, the target field is added to the second cache data table through an asynchronous thread to perform an update on the first cache data table.
[0029] Through the embodiments of the present disclosure, the memory occupation problem of instance application-level cache, the slow cache effectiveness and data validity guarantee problem in multi-instance deployment, and the redundant cache problem when querying multiple databases in the processing flow are solved.
[0030] By placing the management of cache data tables on the database side, memory usage is reduced. This approach ensures that cache data is shared across all instances, thereby optimizing memory usage. Based on the second annotation field in the first cache data table, the system can quickly determine whether the table is a valid data table, which can shorten the cache validity period. The cache is updated only when specific conditions are met, avoiding invalid or redundant update operations. By storing ID associations, the association mechanism between the first cache data table and the second cache data table ensures that in multi-instance deployments, each instance can share the same cache information, avoiding data inconsistency caused by multiple instances maintaining different caches. Flexibility is reflected in the ability to customize configurations based on specific business needs, supporting cache strategies in different scenarios, and improving the versatility and adaptability of the system.
[0031] Figure 1 The application scenario diagram of the annotation-based dynamic caching method according to an embodiment of the present disclosure is schematically shown.
[0032] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0033] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0034] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0035] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0036] It should be noted that the annotation-based dynamic caching method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the annotation-based dynamic caching device provided in the embodiment of the present disclosure can generally be set in the server 105. The annotation-based dynamic caching method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the annotation-based dynamic caching device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0037] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0038] The following will be based on Figure 1 The scene described by Figure 2~Figure 5 The annotation-based dynamic caching method of the disclosed embodiment is described in detail.
[0039] Figure 2 The flowchart of the annotation-based dynamic caching method according to an embodiment of the present disclosure is schematically shown.
[0040] like Figure 2 As shown, the annotation-based dynamic caching method may further include operations S210 to S220.
[0041] In operation S210 , a first cache data table and a second cache data table are established using a database, wherein the first cache data table is a data table including a first annotation, and the first cache data table is associated with the second cache data table.
[0042] Specifically, firstly, a data table structure is pre-designed to set the first cache data table and the second cache data table. For example, the first cache data table includes storage type, storage parameters, storage effective time, storage expiration time and storage ID, wherein; the storage type is used to identify the type of the first cache data table; the storage parameters are parameters corresponding to the storage request; the storage effective time and storage expiration time are used to control the storage timeliness of each field; the storage ID is used to associate with the second cache data table. Among them, in the embodiment of the present disclosure, the first cache data table is a data table containing a first annotation, and therefore, the first cache data table also includes storage data annotation information.
[0043] Exemplarily, the second cache data table includes a primary key ID for identifying the type of the second cache data table; it also includes a foreign key ID for associating the first cache data table with the second cache data table, that is, the second cache data table is associated with the first cache data table via a storage ID; multiple fields are stored in the second cache data table, that is, the actual cached data content, for example, 15 fields with a length of 300, that is, a maximum of 15 field information is stored by default.
[0044] Exemplarily, when a user requests data, the first cache data table is queried first. If the corresponding storage data annotation information is found in the first cache data, the second cache data table is queried, the first cache data table is associated with the second cache data table through the foreign key ID, and the fields stored in the second cache data table are obtained. If the relevant data is not found in the first cache data table or the fields in the second cache data table are not found, the original data can be read from the main database and updated to the first cache data table and the second cache data table.
[0045] Through the embodiments of the present disclosure, by using the association between the first cache data table and the second cache data table, data query efficiency and cache hit rate can be effectively improved, while ensuring data consistency and validity. The method is applicable to various application scenarios requiring efficient data access and has broad application prospects.
[0046] Figure 3 The flowchart of adding a first annotation to a first cache data table according to an embodiment of the present disclosure is schematically shown.
[0047] like Figure 3 As shown, in an embodiment of the present disclosure, the first cache data table is a data table including a first annotation, and adding the first annotation to the first cache data table may further include operations S310 to S340.
[0048] In operation S310, the type of the first cache data table is recorded.
[0049] Specifically, for example, a first annotation is added to the first cache data table, and a specific type of the first cache data table (such as a user information table, an order information table, etc.) is determined and recorded, so that subsequent operations can be processed accordingly according to the data table type.
[0050] In operation S320, data of the second cache data table is recorded.
[0051] Specifically, the data of the relevant second cache data table is recorded to ensure that the association between the data and the first cache data table is maintained. For example, if the first cache data table is a user information table, the second cache data table may be a user activity record table.
[0052] In operation S330, a plurality of entity objects in each first cache data table are recorded.
[0053] Exemplarily, all entity objects in the first cache data table are traversed, and their attributes and states are recorded one by one to form detailed metadata for subsequent analysis and use.
[0054] In operation S340, a storage validity time and a storage expiration time are set.
[0055] For example, the last step is to set the storage validity time and expiration time for the first cache data table. The validity time refers to the time when the data starts to be used, and the expiration time refers to the time when the data loses its validity. By setting these two times, the potential risks caused by data expiration can be effectively avoided.
[0056] Through the embodiments of the present disclosure, by systematically annotating the first cache data table, the manageability, traceability and usage efficiency of data can be effectively improved. The first cache data table can not only quickly store and access data, but also has a powerful annotation recording function, which improves the flexibility and security of data management.
[0057] In operation S220, based on the preset aspect class, the first cache data table is determined to be a valid data table to complete the updating of the first cache data table.
[0058] Figure 4 The flowchart of updating the first cache data table according to the embodiment of the present disclosure is schematically shown.
[0059] like Figure 4 As shown, in an embodiment of the present disclosure, based on a preset aspect class, updating the first cache data table by determining that the first cache data table is a valid data table may further include operations S410 to S420.
[0060] In operation S410 , when there is a target field including a second annotation in the first cache data table, it is determined that the first cache data table is a valid data table.
[0061] In an embodiment of the present disclosure, a first cache data table is associated with a second cache data table, the second cache data table is associated with the first cache data table through a storage ID, and a plurality of fields are stored in the second cache data table. Therefore, for example, when the first cache data table is associated with the second cache data table, it contains a plurality of fields, some of which are marked as "@Cacheable", i.e., target fields. When the existence of these marked target fields is detected, the first cache data table will be automatically confirmed to be valid.
[0062] Through the implementation of the present disclosure, the cache logic is inserted in the key link through the preset aspect class. According to the second annotation field in the first cache data table, the system can quickly determine whether the table is a valid data table, which can shorten the cache effectiveness time. The cache will only be updated when specific conditions are met, avoiding invalid or redundant update operations. Reduce the number of actual database queries and improve overall processing efficiency. In this way, even in the case of multiple queries, the cache data can be effectively utilized to reduce latency.
[0063] Figure 5 The flowchart of obtaining a target field containing a second annotation according to an embodiment of the present disclosure is schematically shown.
[0064] like Figure 5 As shown, in the embodiment of the present disclosure, obtaining the target field containing the second annotation may further include operations S510 to S520.
[0065] In operation S510 , a second annotation is added to a target field to be cached to obtain a target field including the second annotation.
[0066] Specifically, a target field to be cached is received, the target field comes from an entity object, a second annotation is added to the target field to facilitate subsequent processing and identification, and a new target field is generated and returned, the field including the second annotation.
[0067] In operation S520 , a non-static field within a first range in the entity object to be cached is set as a target field.
[0068] Specifically, a first range is determined according to a preset condition, and the fields within the range are defined as non-static fields, for example, the first fifteen non-static fields of the default cache entity class. All non-static fields in the entity object to be cached that meet the first range are set as target fields. The target field containing the second annotation is updated to the cache for subsequent data processing and access.
[0069] It should be noted that, in the embodiment of the present disclosure, the target field containing the second annotation can be mapped with the original field in the database. That is, the second annotation contains an attribute, which is the target field name, which is used to map the entity class field with the database field. When the attribute is not filled in, the camel case name of the attribute is converted to an underscore name by default.
[0070] Exemplarily, when there is a target field containing a second annotation in the first cache data table, determining that the first cache data table is a valid data table also includes: mapping the target field of the second annotation to an entity object, returning list data or returning paging data and storing it in the first cache data table. By providing a mapping relationship between the target field and the original field of the database, it helps to seamlessly switch between the cache and the database, and improves data consistency.
[0071] Through the embodiments of the present disclosure, the target fields and their annotations in the cache can be effectively managed, and the flexibility and efficiency of the system in processing complex objects can be improved. At the same time, the system can dynamically adjust the cache strategy to ensure that only fields that meet specific requirements are cached, thereby optimizing performance.
[0072] In operation S420 , when the first cache data table does not have a target field containing the second annotation, the target field is added to the second cache data table through an asynchronous thread to update the first cache data table.
[0073] Specifically, the asynchronous thread can call the data acquisition interface to obtain the data of the target field from the database or other data sources in real time and store it in the second cache data table. In addition, after successfully adding the data to the second cache data table, the asynchronous thread sends an update notification to the first cache data table to ensure data synchronization. The real-time update of the cache data table is achieved through asynchronous threads, which effectively reduces the blocking time of the main thread and improves the response speed of the system. For data with high frequency of access, this method can significantly improve the consistency and availability of data.
[0074] Through the embodiments of the present disclosure, by accurately judging the validity of the cache data table, an efficient data update process is achieved, reducing the waste of system resources. At the same time, through the asynchronous processing mechanism, the system response speed and user experience are improved.
[0075] Based on the above annotation-based dynamic caching method, the present disclosure also provides an annotation-based dynamic caching device. Figure 6 The device is described in detail.
[0076] Figure 6 The structural block diagram of the annotation-based dynamic caching device according to an embodiment of the present disclosure is schematically shown.
[0077] like Figure 6 As shown, the annotation-based dynamic cache device 600 of this embodiment includes a cache data table establishment module 610 and a cache data table update module 620 .
[0078] The cache data table establishment module 610 is used to establish a first cache data table and a second cache data table using a database, wherein the first cache data table is a data table containing a first annotation, and the first cache data table is associated with the second cache data table. In one embodiment, the cache data table establishment module 610 can be used to perform the operation S210 described above, which will not be repeated here.
[0079] The cache data table update module 620 is used to complete the update of the first cache data table by determining that the first cache data table is a valid data table based on the preset aspect class, wherein: when the first cache data table contains a target field containing the second annotation, the first cache data table is determined to be a valid data table; when the first cache data table does not contain a target field containing the second annotation, the target field is added to the second cache data table through an asynchronous thread to update the first cache data table. In one embodiment, the cache data table update module 620 can be used to perform the operation S220 described above, which will not be repeated here.
[0080] According to an embodiment of the present disclosure, any multiple modules in the cache data table establishment module 610 and the cache data table update module 620 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the cache data table establishment module 610 and the cache data table update module 620 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. Alternatively, at least one of the cache data table establishment module 610 and the cache data table update module 620 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.
[0081] Figure 7 A block diagram of an electronic device suitable for implementing an annotation-based dynamic caching method according to an embodiment of the present disclosure is schematically shown.
[0082] like Figure 7 As shown, the electronic device 700 according to an embodiment of the present disclosure includes a processor 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 707 to a random access memory (RAM) 703. The processor 701 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include an onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0083] In RAM 703, various programs and data required for the operation of electronic device 700 are stored. Processor 701, ROM 702 and RAM 703 are connected to each other via bus 704. Processor 701 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 702 and / or RAM 703. It should be noted that the program can also be stored in one or more memories other than ROM 702 and RAM 703. Processor 701 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in one or more memories.
[0084] According to an embodiment of the present disclosure, the electronic device 700 may further include an input / output (I / O) interface 705, which is also connected to the bus 704. The electronic device 700 may further include one or more of the following components connected to the I / O interface 705: an input portion 706 including a keyboard, a mouse, etc.; an output portion 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 707 including a hard disk, etc.; and a communication portion 709 including a network interface card such as a LAN card, a modem, etc. The communication portion 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage portion 707 as needed.
[0085] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0086] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 702 and / or RAM 703 described above and / or one or more memories other than ROM 702 and RAM 703.
[0087] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present disclosure.
[0088] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 701. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0089] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 709, and / or installed from the removable medium 711. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0090] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0091] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0092] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0093] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present disclosure. In particular, without departing from the spirit and teachings of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0094] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A dynamic caching method based on annotations, characterized in that: Applied to the database side, the method includes: Using a database to establish a first cache data table and a second cache data table, wherein the first cache data table is a data table including a first annotation, and the first cache data table is associated with the second cache data table; Based on the preset aspect class, the first cache data table is updated by determining that the first cache data table is a valid data table, wherein: When there is a target field containing a second annotation in the first cache data table, determining that the first cache data table is a valid data table; When the first cache data table does not have a target field containing the second annotation, the target field is added to the second cache data table through an asynchronous thread to update the first cache data table.
2. The annotation-based dynamic caching method according to claim 1, characterized in that: The first cache data table includes storage type, storage parameters, storage effective time, storage expiration time and storage ID, wherein; The storage type is used to identify the type of the first cache data table; The storage parameters are parameters corresponding to the storage request; The storage validity time and storage expiration time are used to control the storage timeliness of each field; The storage ID is used to be associated with the second cache data table.
3. The annotation-based dynamic caching method according to claim 1 or 2, characterized in that: The first cache data table is associated with the second cache data table, wherein; The second cache data table is associated with the first cache data table through one storage ID, and the second cache data table stores a plurality of fields.
4. The annotation-based dynamic caching method according to claim 1 or 2, characterized in that: The first cache data table is a data table including a first annotation, and adding the first annotation to the first cache data table includes: Recording the type of the first cache data table; Recording data in the second cache data table; Recording a plurality of entity objects in each of the first cache data tables; Set the storage validity time and storage expiration time.
5. The annotation-based dynamic caching method according to claim 4, characterized in that: The target field containing the second annotation is obtained by the following method, including: Adding a second annotation to the target field to be cached to obtain a target field containing the second annotation, and Set the non-static field in the first range of the entity object to be cached as the target field.
6. The annotation-based dynamic caching method according to claim 5, characterized in that: The target field containing the second annotation can be mapped with the original field in the database.
7. The annotation-based dynamic caching method according to claim 5, characterized in that: When there is a target field containing a second annotation in the first cache data table, determining that the first cache data table is a valid data table further includes: The target field of the second annotation is mapped to an entity object, returns list data or returns paged data and is stored in the first cache data table.
8. A dynamic caching device based on annotations, characterized in that: The device comprises: A cache data table establishment module, used to establish a first cache data table and a second cache data table using a database, wherein the first cache data table is a data table including a first annotation, and the first cache data table is associated with the second cache data table; A cache data table update module is used to complete the update of the first cache data table by judging that the first cache data table is a valid data table based on a preset aspect class, wherein: When there is a target field containing a second annotation in the first cache data table, determining that the first cache data table is a valid data table; When the first cache data table does not have a target field containing the second annotation, the target field is added to the second cache data table through an asynchronous thread to update the first cache data table.
9. An electronic device, comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.