Nothing Special   »   [go: up one dir, main page]

CN105574158A - Refreshing method and system of database caching data - Google Patents

Refreshing method and system of database caching data Download PDF

Info

Publication number
CN105574158A
CN105574158A CN201510944487.3A CN201510944487A CN105574158A CN 105574158 A CN105574158 A CN 105574158A CN 201510944487 A CN201510944487 A CN 201510944487A CN 105574158 A CN105574158 A CN 105574158A
Authority
CN
China
Prior art keywords
message
library
update
update time
time
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.)
Granted
Application number
CN201510944487.3A
Other languages
Chinese (zh)
Other versions
CN105574158B (en
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.)
Vipshop Guangzhou Software Co Ltd
Original Assignee
Guangzhou Pinwei Software 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 Guangzhou Pinwei Software Co Ltd filed Critical Guangzhou Pinwei Software Co Ltd
Priority to CN201510944487.3A priority Critical patent/CN105574158B/en
Publication of CN105574158A publication Critical patent/CN105574158A/en
Application granted granted Critical
Publication of CN105574158B publication Critical patent/CN105574158B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • 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/23Updating

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a refreshing method and system of database caching data. The refreshing method comprises the following steps: receiving a primary library update message which contains primary library update time which is updated at the time and an updated data object, obtaining the auxiliary library update time of a corresponding data object in an auxiliary library, then, comparing the primary library update time and the auxiliary library update time, and executing a caching data refreshing operation if the auxiliary library update time is longer than the primary library update time. Therefore, the refreshing of the caching data can be realized without a situation that development personnel increase development codes of timing task inspection so as to lower the development cost of the refreshing of the database caching data.

Description

数据库缓存数据的刷新方法及其系统Method and system for refreshing database cache data

技术领域technical field

本发明涉及数据库领域,特别是一种数据库缓存数据的刷新方法及其系统。The invention relates to the field of databases, in particular to a method and system for refreshing cached data in a database.

背景技术Background technique

在数据库读写分离的场景下,从库数据复制会有一定的延时,而缓存的数据来源是从库,当数据有修改、需要刷新缓存的时候,需要等待较长的时间。In the scenario where the database reads and writes are separated, there will be a certain delay in replicating data from the database, and the source of the cached data is from the database. When the data is modified and the cache needs to be refreshed, it takes a long time to wait.

目前已有的方案中,通常是把修改的信息记录在主库中,然后用定时任务检查的方式检查从库中的数据是否有更新,若发现有更新就刷新缓存,否则继续等待任务检查,因此,需要开发人员花费较大的精力,增加定时任务检查的开发代码以实现缓存数据的刷新,从而提高了数据库缓存数据刷新的开发成本。In the current existing solutions, the modified information is usually recorded in the main library, and then the data in the slave library is checked by a scheduled task check. If there is an update, the cache is refreshed, otherwise continue to wait for the task check. Therefore, developers need to spend a lot of energy to increase the development code of scheduled task checking to realize the refreshing of cached data, thereby increasing the development cost of refreshing the database cached data.

发明内容Contents of the invention

针对上述现有技术中存在的数据库缓存数据刷新的开发成本较高的问题,本发明的目的在于提供一种数据库缓存数据的刷新方法及其系统,能够降低数据库缓存数据刷新的开发成本。In view of the high development cost of database cache data refresh in the above prior art, the purpose of the present invention is to provide a database cache data refresh method and system thereof, which can reduce the development cost of database cache data refresh.

数据库缓存数据的刷新方法,包括:Refresh method of database cache data, including:

接收主库数据更新的消息,所述消息包含本次更新的时间以及更新的数据对象,记所述时间为主库更新时间;Receive the message of main library data update, the message includes the time of this update and the updated data object, record the time as the update time of the main library;

获取从库中相应数据对象的最近更新时间,记为从库更新时间,比较所述从库更新时间和所述主库更新时间;Obtain the latest update time of the corresponding data object in the slave library, record it as the update time of the slave library, and compare the update time of the slave library with the update time of the master library;

若所述从库更新时间大于等于所述主库更新时间,根据所述消息执行缓存数据的刷新操作。If the update time of the slave library is greater than or equal to the update time of the master library, a cache data refresh operation is performed according to the message.

数据库缓存数据的刷新系统,包括:Refresh system for database cache data, including:

消息接收模块,用于接收主库数据更新的消息,所述消息包含本次更新的时间以及更新的数据对象,记所述时间为主库更新时间;The message receiving module is used to receive the message of master database data update, and said message includes the time of this update and the updated data object, and records said time as master database update time;

消息比较模块,用于获取从库中相应数据对象的最近更新时间,记为从库更新时间,比较所述从库更新时间和所述主库更新时间;The message comparison module is used to obtain the latest update time of the corresponding data object in the slave library, which is recorded as the update time of the slave library, and compares the update time of the slave library with the update time of the main library;

数据刷新模块,用于若所述从库更新时间大于等于所述主库更新时间,根据所述消息执行缓存数据的刷新操作。A data refresh module, configured to perform a cache data refresh operation according to the message if the update time of the slave library is greater than or equal to the update time of the master library.

本发明的数据库缓存数据的刷新方法及其系统,通过接收包含本次更新的主库更新时间以及更新的数据对象的主库数据更新消息,获取从库中相应数据对象的从库更新时间,然后比较从库更新时间和所述主库更新时间,若所述从库更新时间大于等于所述主库更新时间,则根据所述消息执行缓存数据的刷新操作。因此,无需开发人员增加定时任务检查的开发代码就能实现缓存数据的刷新,从而降低数据库缓存数据刷新的开发成本。The method and system for refreshing database cached data of the present invention obtains the update time of the corresponding data object in the slave library by receiving the update time of the master library including the update time of the master library and the updated data object of the master library, and then Comparing the update time of the slave library with the update time of the master library, if the update time of the slave library is greater than or equal to the update time of the master library, perform a refresh operation of cached data according to the message. Therefore, the refresh of cached data can be realized without developers adding development codes for timing task checking, thereby reducing the development cost of refreshing database cached data.

附图说明Description of drawings

图1为一个实施例的数据库缓存数据的刷新方法的流程示意图;Fig. 1 is a schematic flow chart of a method for refreshing database cached data of an embodiment;

图2为数据库缓存数据的刷新方法的一个实例图;Fig. 2 is an example diagram of the refreshing method of database cache data;

图3为一个实施例的数据库缓存数据的刷新系统的结构示意图。Fig. 3 is a schematic structural diagram of a system for refreshing database cache data according to an embodiment.

具体实施方式detailed description

为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述。In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings.

请参阅图1中一个实施例的数据库缓存数据的刷新方法的流程示意图。Please refer to FIG. 1 for a schematic flowchart of a method for refreshing database cache data in an embodiment.

一种数据库缓存数据的刷新方法,包括:A method for refreshing database cache data, comprising:

S102,接收主库数据更新的消息,所述消息包含本次更新的时间以及更新的数据对象,记所述时间为主库更新时间。S102. Receive a data update message of the master database, the message includes the time of this update and the updated data object, and record the time as the update time of the master database.

通过接收主库数据更新的消息,确定主库的更新时间以及更新的数据对象,为后续更新时间的比较提供基准。By receiving the data update message of the master database, determine the update time of the master database and the updated data objects, and provide a benchmark for the comparison of subsequent update times.

S104,获取从库中相应数据对象的最近更新时间,记为从库更新时间,比较所述从库更新时间和所述主库更新时间。S104. Obtain the latest update time of the corresponding data object in the slave library, record it as the update time of the slave library, and compare the update time of the slave library with the update time of the master library.

通过获取从库中相应数据对象的最近更新时间,确定从库的更新时间,并对从库更新时间和主库更新时间作比较,判断从库中相应数据对象的更新情况,从而提高判断从库数据更新的便利性。By obtaining the latest update time of the corresponding data object in the slave library, determine the update time of the slave library, and compare the update time of the slave library with the update time of the master library to judge the update status of the corresponding data object in the slave library, thereby improving the judgment of the slave library The convenience of data update.

S106,若所述从库更新时间大于等于所述主库更新时间,根据所述消息执行缓存数据的刷新操作。S106. If the update time of the slave library is greater than or equal to the update time of the master library, perform a cache data refresh operation according to the message.

如果所述从库更新时间大于等于所述主库更新时间,说明从库中相应的数据对象在本次的更新中已经更新,则执行缓存数据的刷新操作,因此,通过主动执行缓存数据的刷新操作,从而缩短缓存数据的等待刷新时间,提高缓存数据的刷新效率。If the update time of the slave library is greater than or equal to the update time of the main library, it means that the corresponding data object in the slave library has been updated in this update, and the refresh operation of the cached data is performed. Therefore, by actively performing the refresh of the cached data operation, thereby shortening the waiting refresh time of cached data and improving the refresh efficiency of cached data.

本实施例中,通过接收包含本次更新的主库更新时间以及更新的数据对象的主库数据更新消息,获取从库中相应数据对象的从库更新时间,然后比较从库更新时间和所述主库更新时间,若所述从库更新时间大于等于所述主库更新时间,则根据所述消息执行缓存数据的刷新操作。因此,无需开发人员增加定时任务检查的开发代码就能实现缓存数据的刷新,从而降低数据库缓存数据刷新的开发成本。In this embodiment, by receiving the main library data update message containing the updated main library update time and the updated data object, the slave library update time of the corresponding data object in the slave library is obtained, and then the slave library update time is compared with the Master database update time, if the slave database update time is greater than or equal to the master database update time, perform a cache data refresh operation according to the message. Therefore, the refresh of cached data can be realized without developers adding development codes for timing task checking, thereby reducing the development cost of refreshing database cached data.

在其中一个实施例中,所述比较所述从库更新时间和所述主库更新时间,之后包括:In one of the embodiments, the comparison of the update time of the slave library and the update time of the master library includes:

若所述从库更新时间小于所述主库更新时间,将所述消息的标识存入预设的服务队列。If the update time of the slave library is less than the update time of the master library, store the identifier of the message in a preset service queue.

其中,所述消息的标识为本次主库数据更新的消息的标签,只需存储所述消息的标识即可,从而节省系统资源;所述服务队列用于存储所述消息的标识,并对所述消息的标识进行监控。Wherein, the identification of the message is the label of the message of the main library data update this time, and only the identification of the message needs to be stored, thereby saving system resources; the service queue is used to store the identification of the message, and The identification of the message to monitor.

在其中一个实施例中,所述将所述消息的标识存入预设的服务队列,之后包括:In one of the embodiments, the step of storing the identifier of the message into a preset service queue includes:

检测所述消息的标识存入所述服务队列的时间是否达到设定时长,若是,返回所述消息接收失败的响应,以重新接收所述消息。Detect whether the time for storing the identifier of the message in the service queue reaches a set duration, and if so, return a response that the message fails to be received, so as to receive the message again.

通过检测,若所述消息的标识存入所述服务队列的时间达到设定时长,则返回所述消息接收失败的响应,以重新接收所述消息,并在重新接收到所述消息后,再次对从库的数据更新情况进行判定,提高从库数据更新的判定效率。Through detection, if the time for the identifier of the message to be stored in the service queue reaches the set duration, return a response that the message fails to be received, to re-receive the message, and after re-receiving the message, again Judgment is made on the data update status of the slave database to improve the judgment efficiency of the slave database data update.

在其中一个实施例中,所述接收主库数据更新的消息,包括:In one of the embodiments, the receiving the message of master database data update includes:

接收预设的消息队列发送的主库数据更新的消息,所述消息队列实时获取主库数据更新的消息,从而提高获取数据更新的消息的效率;Receiving the message of the main library data update sent by the preset message queue, the message queue obtains the message of the main library data update in real time, thereby improving the efficiency of obtaining the message of the data update;

所述根据所述消息执行缓存数据的刷新操作,之后还包括,The executing the refresh operation of cached data according to the message further includes,

向所述消息队列返回所述消息接收成功的响应,释放消息队列中相应消息的占用资源,从而提高消息队列的运行效率;Returning a response that the message is received successfully to the message queue, releasing the occupied resources of the corresponding message in the message queue, thereby improving the operating efficiency of the message queue;

所述返回所述消息接收失败的响应,以重新接收所述消息,包括,The returning a response of failure to receive the message to re-receive the message includes,

向所述消息队列返回所述消息接收失败的响应,并接收所述消息队列重新发送的所述消息,从而继续对从库的数据更新情况进行判定,提高从库数据更新的判定效率。Returning a response of failure to receive the message to the message queue, and receiving the message resent by the message queue, so as to continue to judge the data update situation of the slave database, and improve the judgment efficiency of the data update of the slave database.

图2为数据库缓存数据的刷新方法的一个实例图,结合图2所示,下面以一具体实例对本发明数据库缓存数据的刷新方法实施例进行进一步的说明。FIG. 2 is an example diagram of a method for refreshing database cached data. In combination with FIG. 2 , the embodiment of the method for refreshing database cached data of the present invention will be further described below with a specific example.

具体地,在更新组件202与处理组件203间设置了一消息队列204。当主库200数据有更新时,更新组件202发送更新缓存的通知消息给消息队列204,所述消息包含主库更新时间以及更新的数据对象;处理组件203接收所述消息队列204转发的更新消息,获取从库201中相应数据对象的最近更新时间(记为从库更新时间),并比较所述从库更新时间和所述主库更新时间,若所述从库更新时间大于等于所述主库更新时间,则处理组件203根据所述消息执行缓存数据的刷新操作,并向所述消息队列204返回所述消息接收成功的响应;否则,将所述消息的标识存入预设的服务队列205;检测所述消息的标识存入所述服务队列205的时间是否达到120秒,若是,向所述消息队列204返回所述消息接收失败的响应,并将该消息重新放回消息队列204中,处理组件203将重新接收所述消息,充分利用了消息队列的延迟确认机制,使缓存刷新变得简单和高效,有利于实现需要异步刷新缓存的场景。Specifically, a message queue 204 is set between the updating component 202 and the processing component 203 . When the main library 200 data was updated, the update component 202 sent a notification message of updating the cache to the message queue 204, and the message included the update time of the main library and the updated data object; the processing component 203 received the update message forwarded by the message queue 204, Obtain the latest update time (recorded as the update time from the library) of the corresponding data object in the library 201, and compare the update time from the library with the update time of the main library, if the update time from the library is greater than or equal to the main library update time, then the processing component 203 performs the refresh operation of cached data according to the message, and returns a response that the message is received successfully to the message queue 204; otherwise, the message identifier is stored in the preset service queue 205 ; detect whether the time for the identification of the message to be stored in the service queue 205 reaches 120 seconds, if so, return the response of the message reception failure to the message queue 204, and put the message back in the message queue 204, The processing component 203 will re-receive the message, making full use of the delayed confirmation mechanism of the message queue, making cache refreshing simple and efficient, and facilitating the realization of scenarios requiring asynchronous cache refreshing.

在其中一个实施例中,所述消息队列为RabbitMQ队列,所述设定时长为120秒。In one of the embodiments, the message queue is a RabbitMQ queue, and the set duration is 120 seconds.

所述RabbitMQ队列性能强大、易于使用,用于本实施例中更能提高消息队列的可操作性;120秒的设定时长在提高从库数据更新的判定效率的同时,使得判定的频率不过于密集,从而避免占用过多的系统资源。The RabbitMQ queue has powerful performance and is easy to use, and it is used in this embodiment to improve the operability of the message queue; while the setting time of 120 seconds improves the judgment efficiency of slave database data update, the frequency of judgment is not too high. Dense, so as not to take up too many system resources.

本发明还提供一种数据库缓存数据的刷新系统,如图3所示,包括:The present invention also provides a refresh system for database cache data, as shown in Figure 3, comprising:

消息接收模块300,用于接收主库数据更新的消息,所述消息包含本次更新的时间以及更新的数据对象,记所述时间为主库更新时间。The message receiving module 300 is configured to receive a message of data update of the master database, the message includes the time of this update and the updated data object, and the time is recorded as the update time of the master database.

所述消息接收模块300通过接收主库数据更新的消息,确定主库的更新时间以及更新的数据对象,为后续更新时间的比较提供基准。The message receiving module 300 determines the update time of the main library and the updated data objects by receiving the message of the main library data update, so as to provide a benchmark for the comparison of subsequent update times.

消息比较模块301,用于获取从库中相应数据对象的最近更新时间,记为从库更新时间,比较所述从库更新时间和所述主库更新时间。The message comparison module 301 is configured to obtain the latest update time of the corresponding data object in the slave library, which is recorded as the update time of the slave library, and compare the update time of the slave library with the update time of the master library.

所述消息比较模块301通过获取从库中相应数据对象的最近更新时间,确定从库的更新时间,并对从库更新时间和主库更新时间作比较,判断从库中相应数据对象的更新情况,从而提高判断从库数据更新的便利性。The message comparison module 301 determines the update time of the slave library by obtaining the latest update time of the corresponding data object in the library, and compares the update time of the slave library with the update time of the master library to determine the update situation of the corresponding data object in the slave library , so as to improve the convenience of judging the data update of the slave library.

数据刷新模块302,用于若所述从库更新时间大于等于所述主库更新时间,根据所述消息执行缓存数据的刷新操作。The data refresh module 302 is configured to perform a cache data refresh operation according to the message if the update time of the slave library is greater than or equal to the update time of the master library.

如果所述从库更新时间大于等于所述主库更新时间,说明从库中相应的数据对象在本次的更新中已经更新,则执行缓存数据的刷新操作,因此,通过主动执行缓存数据的刷新操作,从而缩短缓存数据的等待刷新时间,提高缓存数据的刷新效率。If the update time of the slave library is greater than or equal to the update time of the main library, it means that the corresponding data object in the slave library has been updated in this update, and the refresh operation of the cached data is performed. Therefore, by actively performing the refresh of the cached data operation, thereby shortening the waiting refresh time of cached data and improving the refresh efficiency of cached data.

本实施例中,消息接收模块300接收包含本次更新的主库更新时间以及更新的数据对象的主库数据更新消息,消息比较模块301获取从库中相应数据对象的从库更新时间,然后比较从库更新时间和所述主库更新时间,数据刷新模块302判断若所述从库更新时间大于等于所述主库更新时间,则根据所述消息执行缓存数据的刷新操作。因此,无需开发人员增加定时任务检查的开发代码就能实现缓存数据的刷新,从而降低数据库缓存数据刷新的开发成本。In this embodiment, the message receiving module 300 receives the master library data update message containing the updated master library update time and the updated data object this time, and the message comparison module 301 obtains the slave library update time of the corresponding data object in the slave library, and then compares From the update time of the database and the update time of the master database, the data refresh module 302 judges that if the update time of the slave database is greater than or equal to the update time of the master database, then perform a cache data refresh operation according to the message. Therefore, the refresh of cached data can be realized without developers adding development codes for timing task checking, thereby reducing the development cost of refreshing database cached data.

在其中一个实施例中,所述数据刷新模块,还用于若所述从库更新时间小于所述主库更新时间,将所述消息的标识存入预设的服务队列。In one of the embodiments, the data refresh module is further configured to store the identifier of the message in a preset service queue if the update time of the slave library is shorter than the update time of the master library.

在其中一个实施例中,所述数据刷新模块,还用于检测所述消息的标识存入所述服务队列的时间是否达到设定时长,若是,返回所述消息接收失败的响应,以重新接收所述消息。In one of the embodiments, the data refresh module is also used to detect whether the time for storing the identifier of the message in the service queue reaches the set duration, and if so, return a response that the message fails to be received to receive it again said message.

其中,所述消息的标识为本次主库数据更新的消息的标签,只需存储所述消息的标识即可,从而节省系统资源;所述服务队列用于存储所述消息的标识,并对所述消息的标识进行监控,若所述消息的标识存入所述服务队列的时间达到设定时长,则返回所述消息接收失败的响应,以重新接收所述消息,从而继续对从库的数据更新情况进行判定,提高从库数据更新的判定效率。Wherein, the identification of the message is the label of the message of the main library data update this time, and only the identification of the message needs to be stored, thereby saving system resources; the service queue is used to store the identification of the message, and The identification of the message is monitored, and if the time for storing the identification of the message in the service queue reaches the set duration, a response that the message fails to be received is returned to receive the message again, thereby continuing to process the slave library. The data update status is judged to improve the judgment efficiency of slave database data update.

在其中一个实施例中,所述数据库缓存数据的刷新系统还包括,In one of the embodiments, the system for refreshing the database cache data further includes:

消息中转模块,用于通过预设的消息队列实时获取主库数据更新的消息,从而提高获取数据更新的消息的效率;The message transfer module is used to obtain the data update message of the main database in real time through the preset message queue, thereby improving the efficiency of obtaining the message of data update;

所述消息接收模块包括:The message receiving module includes:

接收子模块,用于接收所述消息中转模块发送的主库数据更新的消息;The receiving sub-module is used to receive the message of master database data update sent by the message transfer module;

第一响应子模块,用于在根据所述消息执行缓存数据的刷新操作之后,向所述消息中转模块返回所述消息接收成功的响应,以释放消息队列中相应消息的占用资源,从而提高消息队列的运行效率;The first response sub-module is configured to return a response to the message transfer module that the message is received successfully after performing the cache data refresh operation according to the message, so as to release the occupied resources of the corresponding message in the message queue, thereby improving the message The operating efficiency of the queue;

第二响应子模块,用于若所述消息的标识存入所述服务队列的时间达到设定时长,向所述消息中转模块返回所述消息接收失败的响应,并接收所述消息中转模块重新发送的所述消息,从而继续对从库的数据更新情况进行判定,提高从库数据更新的判定效率。The second response sub-module is used to return a response that the message fails to be received to the message transfer module if the time for the message identifier to be stored in the service queue reaches the set duration, and receive the message transfer module again The message is sent, so as to continue to judge the data update situation of the slave database, and improve the judgment efficiency of the data update of the slave database.

在其中一个实施例中,所述消息队列为RabbitMQ队列,所述设定时长为120秒。In one of the embodiments, the message queue is a RabbitMQ queue, and the set duration is 120 seconds.

所述RabbitMQ队列性能强大、易于使用,用于本实施例中更能提高消息队列的可操作性;120秒的设定时长在提高从库数据更新的判定效率的同时,使得判定的频率不过于密集,从而避免占用过多的系统资源。The RabbitMQ queue has powerful performance and is easy to use, and it is used in this embodiment to improve the operability of the message queue; while the setting time of 120 seconds improves the judgment efficiency of slave database data update, the frequency of judgment is not too high. Dense, so as not to take up too many system resources.

以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The various technical features of the above-mentioned embodiments can be combined arbitrarily. For the sake of concise description, all possible combinations of the various technical features in the above-mentioned embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, should be considered as within the scope of this specification.

以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation modes of the present invention, and the descriptions thereof are relatively specific and detailed, but should not be construed as limiting the patent scope of the present invention. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent for the present invention should be based on the appended claims.

Claims (10)

1.数据库缓存数据的刷新方法,其特征在于,包括:1. The refresh method of database cache data is characterized in that, comprising: 接收主库数据更新的消息,所述消息包含本次更新的时间以及更新的数据对象,记所述时间为主库更新时间;Receive the message of main library data update, the message includes the time of this update and the updated data object, record the time as the update time of the main library; 获取从库中相应数据对象的最近更新时间,记为从库更新时间,比较所述从库更新时间和所述主库更新时间;Obtain the latest update time of the corresponding data object in the slave library, record it as the update time of the slave library, and compare the update time of the slave library with the update time of the master library; 若所述从库更新时间大于等于所述主库更新时间,根据所述消息执行缓存数据的刷新操作。If the update time of the slave library is greater than or equal to the update time of the master library, a cache data refresh operation is performed according to the message. 2.根据权利要求1所述的数据库缓存数据的刷新方法,其特征在于,所述比较所述从库更新时间和所述主库更新时间,之后包括:2. the refresh method of database cache data according to claim 1, is characterized in that, described comparing described from library update time and described master library update time, comprising afterwards: 若所述从库更新时间小于所述主库更新时间,将所述消息的标识存入预设的服务队列。If the update time of the slave library is less than the update time of the master library, store the identifier of the message in a preset service queue. 3.根据权利要求2所述的数据库缓存数据的刷新方法,其特征在于,所述将所述消息的标识存入预设的服务队列,之后包括:3. The refresh method of the database cache data according to claim 2, characterized in that, storing the identifier of the message into a preset service queue, and then comprising: 检测所述消息的标识存入所述服务队列的时间是否达到设定时长,若是,返回所述消息接收失败的响应,以重新接收所述消息。Detect whether the time for storing the identifier of the message in the service queue reaches a set duration, and if so, return a response that the message fails to be received, so as to receive the message again. 4.根据权利要求3所述的数据库缓存数据的刷新方法,其特征在于,所述接收主库数据更新的消息,包括:4. the refresh method of database cache data according to claim 3, is characterized in that, the message that described receiving master library data update comprises: 接收预设的消息队列发送的主库数据更新的消息,所述消息队列实时获取主库数据更新的消息;Receive the message that the preset message queue sends the main library data update, and the message queue obtains the message of the main library data update in real time; 所述根据所述消息执行缓存数据的刷新操作,之后还包括,The executing the refresh operation of cached data according to the message further includes, 向所述消息队列返回所述消息接收成功的响应;Returning a response that the message is received successfully to the message queue; 所述返回所述消息接收失败的响应,以重新接收所述消息,包括,The returning a response of failure to receive the message to re-receive the message includes, 向所述消息队列返回所述消息接收失败的响应,并接收所述消息队列重新发送的所述消息。Returning a response that the message fails to be received to the message queue, and receiving the message resent by the message queue. 5.根据权利要求4所述的数据库缓存数据的刷新方法,其特征在于,所述消息队列为RabbitMQ队列,所述设定时长为120秒。5. The method for refreshing database cache data according to claim 4, wherein the message queue is a RabbitMQ queue, and the set duration is 120 seconds. 6.数据库缓存数据的刷新系统,其特征在于,包括:6. The refreshing system of database cache data is characterized in that, comprising: 消息接收模块,用于接收主库数据更新的消息,所述消息包含本次更新的时间以及更新的数据对象,记所述时间为主库更新时间;The message receiving module is used to receive the message of master database data update, and said message includes the time of this update and the updated data object, and records said time as master database update time; 消息比较模块,用于获取从库中相应数据对象的最近更新时间,记为从库更新时间,比较所述从库更新时间和所述主库更新时间;The message comparison module is used to obtain the latest update time of the corresponding data object in the slave library, which is recorded as the update time of the slave library, and compares the update time of the slave library with the update time of the main library; 数据刷新模块,用于若所述从库更新时间大于等于所述主库更新时间,根据所述消息执行缓存数据的刷新操作。A data refresh module, configured to perform a cache data refresh operation according to the message if the update time of the slave library is greater than or equal to the update time of the master library. 7.根据权利要求6所述的数据库缓存数据的刷新系统,其特征在于,7. The refreshing system of database cache data according to claim 6, is characterized in that, 所述数据刷新模块,还用于若所述从库更新时间小于所述主库更新时间,将所述消息的标识存入预设的服务队列。The data refreshing module is further configured to store the identifier of the message into a preset service queue if the update time of the slave database is less than the update time of the master database. 8.根据权利要求7所述的数据库缓存数据的刷新系统,其特征在于,8. The refreshing system of database cache data according to claim 7, is characterized in that, 所述消息接收模块,还用于检测所述消息的标识存入所述服务队列的时间是否达到设定时长,若是,返回所述消息接收失败的响应,以重新接收所述消息。The message receiving module is further configured to detect whether the time for storing the identifier of the message in the service queue reaches a set duration, and if so, return a response that the message fails to be received, so as to receive the message again. 9.根据权利要求8所述的数据库缓存数据的刷新系统,其特征在于,还包括,9. The system for refreshing database cache data according to claim 8, further comprising: 消息中转模块,用于通过预设的消息队列实时获取主库数据更新的消息;The message transfer module is used to obtain real-time data update messages of the main database through the preset message queue; 所述消息接收模块包括:The message receiving module includes: 接收子模块,用于接收所述消息中转模块发送的主库数据更新的消息;The receiving sub-module is used to receive the message of master database data update sent by the message transfer module; 第一响应子模块,用于在根据所述消息执行缓存数据的刷新操作之后,向所述消息中转模块返回所述消息接收成功的响应;The first response sub-module is configured to return a response that the message is received successfully to the message transfer module after the cache data refresh operation is performed according to the message; 第二响应子模块,用于若所述消息的标识存入所述服务队列的时间达到设定时长,向所述消息中转模块返回所述消息接收失败的响应,并接收所述消息中转模块重新发送的所述消息。The second response sub-module is used to return a response that the message fails to be received to the message transfer module if the time for the message identifier to be stored in the service queue reaches the set duration, and receive the message transfer module again The message sent. 10.根据权利要求9所述的数据库缓存数据的刷新系统,其特征在于,所述消息队列为RabbitMQ队列,所述设定时长为120秒。10. The system for refreshing database cached data according to claim 9, wherein the message queue is a RabbitMQ queue, and the set duration is 120 seconds.
CN201510944487.3A 2015-12-15 2015-12-15 Database cache data refresh method and system Active CN105574158B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510944487.3A CN105574158B (en) 2015-12-15 2015-12-15 Database cache data refresh method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510944487.3A CN105574158B (en) 2015-12-15 2015-12-15 Database cache data refresh method and system

Publications (2)

Publication Number Publication Date
CN105574158A true CN105574158A (en) 2016-05-11
CN105574158B CN105574158B (en) 2019-03-12

Family

ID=55884289

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510944487.3A Active CN105574158B (en) 2015-12-15 2015-12-15 Database cache data refresh method and system

Country Status (1)

Country Link
CN (1) CN105574158B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106202436A (en) * 2016-07-14 2016-12-07 上海超橙科技有限公司 A kind of information updating method and equipment
CN107943958A (en) * 2017-11-24 2018-04-20 税友软件集团股份有限公司 A kind of Individual Income Tax master data sharing method and system
CN108153794A (en) * 2016-12-02 2018-06-12 阿里巴巴集团控股有限公司 Page cache method for refreshing data, apparatus and system
CN113434525A (en) * 2021-06-24 2021-09-24 青岛海尔科技有限公司 Cache data updating method and device, storage medium and electronic device
CN113688146A (en) * 2021-08-23 2021-11-23 猪八戒股份有限公司 Distributed architecture high-concurrency order search engine data refreshing method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1520562A (en) * 2001-06-30 2004-08-11 国际商业机器公司 System and method for caching mechanism for central synchronization
CN1677340A (en) * 2004-03-29 2005-10-05 联想(北京)有限公司 Message service device and method for console of machine group mornitoring-controlling system
CN101308513A (en) * 2008-06-27 2008-11-19 福建星网锐捷网络有限公司 Distributed system cache data synchronous configuration method and apparatus
CN102023973A (en) * 2009-09-14 2011-04-20 中国移动通信集团公司 Method, device and system for synchronizing database with application cache server
CN103870977A (en) * 2012-12-18 2014-06-18 风网科技(北京)有限公司 Method and system thereof for data synchronizing of mobile advertising platform

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1520562A (en) * 2001-06-30 2004-08-11 国际商业机器公司 System and method for caching mechanism for central synchronization
CN1677340A (en) * 2004-03-29 2005-10-05 联想(北京)有限公司 Message service device and method for console of machine group mornitoring-controlling system
CN101308513A (en) * 2008-06-27 2008-11-19 福建星网锐捷网络有限公司 Distributed system cache data synchronous configuration method and apparatus
CN102023973A (en) * 2009-09-14 2011-04-20 中国移动通信集团公司 Method, device and system for synchronizing database with application cache server
CN103870977A (en) * 2012-12-18 2014-06-18 风网科技(北京)有限公司 Method and system thereof for data synchronizing of mobile advertising platform

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106202436A (en) * 2016-07-14 2016-12-07 上海超橙科技有限公司 A kind of information updating method and equipment
CN108153794A (en) * 2016-12-02 2018-06-12 阿里巴巴集团控股有限公司 Page cache method for refreshing data, apparatus and system
CN108153794B (en) * 2016-12-02 2022-06-07 阿里巴巴集团控股有限公司 Page cache data refreshing method, device and system
CN107943958A (en) * 2017-11-24 2018-04-20 税友软件集团股份有限公司 A kind of Individual Income Tax master data sharing method and system
CN113434525A (en) * 2021-06-24 2021-09-24 青岛海尔科技有限公司 Cache data updating method and device, storage medium and electronic device
CN113434525B (en) * 2021-06-24 2023-06-09 青岛海尔科技有限公司 Cache data updating method and device, storage medium and electronic device
CN113688146A (en) * 2021-08-23 2021-11-23 猪八戒股份有限公司 Distributed architecture high-concurrency order search engine data refreshing method and system

Also Published As

Publication number Publication date
CN105574158B (en) 2019-03-12

Similar Documents

Publication Publication Date Title
JP6745884B2 (en) Data synchronization method, device and system
CN105574158A (en) Refreshing method and system of database caching data
US10860395B2 (en) Event processing method, non-transitory computer-readable storage medium for storing program
US20200341862A1 (en) Data backup method and apparatus
WO2015188501A1 (en) Configuration file updating method, device, system and computer storage medium
CN104881494A (en) Method, device and system for performing data synchronization with Redis server
CN111159233B (en) Distributed caching method, system, computer equipment and storage medium
CN112527879B (en) Kafka-based real-time data extraction method and related equipment
TWI738722B (en) Application program interface deadlock monitoring method and device
US20130041937A1 (en) Pre-fetching data
CN106789741B (en) Consumption method and device for message queue
CN104750596B (en) A kind of alarm information processing method and service subsystem
CN105824846B (en) Data migration method and device
KR102151302B1 (en) Remote data synchronization method and device for database
WO2020025049A1 (en) Data synchronization method and apparatus, database host, and storage medium
CN111324668B (en) Database data synchronous processing method, device and storage medium
CN111694645B (en) Task processing method and related device in distributed task scheduling system
EP2995028B1 (en) Tuple recovery
US10938633B2 (en) Facilitating resilient and fault tolerant asynchronous messaging
US11755618B2 (en) Stateless stream handling and resharding
CN106033422A (en) A database operation control method, device and system
US12197447B2 (en) Stateless stream handling and resharding
TW201600975A (en) Processing tasks in a distributed system
WO2016177284A1 (en) Domain name resolution method and device
CN108200157B (en) Log synchronization method and device for triggering rollback by master node

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20220111

Address after: 510000 Room 601, 128 Dingxin Road, Haizhu District, Guangzhou City, Guangdong Province (office only)

Patentee after: Vipshop (Guangzhou) Software Co.,Ltd.

Address before: 510370 self compiled buildings 1-5, No. 20, Huahai street, Fangcun, Liwan District, Guangzhou, Guangdong

Patentee before: GUANGZHOU PINWEI SOFTWARE Co.,Ltd.

TR01 Transfer of patent right