CN113742617A - Cache updating method and device - Google Patents

Cache updating method and device Download PDF

Info

Publication number
CN113742617A
CN113742617A CN202010885891.9A CN202010885891A CN113742617A CN 113742617 A CN113742617 A CN 113742617A CN 202010885891 A CN202010885891 A CN 202010885891A CN 113742617 A CN113742617 A CN 113742617A
Authority
CN
China
Prior art keywords
data
cache
information
notification message
change information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010885891.9A
Other languages
Chinese (zh)
Inventor
张恒强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202010885891.9A priority Critical patent/CN113742617A/en
Publication of CN113742617A publication Critical patent/CN113742617A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Abstract

The invention discloses a method and a device for updating a cache, and relates to the technical field of computers. One embodiment of the method comprises: receiving a notification message sent by a message queue; determining data change information according to the notification message; the data change information is generated by a data source application and stored in the message queue; and updating the cache data in the target application according to the data change information. According to the implementation method, when the notification message about data change sent by the message queue is monitored, the data change information is determined according to the notification message, and the cache data in the target application is updated by using the data change information, so that the technical problem that the cache cannot be updated or resources are wasted due to the fact that the cache is updated by setting a timing task or setting a cache validity period in the prior art is solved, and the technical effect of updating the cache timely and effectively without wasting resources is achieved.

Description

Cache updating method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for updating a cache.
Background
In the internet system, as the amount of traffic data gradually increases, caching technology is generally used to improve the system performance, wherein the effectiveness of caching and the issue of when to update the caching need to be considered. In the prior art, for the above problems, the following two methods are often used:
(1) actively detecting the effectiveness of the cache at regular time according to the updating frequency, and if the updating is found, pulling the data to cover the cache again;
(2) setting a cache validity period, checking whether the validity period passes when the cache data is used, and if so, pulling the data again to cover the cache.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
with regard to the method (1), since the update of the source data cannot be estimated, it is difficult to determine a suitable update frequency, and if the update frequency is set to be relatively high, the source data may not be changed during the update, which wastes resources; if the update frequency is set relatively low, the cache may be expired when the cache is used, and the cache data is invalid;
for the method (2), because the update of the source data cannot be estimated, a proper validity period is difficult to determine, and if the validity period is set to be relatively short, resources are wasted by frequently pulling the data, and the system performance may be influenced; if the validity period is set to be relatively long, the cache data may be used without the validity period, but with the source data having changed, at which time the cache data is invalid.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for cache update, which are capable of determining data change information according to a notification message sent by a message queue when monitoring the message queue and monitoring the notification message about data change, and updating cache data in a target application by using the data change information, thereby implementing timely and effective cache update.
To achieve the above object, according to an aspect of the embodiments of the present invention, there is provided a method for updating a cache, including:
receiving a notification message sent by a message queue;
determining data change information according to the notification message; the data change information is generated by a data source application and stored in the message queue;
and updating the cache data in the target application according to the data change information.
Optionally, before receiving the notification message in the message queue, the method further includes:
determining configuration information for caching updates in a target application, wherein the configuration information at least comprises: subject information corresponding to the cache;
and the notification message sent by the receiving message queue comprises:
sending a subscription message about the topic information to the message queue based on the configuration information, and receiving the notification message sent by the message queue based on the subscription message, wherein the notification message at least comprises: subject information of the data is changed.
Optionally, the determining the configuration information for caching updates in the target application includes: determining configuration information for caching update in the target application according to an annotation identifier in a program language;
and after determining the configuration information for caching updates in the target application, further comprising:
based on the configuration information, creating a cache corresponding to each topic information in the target application; and creating a monitoring agent in the target application, wherein the monitoring agent is used for receiving the notification message sent by the message queue and updating the cache data in the cache according to the data change information.
Optionally, determining data change information according to the notification message includes:
and responding to the notification message, and acquiring the data change information from the message queue according to the subject information in the notification message.
Optionally, determining the data change information according to the notification message includes:
responding to the notification message, and sending response information to the message queue according to the subject information in the notification message;
and receiving data change information sent by the message queue in response to the response information.
Optionally, the notification message further includes: the data change information;
determining the data change information according to the notification message, including:
determining the data change information from the received notification message.
Optionally, the data change information includes: data identification, theme information of changed data and change types; the change types include: adding, modifying and deleting.
Optionally, the updating the cache data in the target application according to the data change information includes:
according to the data identification, obtaining updating data corresponding to the data identification from the data source application or a database corresponding to the message queue;
and updating the cache data in the target application according to the updating data and the change type.
Optionally, the data change information includes: changing the theme information, the change type and the update data of the data; the change types include: adding, modifying and deleting;
and updating the cache data in the target application according to the updating data and the change type.
According to still another aspect of the embodiments of the present invention, there is provided an apparatus for caching updates, including:
the monitoring module is used for receiving the notification message sent by the message queue;
the cache updating module is used for determining data change information according to the notification message and updating cache data in the target application according to the data change information; and the data change information is generated by the data source application and stored in the message queue.
Optionally, before receiving the notification message in the message queue, the listening module further includes:
determining configuration information for caching updates in a target application, wherein the configuration information at least comprises: subject information corresponding to the cache;
and the monitoring module receives the notification message sent by the message queue, and the method comprises the following steps:
sending a subscription message about the topic information to the message queue based on the configuration information, and receiving the notification message sent by the message queue based on the subscription message, wherein the notification message at least comprises: subject information of the data is changed.
Optionally, the determining, by the listening module, configuration information for caching updates in the target application includes: determining configuration information for caching update in the target application according to an annotation identifier in a program language;
and after determining the configuration information for caching updates in the target application, the snoop module is further configured to:
based on the configuration information, creating a cache corresponding to each topic information in the target application; and creating a monitoring agent in the target application, wherein the monitoring agent is used for receiving the notification message sent by the message queue and updating the cache data in the cache according to the data change information.
Optionally, the determining, by the cache update module, data change information according to the notification message includes:
and responding to the notification message, and acquiring the data change information from the message queue according to the subject information in the notification message.
Optionally, the determining, by the cache update module according to the notification message, the data change information includes:
responding to the notification message, and sending response information to the message queue according to the subject information in the notification message;
and receiving data change information sent by the message queue in response to the response information.
Optionally, the notification message further includes: the data change information;
the cache updating module determines the data change information according to the notification message, and the cache updating module comprises:
determining the data change information from the received notification message.
Optionally, the data change information includes: data identification, theme information of changed data and change types; the change types include: adding, modifying and deleting.
Optionally, the updating the cache data in the target application by the cache updating module according to the data change information includes:
according to the data identification, obtaining updating data corresponding to the data identification from the data source application or a database corresponding to the message queue;
and updating the cache data in the target application according to the updating data and the change type.
Optionally, the data change information includes: changing the theme information, the change type and the update data of the data; the change types include: adding, modifying and deleting;
and the cache updating module updates the cache data in the target application according to the updating data and the change type.
According to another aspect of the embodiments of the present invention, there is provided an electronic device for caching updates, including:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the cache update method provided by the invention.
According to a further aspect of the embodiments of the present invention, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor, implements the method of cache update provided by the present invention.
One embodiment of the above invention has the following advantages or benefits: because the technical means of monitoring the message queue, determining the data change information according to the notification message when monitoring the notification message about the data change sent by the message queue, and updating the cache data in the target application by using the data change information is adopted, the technical problem that the cache cannot be updated or resources are wasted due to the fact that the cache is updated by setting a timing task or setting a cache validity period in the prior art is solved, and the technical effect of updating the cache timely and effectively without wasting resources is achieved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a flowchart illustrating a method for cache update according to a first embodiment of the present invention;
fig. 2 is a flow chart illustrating a method involved before receiving a notification message according to a second embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for cache update according to a third embodiment of the present invention;
FIG. 4 is a flowchart illustrating a method for cache update according to a fourth embodiment of the present invention;
FIG. 5 is a flowchart illustrating a method for cache update according to a fifth embodiment of the present invention;
FIG. 6 is a block diagram illustrating a method for cache update according to a sixth embodiment of the present invention;
FIG. 7 is a diagram illustrating major blocks of an apparatus for caching updates according to a seventh embodiment of the present invention;
FIG. 8 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 9 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is a flowchart illustrating a processing method of cache update according to a first embodiment of the present invention, as shown in fig. 1, the method of cache update includes:
step S101, receiving a notification message sent by a message queue;
step S102, determining data change information according to the notification message; the data change information is generated by a data source application and stored in the message queue;
and step S103, updating the cache data in the target application according to the data change information.
The data source application can monitor whether the data generated by the data source application is changed or not by setting a listener of a specific data topic in the target application in advance. Specifically, when the data source application generates new data, deletes generated data, or modifies generated data, the data source application generates data change information and stores the data change information in a message queue; the message queue may send a notification message corresponding to the data change information to the target application after receiving the data change information.
According to the method, when the notification message about data change sent by the message queue is received, the data change information is determined according to the notification message, and the cache data in the target application is updated by using the data change information, so that timely and effective cache updating is realized.
In some embodiments, before receiving the notification message in the message queue, the method further includes: determining configuration information for caching updates in a target application, wherein the configuration information at least comprises: subject information corresponding to the cache; the configuration information may be determined from annotation identifiers in the program language;
in some embodiments, after determining the configuration information for caching updates in the target application, the method further includes: based on the configuration information, creating a cache corresponding to each topic information in the target application; and creating a monitoring agent in the target application, wherein the monitoring agent is used for receiving the notification message sent by the message queue and updating the cache data in the cache according to the data change information.
And the notification message sent by the receiving message queue comprises: sending a subscription message about the topic information to the message queue based on the configuration information, and receiving the notification message sent by the message queue based on the subscription message, wherein the notification message at least comprises: subject information of the data is changed.
The configuration information for the cache update may indicate configuration information of a message queue corresponding to the cache update, so that the target application obtains data change information from the corresponding message queue;
the annotation identifier in the program language can be used for being read and identified by other programs, and can also add extra information to the program statement; the Annotation identifier can be regarded as an Annotation mechanism in the program language, and the section can be declared based on an Annotation mode, such as Java Annotation (Annotation) in Java language;
specifically, in the method of the present invention, a possible annotation identifier statement for caching updated configuration information may be set as follows:
@CacheConfigAnnotation(serverAddress="xx1",topic="xxx2",userName="xx3",password="yyyzzz");
the @ CacheConfig can be used for being marked on the class and storing public attributes of all caches in the class;
in the above statements, seriaddresss "xx1", topoic "xxx2", userName "xx3", and password "yyyzzz" may be regarded as the common attribute, specifically:
the server address of "xx1" may be represented as a server address of a message queue subscribed to the cache, the topic of "xxx2" may represent subject information corresponding to the cache in the message queue, and the userName "xx3" and the password "yyzzzz" may represent authentication information related to the subject information.
The monitoring agent can be used for receiving notification messages sent by the message queue; the monitoring agent can also update the cache data in the cache according to the data change information; in some practical applications, other proxy applications may be set, and the proxy applications are used to update the cached data in the cache according to the data change information.
In some practical applications, a cache manager may be further configured for each cache, and is configured to correspond to the configuration information one to one, so as to manage an update method of the corresponding cache, or an initialization method executed after the application is started; a cache manager registry may also be set for all caches or cache managers, and the cache manager registry may send a snoop task including configuration information to the snoop agents, so that the snoop agents are used to receive notification messages sent by the message queue after the target application sends a subscription message to the message queue.
For convenience of understanding the method flow related to receiving the notification message in the above embodiment, reference may be made to fig. 2; fig. 2 is a flowchart illustrating a method included before receiving a notification message according to a second embodiment of the present invention, as shown in fig. 2, including:
step S201, starting a target application;
step S202, determining configuration information for caching updating in the target application according to the annotation identifier in the program language; specifically, after the application program is started, the configuration information may be determined according to an annotation identifier in a program language scanned in the program starting and executing process; the configuration information comprises message queue subject information corresponding to the cache;
step S203, creating a cache corresponding to each topic information;
step S204, a monitoring agent is established; the monitoring agent can be used for receiving the notification message sent by the message queue;
step S205, sending a subscription message about topic information to a message queue based on the configuration information;
step S206, receiving the notification message; the notification message is sent to the target application when the message queue receives the data change information;
in some practical cases, the order of steps S203 and S204 is not limited, and step S203 may be executed first and then step S204 may be executed, step S204 may be executed first and then step S203 may be executed, or step S203 and step S204 may be executed simultaneously; it is sufficient that the execution of steps S203 and S204 is performed after step S202 and before step S205.
In some embodiments, determining data change information from the notification message comprises:
and responding to the notification message, and acquiring the data change information from the message queue according to the subject information in the notification message.
For convenience of understanding the method flow of determining data change information in the above embodiments, reference may be made to fig. 3: FIG. 3 is a flowchart illustrating a method for cache update according to a third embodiment of the present invention, where the method of the third embodiment is executed by a target application, a message queue, and a data source application; as shown in fig. 3, includes:
step S301, the target application sends a subscription message to a message queue; the subscription message may include subscribed topic information;
step S302, the message queue returns a response message based on the subscription message to the target application; the response message may be a message indicating that the subscription is successful;
step S303, the data source application sends data change information to the message queue; specifically, the data change information may be stored in the message queue according to preset theme information;
step S304, when the data change information sent by the data source application is received in the message queue, the message queue can send a notification message about the data change information to the target application based on the subscription message; wherein the notification message may include subject information of the changed data;
step S305, after receiving the notification message, the target application may respond to the notification message and obtain the data change information from the message queue according to the subject information in the notification message;
it should be noted that, in some practical applications, the data source application sending the data change information to the message queue in step S303 may not be limited by whether the target application sends the subscription message to the message queue, and the data source application may also send the data change information to the message queue before the target application sends the subscription message to the message queue, but the message queue does not send a notification message about the data change information to the target application only in a case where the target application does not send the subscription message to the message queue.
In some embodiments, determining the data change information from the notification message comprises: responding to the notification message, and sending response information to the message queue according to the subject information in the notification message;
and receiving data change information sent by the message queue in response to the response information.
For convenience of understanding the method flow of determining data change information in the above embodiments, reference may be made to the following fig. 4: FIG. 4 is a flowchart illustrating a method for cache update according to a fourth embodiment of the present invention, where the method of the fourth embodiment is executed by a target application, a message queue, and a data source application; as shown in fig. 4, includes:
step S401, the target application sends subscription information to an information queue; the subscription message may include subscribed topic information;
step S402, the message queue returns a response message based on the subscription message to the target application; the response message may be a message indicating that the subscription is successful;
step S403, the data source application sends data change information to the message queue; specifically, the data change information may be stored in the message queue according to preset theme information;
step S404, when receiving the data change information sent by the data source application in the message queue, the message queue may send a notification message about the data change information to the target application based on the subscription message; wherein the notification message may include subject information of the changed data;
step S405, the target application returns a response message based on the notification message to the message queue; the response message may be a message indicating that the notification is successfully received and that preparation for accepting the data change information is made;
step S406, after receiving the response message sent by the target application, the message queue may send the data change information to the target queue;
it should be noted that, in some practical applications, the data source application sending the data change information to the message queue in step S403 may not be limited by whether the target application sends the subscription message to the message queue, and the data source application may also send the data change information to the message queue before the target application sends the subscription message to the message queue, but the message queue does not send a notification message about the data change information to the target application only in a case where the target application does not send the subscription message to the message queue.
In some embodiments, the notification message further comprises: the data change information;
determining the data change information according to the notification message, including:
determining the data change information from the received notification message.
For convenience of understanding the method flow of determining data change information in the above embodiments, reference may be made to the following fig. 5: FIG. 5 is a flowchart illustrating a method for cache update according to a fifth embodiment of the present invention, where the method of the fifth embodiment is executed by a target application, a message queue, and a data source application; as shown in fig. 5, includes:
step S501, a target application sends a subscription message to a message queue; the subscription message may include subscribed topic information;
step S502, the message queue returns a response message based on the subscription message to the target application; the response message may be a message indicating that the subscription is successful;
step S503, the data source application sends data change information to the message queue; specifically, the data change information may be stored in the message queue according to preset theme information;
step S504, when receiving the data change information sent by the data source application in the message queue, the message queue may send a notification message containing the data change information to the target application based on the subscription message;
it should be noted that, in some practical applications, the data source application sending the data change information to the message queue in step S503 may not be limited by whether the target application sends the subscription message to the message queue, and the data source application may also send the data change information to the message queue before the target application sends the subscription message to the message queue, but the message queue does not send a notification message about the data change information to the target application only in a case where the target application does not send the subscription message to the message queue.
It is noted that, in the embodiments shown in fig. 1-5, the data change information includes: data identification, theme information of changed data and change types; the change types include: adding, modifying and deleting.
Further, in some embodiments, the updating the cached data in the target application according to the data change information includes: according to the data identification, obtaining updating data corresponding to the data identification from the data source application or a database corresponding to the message queue;
and updating the cache data in the target application according to the updating data and the change type.
The data identification may be a unique identification for identifying data; when the data change information includes the data identifier, the change type, and the theme information of the changed data, the target application may first obtain the data corresponding to the data identifier from the data source application or from the database corresponding to the message queue, and then update the cache related to the theme according to the change type. For example: the data change information may include a data identification of the changed data: "user _ id", and change type: and modifying, namely after receiving the data change information, the target application can acquire the data content corresponding to the user _ id from the data source application or the database corresponding to the message queue, and modify and update the cache in the target application.
In still other embodiments, the data change information includes: changing the theme information, the change type and the update data of the data; the change types include: adding, modifying and deleting; and updating the cache data in the target application according to the updating data and the change type.
When the data change information includes the update data, the change type, and the theme information of the change data, the update data may be obtained from the data change information, and then the cache subscribed with the theme information may be updated according to the change type.
To facilitate understanding of the method architecture in embodiments of the present invention, reference may be made to the following fig. 6: fig. 6 is a schematic structural diagram of a method for cache update according to a sixth embodiment of the present invention, as shown in fig. 6, including:
a target application 601, a message queue 602, a data source application 603, and a database 604 corresponding to the message queue; in the target application 601, the method includes: cache configuration 605, cache/cache manager 606, cache manager registry 607, snoop agent 608; wherein the content of the first and second substances,
the target application 601 is an application that has a cache update requirement along with the update of data in the data source application;
the message queue 602 can serve as message middleware for the target application 601 and the data source application 603; specifically, the data source application 603 may send data change information to the message queue 602 when a data change occurs; the target application 601 may send a subscription message to the message queue 602, so that the message queue 602 sends a corresponding notification message to the target application 601 when receiving the data change information sent by the data source application 603;
in the target application 601, the cache configuration information 605 may indicate configuration information of a message queue corresponding to a cache update;
the cache/cache manager 606 may be used to indicate the cache to be updated;
cache manager registry 607 may be used to manage all caches/cache managers;
listening agent 608 may be configured to receive notification messages sent by the message queue;
after the target application 601 is started, the cache configuration information 605 may be determined, and a cache/cache manager 606 may be created according to the cache configuration information 605, and a snoop agent 608 may be created for receiving the notification message sent by the message queue 602;
when the target application 601 determines data change information for updating the cache, the cache indicated by the cache/cache manager 606 may be updated with the snooping agent 608;
when the data change information includes a data identifier, theme information of the changed data, and a change type, the updated data may be obtained from the database 604 corresponding to the message queue, and then the updated data is used to perform cache update; in another example, which is not shown, as described above, the database 604 is a database corresponding to the data source application 603, that is, the update data may be obtained from the database 604 corresponding to the data source 603, and then the cache update may be performed using the update data.
When the data change information comprises the theme information, the change type and the update data of the change data, the cache update can be directly carried out according to the update data.
In summary, the cache update method of the present invention can be accomplished by the above-mentioned architecture.
Fig. 7 is a schematic diagram of main modules of an apparatus for caching updates according to a seventh embodiment of the present invention, and as shown in fig. 7, an apparatus 700 for processing a service request includes:
a monitoring module 701, configured to receive a notification message sent by a message queue;
a cache updating module 702, configured to determine data change information according to the notification message, and update cache data in a target application according to the data change information; and the data change information is generated by the data source application and stored in the message queue.
The data source application can monitor whether the data generated by the data source application is changed or not by setting a listener of a specific data topic in the target application in advance. Specifically, when the data source application generates new data, deletes generated data, or modifies generated data, the data source application generates data change information and stores the data change information in a message queue; the message queue may send a notification message corresponding to the data change information to the target application after receiving the data change information.
According to the device, when the notification message about data change sent by the message queue is received, the data change information is determined according to the notification message, and the cache data in the target application is updated by using the data change information, so that timely and effective cache updating is realized.
In some embodiments, the listening module 701, before receiving the notification message in the message queue, further includes: determining configuration information for caching updates in a target application, wherein the configuration information at least comprises: subject information corresponding to the cache;
in some embodiments, the snooping module 701 determines configuration information for caching updates in the target application includes: determining configuration information for caching update in the target application according to an annotation identifier in a program language;
and after determining the configuration information for caching updates in the target application, the snoop module is further configured to: based on the configuration information, creating a cache corresponding to each topic information in the target application; and creating a monitoring agent in the target application, wherein the monitoring agent is used for receiving the notification message sent by the message queue and updating the cache data in the cache according to the data change information.
And the monitoring module receives the notification message sent by the message queue, and the method comprises the following steps:
sending a subscription message about the topic information to the message queue based on the configuration information, and receiving the notification message sent by the message queue based on the subscription message, wherein the notification message at least comprises: subject information of the data is changed.
The configuration information for the cache update may indicate configuration information of a message queue corresponding to the cache update, so that the target application obtains data change information from the corresponding message queue;
the annotation identifier in the program language can be used for being read and identified by other programs, and can also add extra information to the program statement; the Annotation identifier can be regarded as an Annotation mechanism in the program language, and the section can be declared based on an Annotation mode, such as Java Annotation (Annotation) in Java language;
specifically, in the method of the present invention, a possible annotation identifier statement for caching updated configuration information may be set as follows:
@CacheConfigAnnotation(serverAddress="xx1",topic="xxx2",userName="xx3",password="yyyzzz");
the @ CacheConfig can be used for being marked on the class and storing public attributes of all caches in the class;
in the above statements, seriaddresss "xx1", topoic "xxx2", userName "xx3", and password "yyyzzz" may be regarded as the common attribute, specifically:
the server address of "xx1" may be represented as a server address of a message queue subscribed to the cache, the topic of "xxx2" may represent subject information corresponding to the cache in the message queue, and the userName "xx3" and the password "yyzzzz" may represent authentication information related to the subject information.
The monitoring agent can be used for receiving notification messages sent by the message queue; the monitoring agent can also update the cache data in the cache according to the data change information; in some practical applications, other proxy applications may be set, and the proxy applications are used to update the cached data in the cache according to the data change information.
In some practical applications, a cache manager may be further configured for each cache, and is configured to correspond to the configuration information one to one, so as to manage an update method of the corresponding cache, or an initialization method executed after the application is started; a cache manager registry may also be set for all caches or cache managers, and the cache manager registry may send snoop tasks including configuration information to the snoop agents, so that the snoop agents may receive notification messages sent by the message queue after the target application sends a subscription message to the message queue.
In some embodiments, the cache update module 702 determines data change information from the notification message, including: and responding to the notification message, and acquiring the data change information from the message queue according to the subject information in the notification message.
In some embodiments, the cache update module 702 determines the data change information according to the notification message, including: responding to the notification message, and sending response information to the message queue according to the subject information in the notification message; and receiving data change information sent by the message queue in response to the response information.
In some embodiments, the notification message further comprises: the data change information; the cache update module 702 determines the data change information according to the notification message, including: determining the data change information from the received notification message.
In some embodiments, the data change information includes: data identification, theme information of changed data and change types; the change types include: adding, modifying and deleting.
Further, in some embodiments, the cache updating module 702 updates the cache data in the target application according to the data change information, including:
according to the data identification, obtaining updating data corresponding to the data identification from the data source application or a database corresponding to the message queue;
and updating the cache data in the target application according to the updating data and the change type.
The data identification may be a unique identification for identifying data; when the data change information includes the data identifier, the change type, and the theme information of the changed data, the target application may first obtain the data corresponding to the data identifier from the data source application or from the database corresponding to the message queue, and then update the cache related to the theme according to the change type. For example: the data change information may include a data identification of the changed data: "user _ id", and change type: and modifying, namely after receiving the data change information, the target application can acquire the data content corresponding to the user _ id from the data source application or the database corresponding to the message queue, and modify and update the cache in the target application.
In some embodiments, the data change information includes: changing the theme information, the change type and the update data of the data; the change types include: adding, modifying and deleting; the cache update module 702 updates the cache data in the target application according to the update data and the change type.
When the data change information includes the update data, the change type, and the theme information of the change data, the update data may be obtained from the data change information, and then the cache subscribed with the theme information may be updated according to the change type.
Fig. 8 illustrates an exemplary system architecture 800 to which the method of cache update or the apparatus of cache update of embodiments of the present invention may be applied.
As shown in fig. 8, the system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. The network 804 serves to provide a medium for communication links between the terminal devices 801, 802, 803 and the server 805. Network 804 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 801, 802, 803 to interact with a server 805 over a network 804 to receive or send messages or the like. The terminal devices 801, 802, 803 may have installed thereon various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like.
The terminal devices 801, 802, 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 805 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 801, 802, 803.
It should be understood that the number of terminal devices, networks, and servers in fig. 8 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 9, shown is a block diagram of a computer system 900 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU)901 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
The following components are connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The above-described functions defined in the system of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 901.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or 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 foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a monitoring module and a cache updating module. Wherein the names of the modules do not in some cases constitute a limitation of the module itself.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: step S101, receiving a notification message sent by a message queue; step S102, determining data change information according to the notification message; the data change information is generated by a data source application and stored in the message queue; and step S103, updating the cache data in the target application according to the data change information.
According to the technical scheme of the embodiment of the invention, when the notification message about data change sent by the message queue is monitored, the data change information is determined according to the notification message, and the cache data in the target application is updated by using the data change information, so that the technical problem that the cache cannot be updated or resources are wasted due to the fact that the cache is updated by setting a timing task or setting a cache validity period in the prior art is solved, and the technical effect of updating the cache timely and effectively without wasting resources is achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A method of cache update, comprising:
receiving a notification message sent by a message queue;
determining data change information according to the notification message; the data change information is generated by a data source application and stored in the message queue;
and updating the cache data in the target application according to the data change information.
2. The method of claim 1, wherein prior to receiving the notification message in the message queue, further comprising:
determining configuration information for caching updates in the target application, wherein the configuration information at least comprises: subject information corresponding to the cache;
and the notification message sent by the receiving message queue comprises:
sending a subscription message about the topic information to the message queue based on the configuration information, and receiving the notification message sent by the message queue based on the subscription message, wherein the notification message at least comprises: subject information of the data is changed.
3. The method of claim 2, wherein determining configuration information for caching updates in the target application comprises: determining configuration information for caching update in the target application according to an annotation identifier in a program language;
and after determining the configuration information for caching updates in the target application, further comprising:
based on the configuration information, creating a cache corresponding to each topic information in the target application; and creating a monitoring agent in the target application, wherein the monitoring agent is used for receiving the notification message sent by the message queue and updating the cache data in the cache according to the data change information.
4. The method of any of claims 1-3, wherein determining data change information based on the notification message comprises:
and responding to the notification message, and acquiring the data change information from the message queue according to the subject information in the notification message.
5. The method of any of claims 1-3, wherein determining the data change information based on the notification message comprises:
responding to the notification message, and sending response information to the message queue according to the subject information in the notification message;
and receiving data change information sent by the message queue in response to the response information.
6. The method of any of claims 1-3, wherein the notification message further comprises: the data change information;
determining the data change information according to the notification message, including:
determining the data change information from the received notification message.
7. The method of claims 1-3, wherein the data change information comprises: data identification, theme information of changed data and change types; the change types include: adding, modifying and deleting.
8. The method of claim 7, wherein updating the cached data in the target application according to the data change information comprises:
according to the data identification, obtaining updating data corresponding to the data identification from the data source application or a database corresponding to the message queue;
and updating the cache data in the target application according to the updating data and the change type.
9. The method of claims 1-3, wherein the data change information comprises: changing the theme information, the change type and the update data of the data; the change types include: adding, modifying and deleting;
and updating the cache data in the target application according to the updating data and the change type.
10. An apparatus for caching updates, comprising:
the monitoring module is used for receiving the notification message sent by the message queue;
the cache updating module is used for determining data change information according to the notification message and updating cache data in the target application according to the data change information; and the data change information is generated by the data source application and stored in the message queue.
11. An electronic device that caches updates, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-9.
CN202010885891.9A 2020-08-28 2020-08-28 Cache updating method and device Pending CN113742617A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010885891.9A CN113742617A (en) 2020-08-28 2020-08-28 Cache updating method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010885891.9A CN113742617A (en) 2020-08-28 2020-08-28 Cache updating method and device

Publications (1)

Publication Number Publication Date
CN113742617A true CN113742617A (en) 2021-12-03

Family

ID=78727987

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010885891.9A Pending CN113742617A (en) 2020-08-28 2020-08-28 Cache updating method and device

Country Status (1)

Country Link
CN (1) CN113742617A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115840862A (en) * 2023-02-21 2023-03-24 南京赛宁信息技术有限公司 Method and system for quickly querying targets in large-scale scene of network target range

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115840862A (en) * 2023-02-21 2023-03-24 南京赛宁信息技术有限公司 Method and system for quickly querying targets in large-scale scene of network target range

Similar Documents

Publication Publication Date Title
CN113489772B (en) Network request processing method and device and electronic equipment
CN109388626B (en) Method and apparatus for assigning numbers to services
CN111475180A (en) Method and system for updating client cache
CN109995801B (en) Message transmission method and device
CN111427701A (en) Workflow engine system and business processing method
CN108011949B (en) Method and apparatus for acquiring data
CN113760324A (en) Method and device for constructing micro front-end application
CN111510466B (en) Data updating method and device for client, electronic equipment and readable medium
CN113364887B (en) File downloading method based on FTP, proxy server and system
CN113760536A (en) Data caching method and device, electronic equipment and computer readable medium
CN113595927A (en) Method and device for processing mirror flow in bypass mode
CN113742617A (en) Cache updating method and device
CN112948138A (en) Method and device for processing message
CN113127923A (en) Method and device for managing authority
CN110851194A (en) Method and device for acquiring code for realizing new interface
CN114528517A (en) View processing method and device, electronic equipment and computer readable medium
CN115442129A (en) Method, device and system for managing cluster access authority
CN109981320B (en) Method and device for managing configuration information
CN109087097B (en) Method and device for updating same identifier of chain code
CN108833147B (en) Configuration information updating method and device
CN110019671B (en) Method and system for processing real-time message
CN109213815B (en) Method, device, server terminal and readable medium for controlling execution times
CN113238808A (en) Message pushing method and device
CN110262756B (en) Method and device for caching data
CN113766437B (en) Short message sending method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination