TW201828082A - Data transmission method and device solving the technical problem of frequent failures when full volume of data is updated - Google Patents

Data transmission method and device solving the technical problem of frequent failures when full volume of data is updated Download PDF

Info

Publication number
TW201828082A
TW201828082A TW106102231A TW106102231A TW201828082A TW 201828082 A TW201828082 A TW 201828082A TW 106102231 A TW106102231 A TW 106102231A TW 106102231 A TW106102231 A TW 106102231A TW 201828082 A TW201828082 A TW 201828082A
Authority
TW
Taiwan
Prior art keywords
data
value
timestamp
time stamp
time
Prior art date
Application number
TW106102231A
Other languages
Chinese (zh)
Other versions
TWI738709B (en
Inventor
程峰
Original Assignee
阿里巴巴集團服務有限公司
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 阿里巴巴集團服務有限公司 filed Critical 阿里巴巴集團服務有限公司
Priority to TW106102231A priority Critical patent/TWI738709B/en
Publication of TW201828082A publication Critical patent/TW201828082A/en
Application granted granted Critical
Publication of TWI738709B publication Critical patent/TWI738709B/en

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention discloses a data transmission method and device. The method comprises: receiving periodically, by a first device, a request message from a second device, wherein the request message carries a time stamp corresponding to the request message received this time; determining, by the first device, whether the value of the time stamp is less than a preset threshold value; wherein when the value of the time stamp is less than the preset threshold value, the first device synchronizes sliced data corresponding to the time stamp into the second device according to the corresponding relationship between the time stamp and the sliced data cached locally by the first device, wherein the sliced data is obtained by slicing the full volume of data recorded by the first device. The present invention solves the technical problem of frequent failures when the system updates full volume of data.

Description

資料傳輸方法及裝置  Data transmission method and device  

本發明關於互聯網技術領域,具體而言,關於一種資料傳輸方法及裝置。 The present invention relates to the field of Internet technologies, and in particular, to a data transmission method and apparatus.

隨著網路技術的發展,有些不法分子可能借助於網路平台,發佈一些危害社會的資訊內容,比如涉黃、涉賭、涉暴以及涉恐內容等,這將給社會帶來不利的影響,因而,可能需要對網路內容進行監控,當發現這些不利資訊時,可以對其進行遮罩,以儘量減少該不利資訊的傳播。 With the development of network technology, some lawless elements may use the Internet platform to release information content that is harmful to society, such as pornography, gambling, violence, and terrorism, which will adversely affect society. Therefore, it may be necessary to monitor the content of the network, and when such unfavorable information is found, it may be masked to minimize the spread of the unfavorable information.

在相關技術中,網路內容監控系統,一般包括兩個系統(可以表現為兩個設備),比如,系統A和系統B,系統B需要同步系統A中的資料,在相關技術中,每次同步需要同步所有的資料資訊,這樣可能會導致資料庫讀超時,或者而當系統A與系統B處於不同網路環境時、系統A提供的全量資料過大、系統B記憶體使用過多時,會造成系統B從系統A全量更新資料頻繁失敗。 In the related art, the network content monitoring system generally includes two systems (which can be represented as two devices), for example, system A and system B, and system B needs to synchronize the data in system A, in the related art, each time Synchronization needs to synchronize all data information, which may cause the database to read timeout, or when system A and system B are in different network environments, system A provides too much data, and system B memory is used too much, Causes System B to fail to update data from System A in full.

針對上述的問題,目前尚未提出有效的解決方案。 In response to the above problems, no effective solution has been proposed yet.

本發明實施例提供了一種資料傳輸方法及裝置,以至少解決系統之間進行全量更新資料時頻繁失敗的技術問題。 Embodiments of the present invention provide a data transmission method and apparatus, so as to at least solve the technical problem of frequent failures when performing full update of data between systems.

根據本發明實施例的一個方面,提供了一種資料傳輸方法,包括:第一設備定時接收來自第二設備的請求訊息,其中,該請求訊息中攜帶有與本次接收的請求訊息對應的時間戳記;第一設備判斷時間戳記的取值是否小於預設閾值;在時間戳記的取值小於預設閾值時,第一設備按照時間戳記與第一設備在本地快取的分片資料的對應關係,將與時間戳記對應的分片資料同步至第二設備,其中,分片資料為對第一設備記錄的全量資料進行分片得到。 According to an aspect of the embodiments of the present invention, a data transmission method is provided, including: a first device periodically receiving a request message from a second device, where the request message carries a timestamp corresponding to the request message received this time The first device determines whether the value of the timestamp is less than a preset threshold; when the value of the timestamp is less than the preset threshold, the correspondence between the first device and the fragmented data of the first device in the local device according to the timestamp, The fragment data corresponding to the time stamp is synchronized to the second device, wherein the fragment data is obtained by fragmenting the full amount of data recorded by the first device.

根據本發明實施例的另一方面,還提供了一種資料傳輸方法,包括:第二設備向第一設備發送請求訊息,其中,該請求訊息中攜帶有與請求訊息對應的時間戳記;在時間戳記的取值小於預設閾值的情況下,第二設備接收第一設備發送的分片資料;其中,分片資料是與時間戳記對應的在第一設備本地快取的分片資料,上述分片資料為對第一設備記錄的全量資料進行分片得到。 According to another aspect of the present invention, a data transmission method is further provided, including: the second device sends a request message to the first device, where the request message carries a timestamp corresponding to the request message; The second device receives the fragment data sent by the first device, where the fragment data is the fragment data locally cached by the first device corresponding to the time stamp, and the fragment is the fragmented data. The data is obtained by fragmenting the full amount of data recorded by the first device.

根據本發明實施例的另一方面,還提供了一種資料傳輸裝置,應用於第一設備,包括:接收模組,用於定時接收來自第二設備的請求訊息,其中,該請求訊息中攜帶有與本次接收的請求訊息對應的時間戳記;第一判斷模組, 用於判斷時間戳記的取值是否小於預設閾值;第一同步模組,用於在時間戳記的取值小於預設閾值時,按照時間戳記與第一設備在本地快取的分片資料的對應關係,將與時間戳記對應的分片資料同步至第二設備,其中,分片資料為對第一設備記錄的全量資料進行分片得到。 According to another aspect of the present invention, a data transmission apparatus is further provided, which is applied to a first device, and includes: a receiving module, configured to periodically receive a request message from a second device, where the request message carries a timestamp corresponding to the received request message; the first determining module is configured to determine whether the value of the timestamp is less than a preset threshold; the first synchronization module is configured to: the value of the timestamp is less than a preset threshold And synchronizing the fragment data corresponding to the time stamp to the second device according to the correspondence between the time stamp and the fragmented data of the first device in the local cache, wherein the fragment data is the full amount of data recorded by the first device Fragmentation is obtained.

根據本發明實施例的另一方面,還提供了一種資料傳輸裝置,應用於第二設備,包括:發送模組,用於向第一設備發送請求訊息,其中,該請求訊息中攜帶有與請求訊息對應的時間戳記;第一接收模組,用於在時間戳記的取值小於預設閾值的情況下,接收第一設備發送的分片資料;其中,分片資料是與時間戳記對應的在第一設備本地快取的分片資料,上述分片資料為第一設備記錄的全量資料進行分片得到。 According to another aspect of the present invention, a data transmission apparatus is further provided, which is applied to a second device, and includes: a sending module, configured to send a request message to the first device, where the request message carries a request and a request a time stamp corresponding to the message; the first receiving module is configured to receive the fragment data sent by the first device if the value of the time stamp is less than a preset threshold; wherein the fragment data is corresponding to the time stamp The fragment data of the first device locally cached, and the fragment data is obtained by fragmenting the full amount of data recorded by the first device.

在本發明實施例中,採用第一設備將時間戳記對應的第一設備在本地快取的分片資料同步到第二設備,其中,所述分片資料為對所述第一設備記錄的全量資料進行分片得到的方式,即透過將全量資料進行快取分片的方式,然後根據接收的請求訊息中的時間戳記,將該時間戳記對應的快取中的分片資料依次同步到第二設備的方式,降低了資料讀取的壓力,進而解決了系統之間進行全量更新資料時頻繁失敗的技術問題,提高了資料傳輸的效率。 In the embodiment of the present invention, the first device is used to synchronize the locally cached fragment data to the second device, where the fragment data is the full amount recorded by the first device. The method of obtaining the data by sharding, that is, by sharding the full amount of data, and then sequentially synchronizing the shard data in the cache corresponding to the time stamp according to the time stamp in the received request message to the second The way of the device reduces the pressure of data reading, thereby solving the technical problem of frequent failures when the system updates the data in full, and improves the efficiency of data transmission.

10‧‧‧電腦終端 10‧‧‧Computer terminal

102‧‧‧處理器 102‧‧‧Processor

104‧‧‧記憶體 104‧‧‧ memory

106‧‧‧傳輸模組 106‧‧‧Transmission module

S202,S204,S206‧‧‧方法步驟 S202, S204, S206‧‧‧ method steps

S302‧‧‧方法步驟 S302‧‧‧ Method steps

S402,S404,S406,S408,S410,S412,S414,S416,S418,S420,S422,S424,S426‧‧‧方法步驟 S402, S404, S406, S408, S410, S412, S414, S416, S418, S420, S422, S424, S426‧‧ method steps

S501-S514‧‧‧方法步驟 S501-S514‧‧‧ method steps

S601,S604‧‧‧方法步驟 S601, S604‧‧‧ method steps

S702‧‧‧方法步驟 S702‧‧‧ Method steps

80‧‧‧接收模組 80‧‧‧ receiving module

82‧‧‧第一判斷模組 82‧‧‧First Judgment Module

84‧‧‧第一同步模組 84‧‧‧First Synchronous Module

90‧‧‧第二判斷模組 90‧‧‧Second judgment module

100‧‧‧快取模組 100‧‧‧Cache Module

1001‧‧‧判斷單元 1001‧‧‧judging unit

1002‧‧‧第一讀取單元 1002‧‧‧First reading unit

1003‧‧‧第二讀取單元 1003‧‧‧second reading unit

1004‧‧‧暫存單元 1004‧‧‧ temporary storage unit

1202‧‧‧發送模組 1202‧‧‧Transmission module

1204‧‧‧第一接收模組 1204‧‧‧First Receiver Module

1402‧‧‧第二接收模組 1402‧‧‧second receiving module

1502‧‧‧處理器 1502‧‧‧ processor

1506‧‧‧記憶體 1506‧‧‧ memory

1508‧‧‧傳輸裝置 1508‧‧‧Transportation device

此處所說明的附圖用來提供對本發明的進一步理解, 構成本申請的一部分,本發明的示意性實施例及其說明用於解釋本發明,並不構成對本發明的不當限定。在附圖中:圖1是本發明實施例的一種資料傳輸方法的電腦終端的硬體結構方塊圖;圖2是根據本發明實施例1的資料傳輸方法的流程圖一;圖3是根據本發明實施例1的資料傳輸方法的流程圖二;圖4是根據本發明可選實施例的第一設備分片快取全量資料的流程示意圖;圖5是根據本發明可選實施例的資料傳輸方法的流程示意圖;圖6是根據本發明實施例2的資料傳輸方法的流程圖一;圖7是根據本發明實施例2的資料傳輸方法的流程圖二;圖8是根據本發明實施例3的資料傳輸裝置的結構方塊圖一;圖9是根據本發明實施例3的資料傳輸裝置的結構方塊圖二;圖10是根據本發明實施例3的資料傳輸裝置的結構方塊圖三;圖11是根據本發明實施例3的資料傳輸裝置的結構 方塊圖四;圖12是根據本發明實施例4的資料傳輸裝置的結構方塊圖一;圖13是根據本發明實施例4的資料傳輸裝置的結構方塊圖二;圖14是根據本發明實施例4的資料傳輸裝置的結構方塊圖三;圖15是根據本發明實施例的一種電腦終端的結構方塊圖。 The drawings are intended to provide a further understanding of the invention, and are intended to be a part of the invention. 1 is a block diagram of a hardware structure of a computer terminal according to a data transmission method according to an embodiment of the present invention; FIG. 2 is a flow chart 1 of a data transmission method according to Embodiment 1 of the present invention; FIG. 4 is a schematic flowchart of a first device fragmentation cache full amount of data according to an alternative embodiment of the present invention; FIG. 5 is a data transmission according to an alternative embodiment of the present invention. FIG. 6 is a flowchart 1 of a data transmission method according to Embodiment 2 of the present invention; FIG. 7 is a flowchart 2 of a data transmission method according to Embodiment 2 of the present invention; FIG. 8 is a flowchart 3 according to Embodiment 1 of the present invention; FIG. 9 is a block diagram of a data transmission device according to Embodiment 3 of the present invention; FIG. 10 is a block diagram of a data transmission device according to Embodiment 3 of the present invention; FIG. 4 is a block diagram of a data transmission device according to Embodiment 3 of the present invention; FIG. 12 is a block diagram of a data transmission device according to Embodiment 4 of the present invention; FIG. 13 is a data according to Embodiment 4 of the present invention; FIG. 14 is a block diagram showing the structure of a data transmission apparatus according to Embodiment 4 of the present invention; and FIG. 15 is a block diagram showing the structure of a computer terminal according to an embodiment of the present invention.

為了使本技術領域的人員更好地理解本發明方案,下面將結合本發明實施例中的附圖,對本發明實施例中的技術方案進行清楚、完整地描述,顯然,所描述的實施例僅僅是本發明一部分的實施例,而不是全部的實施例。基於本發明中的實施例,本領域普通技術人員在沒有做出創造性勞動前提下所獲得的所有其他實施例,都應當屬於本發明保護的範圍。 The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is an embodiment of the invention, but not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of the present invention.

需要說明的是,本發明的說明書和申請專利範圍及上述附圖中的術語“第一”、“第二”等是用於區別類似的物件,而不必用於描述特定的順序或先後次序。應該理解這樣使用的資料在適當情況下可以互換,以便這裡描述的本發明的實施例能夠以除了在這裡圖示或描述的那些以外的順序實施。此外,術語“包括”和“具有”以及他們的 任何變形,意圖在於覆蓋不排他的包含,例如,包含了一系列步驟或單元的過程、方法、系統、產品或設備不必限於清楚地列出的那些步驟或單元,而是可包括沒有清楚地列出的或對於這些過程、方法、產品或設備固有的其它步驟或單元。 It should be noted that the terms "first", "second" and the like in the specification and claims of the present invention are used to distinguish similar items, and are not necessarily used to describe a specific order or order. It is to be understood that the materials so used are interchangeable, where appropriate, so that the embodiments of the invention described herein can be carried out in a sequence other than those illustrated or described herein. In addition, the terms "comprises" and "comprises" and "the" and "the" are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or device that comprises a series of steps or units is not necessarily limited to Those steps or units may include other steps or units not explicitly listed or inherent to such processes, methods, products or devices.

在相關技術中,在網路內容監控和遮罩領域中,設備之間資料傳輸的主要步驟如下:1. 當第二設備啟動時,第一次從第一設備讀取統一資源定位符url/功能變數名稱阻斷記錄;2. 該次讀取統一資源定位符url/功能變數名稱阻斷記錄是全量更新的方式,第二設備發送的請求會帶時間戳記參數,值為0;3. 第一設備收到時間戳記參數值為0的請求後,會將目前資料庫中所有url/功能變數名稱阻斷記錄讀出,並加上目前時間值(精確到分鐘),一併返回給第二設備;4. 第二設備收到全量url/功能變數名稱阻斷記錄後,清空系統內的所有阻斷記錄,改為使用收到的全量url/功能變數名稱阻斷記錄;5. 1分鐘後,第二設備判斷目前時間是否整點或半點。如果是,則執行2;如果不是,則發送請求給第一設備,帶時間戳記參數是3中第一設備返回的時間值;6. 第一設備收到時間戳記參數值不為0的請求後,會將資料庫中從時間戳記指定時間到目前時間的變化資料讀出,並加上目前時間值(精確到分鐘),一併返回給第 二設備;7. 第二設備收到增量url/功能變數名稱阻斷記錄後,對系統內的所有阻斷記錄做更新;然後執行5。 In the related art, in the field of network content monitoring and masking, the main steps of data transmission between devices are as follows: 1. When the second device is started, the uniform resource locator url/ is read from the first device for the first time. The function variable name block record; 2. The read uniform resource locator url/function variable name block record is a full update mode, the second device sends a request with a time stamp parameter, the value is 0; After a device receives a request with a timestamp parameter value of 0, it will read out all the url/function variable name blocking records in the current database, and add the current time value (accurate to the minute) and return it to the second. Device; 4. After receiving the full url/function variable name blocking record, the second device clears all blocking records in the system, and uses the full url/function variable name received to block the record; 5. 1 minute later The second device determines whether the current time is a whole point or a half point. If yes, execute 2; if not, send a request to the first device, the time stamped parameter is the time value returned by the first device in 3; 6. the first device receives the request after the timestamp parameter value is not 0 , the data in the database from the time stamp specified time to the current time is read out, and the current time value (accurate to the minute) is added to the second device; 7. The second device receives the incremental url / Function variable name After blocking the record, update all blocked records in the system; then execute 5.

當上述第一設備的url/功能變數名稱阻斷資料到達千萬級別時,會出現如下問題:第一設備即時從資料庫全量讀取url/功能變數名稱阻斷資料時,會造成讀資料庫超時;當第一設備與第二設備處於不同網路環境,網路鏈路不穩定;千萬級別的全量url/功能變數名稱阻斷記錄會延長資料傳輸時間,經常造成全量資料傳輸失敗;第二設備伺服器記憶體有限,當自身記憶體使用較多時,全量url/功能變數名稱阻斷記錄的換入換出,經常造成記憶體報警。 When the url/function variable name blocking data of the first device reaches the tens of millions of levels, the following problem occurs: when the first device reads the url/function variable name blocking data from the database in full, the reading database is caused. Timeout; when the first device and the second device are in different network environments, the network link is unstable; the url/function variable name blocking record of 10 million levels will prolong the data transmission time, often causing the full data transmission failure; The memory of the second device server is limited. When the memory of the second device is used more, the full url/function variable name blocks the exchange of the record, which often causes the memory alarm.

為了方便理解本發明,以下對本發明實施例中所關於的術語進行簡單解釋:增量同步方式:系統A維護一批即時變化的資料,系統B需要使用系統A維護的這批資料;當系統B訪問系統A讀取資料時,系統A只將系統B上次訪問與這次訪問之間的資料變化量發送給系統B,這種資料同步方式叫做增量同步方式。 In order to facilitate the understanding of the present invention, the following terms are briefly explained in the embodiments of the present invention: incremental synchronization mode: system A maintains a batch of data that changes instantaneously, system B needs to use the batch of data maintained by system A; when system B When accessing system A to read data, system A only sends the amount of data change between system B's last access and this visit to system B. This data synchronization method is called incremental synchronization mode.

全量同步方式:系統A維護一批即時變化的資料,系統B需要使用系統A維護的這批資料;當系統B訪問系統A讀取資料時,系統A將目前所有資料發送給系統B,這種資料同步方式叫做全量同步方式。 Full-scale synchronization mode: System A maintains a batch of data that changes in real time. System B needs to use the batch of data maintained by System A. When System B accesses System A to read data, System A sends all current data to System B. The data synchronization method is called the full amount synchronization method.

本發明實施例對第一設備與第二設備的阻斷記錄的全 量更新過程做了優化,使用增量同步方式來類比全量同步方式,以避免出現以上問題。以下結合具體實施例詳細說明。 The embodiment of the present invention optimizes the full update process of the blocking records of the first device and the second device, and uses the incremental synchronization mode to analogize the full amount of synchronization to avoid the above problems. The details are described below in conjunction with specific embodiments.

實施例1Example 1

根據本發明實施例,還提供了一種資料傳輸的方法實施例,需要說明的是,在附圖的流程圖示出的步驟可以在諸如一組電腦可執行指令的電腦系統中執行,並且,雖然在流程圖中示出了邏輯順序,但是在某些情況下,可以以不同於此處的循序執行所示出或描述的步驟。 In accordance with an embodiment of the present invention, there is also provided an embodiment of a method of data transfer, it being noted that the steps illustrated in the flowchart of the accompanying drawings may be performed in a computer system such as a set of computer executable instructions, and, although The logical order is shown in the flowchart, but in some cases the steps shown or described may be performed in a different order than here.

本申請實施例1所提供的方法實施例可以在行動終端、電腦終端或者類似的運算裝置中執行。以運行在電腦終端上為例,圖1是本發明實施例的一種資料傳輸方法的電腦終端的硬體結構方塊圖。如圖1所示,電腦終端10可以包括一個或多個(圖中僅示出一個)處理器102(處理器102可以包括但不限於微處理器MCU或可程式設計邏輯器件FPGA等的處理裝置)、用於儲存資料的記憶體104、以及用於通信功能的傳輸模組106。本領域普通技術人員可以理解,圖1所示的結構僅為示意,其並不對上述電子裝置的結構造成限定。例如,電腦終端10還可包括比圖1中所示更多或者更少的元件,或者具有與圖1所示不同的配置。 The method embodiment provided by Embodiment 1 of the present application can be executed in a mobile terminal, a computer terminal or the like. Taking a computer terminal as an example, FIG. 1 is a hardware block diagram of a computer terminal of a data transmission method according to an embodiment of the present invention. As shown in FIG. 1, computer terminal 10 may include one or more (only one shown) processor 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc. ), a memory 104 for storing data, and a transmission module 106 for communication functions. It will be understood by those skilled in the art that the structure shown in FIG. 1 is merely illustrative and does not limit the structure of the above electronic device. For example, computer terminal 10 may also include more or fewer components than those shown in FIG. 1, or have a different configuration than that shown in FIG.

記憶體104可用於儲存應用軟體的軟體程式以及模組,如本發明實施例中的資料傳輸方法對應的程式指令/ 模組,處理器102透過運行儲存在記憶體104內的軟體程式以及模組,從而執行各種功能應用以及資料處理,即實現上述的應用程式的資料傳輸方法。記憶體104可包括高速隨機記憶體,還可包括非易失性記憶體,如一個或者多個磁性儲存裝置、快閃記憶體、或者其他非易失性固態記憶體。在一些實例中,記憶體104可進一步包括相對於處理器102遠端設定的記憶體,這些遠端存放器可以透過網路連接至電腦終端10。上述網路的實例包括但不限於互聯網、企業內部網、局域網、行動通信網及其組合。 The memory 104 can be used to store software programs and modules of the application software, such as the program instructions/modules corresponding to the data transmission method in the embodiment of the present invention, and the processor 102 runs the software programs and modules stored in the memory 104. , thereby performing various functional applications and data processing, that is, implementing the data transmission method of the above application. Memory 104 may include high speed random memory and may also include non-volatile memory such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory. In some examples, memory 104 can further include memory that is remotely located relative to processor 102, which can be connected to computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

傳輸模組106用於經由一個網路接收或者發送資料。上述的網路具體實例可包括電腦終端10的通信供應商提供的無線網路。在一個實例中,傳輸模組106包括一個網路介面卡(Network Interface Controller,NIC),其可透過基站與其他網路設備相連從而可與互聯網進行通訊。在一個實例中,傳輸模組106可以為射頻(Radio Frequency,RF)模組,其用於透過無線方式與互聯網進行通訊。 The transmission module 106 is configured to receive or transmit data via a network. The above specific network example may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transport module 106 includes a network interface controller (NIC) that can be connected to other network devices through the base station to communicate with the Internet. In one example, the transmission module 106 can be a radio frequency (RF) module for communicating wirelessly with the Internet.

在上述運行環境下,本申請提供了如圖2所示的資料傳輸方法。圖2是根據本發明實施例1的資料傳輸方法的流程圖一,如圖2所示,該方法包括:步驟S202,第一設備定時接收來自第二設備的請求訊息,其中,該請求訊息中攜帶有與本次接收的請求訊息對應的時間戳記;可選地,第一設備可以為上述運行環境中的電腦終端 10,透過上述電腦終端10來完成第一設備的功能進而實現本實施例中的資料傳輸方法。 In the above operating environment, the present application provides a data transmission method as shown in FIG. 2. 2 is a flowchart 1 of a data transmission method according to Embodiment 1 of the present invention. As shown in FIG. 2, the method includes: Step S202: A first device periodically receives a request message from a second device, where the request message is Carrying a timestamp corresponding to the request message received this time; optionally, the first device may be the computer terminal 10 in the above-mentioned operating environment, and the function of the first device is completed through the computer terminal 10 to implement the embodiment. Data transmission method.

需要說明的是,定時接收來自第二設備的請求訊息中的定時可以是按照實際情況進行設定,兩次接收的請求訊息的時間間隔可以是固定的,比如設定每隔一分鐘接收一次請求訊息,也可以是不固定的,比如一分鐘後接收第二次請求訊息,再過三分鐘後接收第三次請求訊息,具體的可以根據實際情況進行設定。 It should be noted that the timing of periodically receiving the request message from the second device may be set according to actual conditions, and the time interval of the received request message may be fixed, for example, setting the request message every other minute. It can also be unfixed. For example, after receiving the second request message in one minute, and receiving the third request message after three minutes, the specific request can be set according to the actual situation.

步驟S204,第一設備判斷時間戳記的取值是否小於預設閾值;需要說明的是,上述第一設備和第二設備可以表現為兩個物理實體,也可以表現為兩個應用,但不限於此。上述時間戳記的取值可以是單純的序號比如阿拉伯數字,也可以是時間值,但不限於此。 In step S204, the first device determines whether the value of the timestamp is less than a preset threshold. The first device and the second device may be represented by two physical entities, but may be represented by two applications, but are not limited to this. The value of the above time stamp may be a simple serial number such as an Arabic numeral, or may be a time value, but is not limited thereto.

上述時間戳記的取值可以是指定值,用於指示讀取第一設備中的全量資料;在一個可選的實施例中,上述指定值可以是0,即在請求訊息中攜帶的時間戳記的取值為0時,指示第二設備應當讀第一設備的全量資料。 The value of the timestamp may be a specified value for indicating that the full amount of data in the first device is read; in an optional embodiment, the specified value may be 0, that is, the timestamp carried in the request message. A value of 0 indicates that the second device should read the full amount of data of the first device.

在一個可選實施例中,在步驟S204之前,需要判斷上述時間戳記的取值是否為上述指定值,以及在判斷結果為是時,觸發將與該時間戳記對應的分片資料同步至所述第二設備。在時間戳記的取值為上述指定值的情況下,可以觸發第一設備開始將全量資料中的第一個分片資料同步到第二設備。 In an optional embodiment, before step S204, it is required to determine whether the value of the time stamp is the specified value, and when the determination result is yes, trigger to synchronize the fragment data corresponding to the time stamp to the Second device. In the case that the value of the time stamp is the above specified value, the first device may be triggered to start synchronizing the first fragment data in the full amount of data to the second device.

步驟S206,在時間戳記的取值小於預設閾值時,第一設備按照時間戳記與第一設備在本地快取的分片資料的對應關係,將與時間戳記對應的分片資料同步至第二設備,其中,分片資料為對第一設備記錄的全量資料進行分片得到。 Step S206: When the value of the timestamp is less than the preset threshold, the first device synchronizes the fragmentation data corresponding to the timestamp to the second according to the correspondence between the timestamp and the fragmented data of the first device in the local cache. The device, wherein the fragmentation data is obtained by fragmenting the full amount of data recorded by the first device.

需要說明的是,上述預設閾值可以是對上述全量資料進行分片後得到的分片數量,當然也可以是其他的值,一般該預設閾值可設定為小於10;上述全量資料可以是針對統一資源定位符url的阻斷記錄,也可以是針對功能變數名稱的阻斷記錄,也可以是兩者的組合,並不限於此。 It should be noted that the preset threshold may be a number of fragments obtained by fragmenting the full amount of data, and may be other values. Generally, the preset threshold may be set to be less than 10; The blocking record of the uniform resource locator url may also be a blocking record for the function variable name, or a combination of the two, and is not limited thereto.

上述分片資料可以透過以下方式在第一設備中得到:將第一設備的資料庫中與第一索引n對應的分片資料,寫入本地快取,並將n-1作為分片資料在第一設備的本地快取中的索引,其中,n小於或者等於對全量資料進行分片後得到的所有分片資料的總數量N,n、N均為正整數。在一個可選實施例中,將第一設備的資料庫中與第一索引n對應的分片資料,寫入本地快取,並將n-1作為分片資料在第一設備的本地快取中的索引具體為:第一設備判斷n是否小於N;在n小於N的情況下,第一設備從資料庫中讀取n對應的分片資料,並在n對應的分片資料上附上值為n的時間戳記;在n等於N的情況下,第一設備從資料庫中讀取與n對應的分片資料,並在與n對應的分片資料上附上值為指定時刻的時間戳記;其中,該指定時刻為第二設備上一次訪問第一設備的時刻;第一設備將與n對 應的分片資料寫入本地快取,並將n-1作為分片資料在本地快取中的索引。 The above fragmentation data can be obtained in the first device by: writing the fragment data corresponding to the first index n in the database of the first device to the local cache, and using n-1 as the fragment data. An index in the local cache of the first device, where n is less than or equal to the total number N, n, and N of all the fragment data obtained after fragmenting the full amount of data. In an optional embodiment, the fragment data corresponding to the first index n in the database of the first device is written into the local cache, and n-1 is used as the local cache of the fragment data in the first device. The index in the specific is: the first device determines whether n is less than N; in the case that n is less than N, the first device reads the fragment data corresponding to n from the database, and attaches the fragment data corresponding to n a timestamp with a value of n; in the case where n is equal to N, the first device reads the fragment data corresponding to n from the database, and attaches the time value of the specified time to the fragment data corresponding to n a stamp; wherein the specified time is the time when the second device accesses the first device last time; the first device writes the fragment data corresponding to n to the local cache, and uses n-1 as the fragment data in the local cache Index in .

需要說明的是,進行快取的方式可以是按照發送格式進行分片快取,因而在第二設備需要讀取時,第一設備不需要再對分片資料進行格式的轉變,而是直接返回給第二設備,降低了同步的時間,提高了同步的效率。 It should be noted that the method of performing the cache may be performing the fragment cache according to the transmission format. Therefore, when the second device needs to read, the first device does not need to perform format conversion on the fragment data, but directly returns. For the second device, the synchronization time is reduced and the synchronization efficiency is improved.

透過將第一設備中的全量資料進行分片後快取在第一設備的本地快取中,在快取中快取的每份分片資料都有對應的一個索引,該索引與第二設備發送的請求訊息中的時間戳記具有一定的對應關係,透過該時間戳記與快取中的分片資料的對應關係,將全量資料分片的分片資料同步到第二設備中,在本發明一個可選實施例中,步驟S206中的將與時間戳記對應的分片資料同步至第二設備可以表現為:第一設備以時間戳記的取值作為索引,將第一設備的本地快取中與索引對應的指定分片資料同步至第二設備。 By sharding the full amount of data in the first device and then fetching it in the local cache of the first device, each fragment data cached in the cache has a corresponding index, the index and the second device. The time stamp in the sent request message has a certain correspondence relationship, and the fragmented data of the full data fragment is synchronized to the second device by the correspondence between the time stamp and the fragmented data in the cache, in the present invention In an optional embodiment, the synchronizing the fragment data corresponding to the time stamp to the second device in the step S206 may be performed as follows: the first device uses the value of the time stamp as an index, and the local device of the first device is The specified fragment data corresponding to the index is synchronized to the second device.

透過上述步驟,透過將全量資料進行快取分片的方式,然後根據接收的請求訊息中的時間戳記,按照時間戳記與快取中的分片資料的關係,將該時間戳記對應的快取中的分片資料依次同步到第二設備的方式,降低了資料讀取的壓力,進而解決了系統之間進行全量更新資料時頻繁失敗的技術問題,提高了資料傳輸的效率。 Through the above steps, by performing the cache sharding of the full amount of data, and according to the time stamp in the received request message, according to the relationship between the time stamp and the shard data in the cache, the time stamp corresponding to the cache is in the cache. The shard data is sequentially synchronized to the second device, which reduces the pressure of data reading, thereby solving the technical problem of frequent failures when updating the data between the systems, and improving the efficiency of data transmission.

舉個例子:第一設備的資料庫中通常記錄了千萬級別的資料記錄,此處為了方便理解,以較少資料記錄(80條記錄)為例,在第一設備接收到攜帶時間戳記為0的請 求訊息後,按照相關技術中的方式,則第一設備將該80條記錄一次性全部同步給第二設備。而在本實施例中,第一設備對該80條記錄進行分片,分片可以進行均等分配也可以進行不均等分配,以均等分配為例,分為4片,每個分片有20條記錄,將每個分片所包含的資料寫入快取,並設定快取中的4個分片資料對應的索引0、1、2、3;當第二設備請求讀取第一設備的全量資料時,第一次請求中攜帶的時間戳記為0,則第一設備將快取中以0為索引的分片資料同步至第二設備;一段時間後(比如1分鐘),第一設備接收第二次請求,該第二次請求中攜帶時間戳記為1,則第一設備將快取中以1為索引的分片資料同步至第二設備;以此類推,直至將快取中的分片資料讀取完畢。即本實施例透過將全量資料進行分片,將分片後的資料依次同步至第二設備,即將全量資料分批同步至第二設備,相對於相關技術中的方案能夠降低資料的讀取壓力,縮短資料的傳送時間,提高了資料的傳輸效率。 For example, a data record of tens of millions of levels is usually recorded in the database of the first device. For the sake of easy understanding, for example, with less data records (80 records), the time stamp of the first device is received as After the request message of 0, according to the related art, the first device synchronizes all 80 records to the second device at one time. In this embodiment, the first device performs fragmentation on the 80 records, and the fragments may be equally distributed or may be distributed unevenly. For example, the equal distribution is divided into four pieces, and each of the fragments has 20 pieces. Record, write the data contained in each slice to the cache, and set the index 0, 1, 2, 3 corresponding to the 4 pieces of data in the cache; when the second device requests to read the full amount of the first device When the data is sent, the time stamp carried in the first request is 0, and the first device synchronizes the fragment data indexed by 0 in the cache to the second device; after a period of time (for example, 1 minute), the first device receives The second request, in which the timestamp is 1 in the second request, the first device synchronizes the fragment data indexed by 1 in the cache to the second device; and so on, until the score in the cache The piece of data has been read. That is, in this embodiment, by sharding the full amount of data, the pieces of data are sequentially synchronized to the second device, that is, the full amount of data is synchronized to the second device in batches, and the reading pressure of the data can be reduced compared with the scheme in the related art. , shorten the transmission time of data, and improve the efficiency of data transmission.

在一個可選實施例中,圖3是根據本發明實施例1的資料傳輸方法的流程圖二,如圖3所示,上述方法還包括:步驟S302,在時間戳記的取值等於或者大於預設閾值時,第一設備將從時間戳記指示的時間至目前時間產生的增量資料同步至第二設備。 In an alternative embodiment, FIG. 3 is a second flowchart of a data transmission method according to Embodiment 1 of the present invention. As shown in FIG. 3, the method further includes: Step S302, the value of the timestamp is equal to or greater than When the threshold is set, the first device synchronizes the incremental data generated from the time indicated by the time stamp to the current time to the second device.

需要說明的是,在本發明實施例中,存在兩類時間戳記,第一類時間戳記可以是上述圖2所示實施例中的時間 戳記,該時間戳記可以起到讀取全量資料中的分片資料的索引標識的作用,其可以是用個位數字比如0、1、2等表示;第二類時間戳記可以是真實的時間戳記,其表示一個真實的時間,即第二設備最近一次訪問第一設備的時間,其可以透過一個9位元的數位表示,即第二類時間戳記既可以起到標識的作用,也可以表示一個真實的時間。由於上述預設閾值一般為分片資料,其不可能是個很大的數字,因而可以用9位元數字表示真實時間戳記的第二類時間戳記的取值一般是大於上述預設閾值的(即步驟S302中的等於或者大於預設閾值的時間戳記),因而可以將該第二類時間戳記作為一次全量資料讀取結束的標識,或者是一個正常的增量資料讀取的觸發標識。 It should be noted that, in the embodiment of the present invention, there are two types of time stamps, and the first type of time stamp may be the time stamp in the embodiment shown in FIG. 2, and the time stamp may be used to read the scores in the full amount of data. The role of the index of the slice data, which may be represented by a one-digit number such as 0, 1, 2, etc.; the second type of time stamp may be a real time stamp, which represents a real time, that is, the last access of the second device The time of the first device, which can be represented by a 9-bit digit, that is, the second type of time stamp can serve both the identification and the real time. Since the preset threshold is generally fragmented data, it cannot be a large number, so the value of the second type of time stamp that can represent the real time stamp with a 9-bit number is generally greater than the preset threshold (ie, The time stamp equal to or greater than the preset threshold in step S302 can be used as the identifier of the end of the full-quantity data reading or the trigger identifier of the normal incremental data reading.

需要說明的是,步驟S302中,時間戳記的取值大於或者等於預設閾值,表示第二設備發送的請求是一次正常的增量資料讀取請求,此時,需要將第二設備最近一次訪問第一設備的時刻(即上述的時間戳記指示的時間)至目前時間之間的增量資料傳輸至第二設備,在後續的時間裡第一設備一直以正常的增量同步方式將增量資料同步至第二設備,直到時間點為整點或者半點為止,即直到收到第一設備以全量同步方式將資料同步至第二設備的指示為止,以此類推。 It should be noted that, in step S302, the value of the timestamp is greater than or equal to the preset threshold, indicating that the request sent by the second device is a normal incremental data read request, and the second device needs to be accessed last time. The incremental data between the time of the first device (ie, the time indicated by the time stamp described above) and the current time is transmitted to the second device, and in the subsequent time, the first device keeps the incremental data in a normal incremental synchronization manner. Synchronizing to the second device until the time point is an hour or a half point, that is, until an indication that the first device synchronizes the data to the second device in a full amount of synchronization is received, and so on.

需要說明的是,在本發明的實施例中,上述第一設備與第二設備之間的資料通信可以使用http協議,但不限於此。上述方法可以應用於網路內容的監控與遮罩領域,比 如,第一設備對網路的內容比如涉黃、涉毒、涉暴以及涉恐內容等進行監控,或者其他設備對該內容進行監控,當監控到這些內容後,將該內容對應的網頁的統一資源定位符或者該內容出現的電腦所在的功能變數名稱記錄下來,然後將這些資料透過本發明實施例的方法同步到第二設備,第二設備可以再傳輸給其他設備或者第二設備本身根據獲得到統一資源定位符或者功能變數名稱對這些內容進行遮罩。 It should be noted that, in the embodiment of the present invention, the data communication between the first device and the second device may use the http protocol, but is not limited thereto. The above method can be applied to the field of monitoring and masking of network content. For example, the first device monitors network content such as yellow, poison, violence, and terrorism, or other devices monitor the content. After the content is monitored, the uniform resource locator of the webpage corresponding to the content or the function variable name of the computer where the content appears is recorded, and then the data is synchronized to the second device by using the method of the embodiment of the present invention. The second device can be retransmitted to other devices or the second device itself masks the content according to the obtained uniform resource locator or function variable name.

為了更好的理解本發明,以下結合可選的實施例對本發明做進行一步的解釋。 In order to better understand the present invention, the present invention will be explained in one step in conjunction with the optional embodiments.

在一個可選實施例中,第一設備每30分鐘對第一設備的資料庫中的全量url/功能變數名稱進行一次分片快取,來解決即時從資料庫全量讀取記錄時造成的讀取超時等問題。圖4是根據本發明可選實施例的第一設備分片快取全量資料的流程示意圖,如圖4所示,包括以下步驟:步驟S402,設定該次全量url/功能變數名稱阻斷記錄的分片數量(例如4),該分片數量小於10;步驟S404,讀取目前時間,精確到分鐘,記錄在timestamp中;步驟S406,根據timestamp的值,讀取目前時間資料庫中全量記錄數量(例如81);步驟S408,根據分片數量,計算全量記錄的每個分片中包含的記錄數(例如20、20、20、21);步驟S410,設定分片計數index(即上述實施例中的 第一索引n),值為1;步驟S412,判斷目前index值是否小於分片數量(相當於上述實施例中的分片資料的總數量N);是(例如1),則執行步驟S414;不是(例如4),則執行步驟S422;步驟S414,從資料庫中讀取與index對應的指定分片包含的資料;步驟S416,附上時間戳記,值為index;步驟S418,將分片資料與時間戳記寫入快取,key值為index-1(相當於上述實施例中的n-1);步驟S420,分片計數index增加1;返回步驟S412執行;步驟S422,從資料庫中讀取與index對應的指定分片包含的資料;步驟S424,附上時間戳記,值為timestamp(相當於上述實施例中的指定時刻);步驟S426,將分片資料與時間戳記寫入快取,key值為index-1。 In an optional embodiment, the first device performs a slice cache on the full url/function variable name in the database of the first device every 30 minutes to solve the read caused by the full reading of the record from the database. Take timeout and other issues. 4 is a schematic flowchart of a first device sharding full data according to an alternative embodiment of the present invention. As shown in FIG. 4, the method includes the following steps: Step S402, setting the full url/function variable name blocking record. The number of fragments (for example, 4), the number of fragments is less than 10; step S404, reading the current time, accurate to the minute, recorded in the timestamp; step S406, reading the total number of records in the current time database according to the value of timestamp (For example, 81); Step S408, calculating the number of records (for example, 20, 20, 20, 21) included in each slice of the full-volume record according to the number of slices; and step S410, setting the slice count index (ie, the above embodiment) The first index n) has a value of 1; in step S412, it is determined whether the current index value is smaller than the number of fragments (corresponding to the total number N of fragmentation materials in the above embodiment); if (for example, 1), the steps are performed. S414; if not (for example, 4), step S422 is performed; step S414, the data included in the specified fragment corresponding to the index is read from the database; step S416, the time stamp is attached, and the value is index; in step S418, the score is Slice data and time stamp In the cache, the key value is index-1 (corresponding to n-1 in the above embodiment); in step S420, the slice count index is incremented by one; the process returns to step S412; and in step S422, the index is read from the database. The specified fragment contains the data; step S424, with a time stamp, the value is timestamp (corresponding to the specified time in the above embodiment); in step S426, the fragment data and the time stamp are written to the cache, and the key value is index. -1.

第二設備從第一設備讀取全量阻斷記錄時,第一設備將已有全量阻斷記錄快取分批返回給第二設備,以解決大資料量一次性傳送時可能導致的網路問題與第二設備記憶體使用等問題。圖5是根據本發明可選實施例的資料傳輸方法的流程示意圖,如圖5所示,以4片快取為例,該方法包括以下步驟: 步驟S501,第二設備向第一設備發起請求,讀全量阻斷記錄,時間戳記為0;步驟S502,第一設備判斷時間戳記為0,是全量更新阻斷記錄,以0為key在全量阻斷記錄的快取中讀取第一片快取中的分片資料,並附帶時間戳記為1,返回給第二設備;步驟S503,第二設備清空系統內阻斷記錄,並使用收到的全量阻斷記錄的第一片快取中的分片資料;步驟S504,1分鐘後,第二設備向第一設備發起請求,讀取增量阻斷記錄,時間戳記為步驟S502中第一設備返回的1;步驟S505,第一設備判斷時間戳記小於10,是未完的全量更新阻斷記錄,以1為key在全量阻斷記錄的快取中讀取第二片快取中的分片資料,附帶時間戳記2,返回給第二設備;步驟S506,第二設備將收到的第二片快取中的分片資料,增加到已有阻斷記錄中;步驟S507,1分鐘後,第二設備向第一設備發起請求,讀取增量阻斷記錄,時間戳記為步驟S505中第一設備返回的2;步驟S508,第一設備判斷時間戳記小於10,是未完的全量更新阻斷記錄,以2為key在全量阻斷記錄的快取中讀取第三片快取中的分片資料,附帶時間戳記3,返回給第二設備; 步驟S509,第二設備將收到的第三片快取中的分片資料,增加到已有阻斷記錄中;步驟S510,1分鐘後,第二設備向第一設備發起請求,讀取增量阻斷記錄,時間戳記為步驟S508中第一設備返回的3;步驟S511,第一設備判斷時間戳記小於10,是未完的全量更新阻斷記錄,以3為key在全量阻斷記錄的快取中讀取第四片快取中的分片資料,附帶時間戳記為全量阻斷記錄快取的產生時間timestamp,返回給第二設備;步驟S512,第二設備將收到的第四片快取中的分片資料,增加到已有阻斷記錄中;步驟S513,1分鐘後,第二設備向Mrm發起請求,讀取增量阻斷記錄,時間戳記為步驟S511中第一設備返回的timestamp;步驟S514,第一設備Mrm判斷時間戳記大於10,是一次正常的增量阻斷記錄請求,讀資料庫中timestamp到目前時間的阻斷記錄變化量,附帶目前時間,返回給第二設備;後續每分鐘,第二設備都做增量阻斷記錄請求;如果是整點或半點,則第二設備不做增量阻斷記錄請求,而返回執行步驟S501。 When the second device reads the full amount of the blocked record from the first device, the first device returns the full amount of the blocked record cache to the second device in batches to solve the network problem that may occur when the large data volume is transmitted once. Problems with the use of the second device memory. 5 is a schematic flowchart of a data transmission method according to an alternative embodiment of the present invention. As shown in FIG. 5, taking a 4-chip cache as an example, the method includes the following steps: Step S501: A second device initiates a request to a first device. Read the full block record, the time stamp is 0; in step S502, the first device determines that the time stamp is 0, is the full update block record, and reads the first slice in the cache of the full block record with 0 as the key. The fragmented data is taken with a timestamp of 1 and returned to the second device; in step S503, the second device clears the blocked record in the system and uses the received full amount of the blocked record in the first cache. Fragment data; step S504, after 1 minute, the second device initiates a request to the first device, and reads the incremental blocking record, the time stamp is recorded as 1 returned by the first device in step S502; in step S505, the first device determines the time. The stamp is less than 10, which is an uncompleted full update block record, and the slice data in the second cache is read in the cache of the full block record with 1 as the key, with time stamp 2, and returned to the second device; Step S506, the second device will receive The fragment data in the second cache is added to the existing blocking record; in step S507, after 1 minute, the second device initiates a request to the first device, and reads the incremental blocking record, and the time stamp is recorded as step S505. The first device returns 2; in step S508, the first device determines that the time stamp is less than 10, which is an uncompleted full update blocking record, and reads the third cache in the cache of the full blocked record with 2 as the key. The fragmentation data is returned to the second device with the time stamp 3; in step S509, the second device adds the fragmentation data in the received third cache to the existing blocking record; step S510, 1 After the minute, the second device initiates a request to the first device to read the incremental blocking record, and the timestamp is recorded as 3 returned by the first device in step S508; in step S511, the first device determines that the timestamp is less than 10, which is an unfinished full amount. Update the blocking record, read the fragment data in the fourth cache in the cache of the full blocking record with 3 as the key, and attach the timestamp to the timestamp of the full blocking recording cache, and return to the second Device; step S512, the second device will The received fragment data in the fourth cache is added to the existing blocking record; in step S513, after 1 minute, the second device initiates a request to the Mrm, reads the incremental blocking record, and the time stamp is step The timestamp returned by the first device in S511; in step S514, the first device Mrm determines that the timestamp is greater than 10, which is a normal incremental blocking record request, and reads the change of the blocked record from the timestamp in the database to the current time, with the current The time is returned to the second device; the second device performs an incremental blocking record request every minute; if it is an hour or a half point, the second device does not perform the incremental blocking record request, and returns to step S501.

需要說明的是,在本發明圖5所示的可選實施例中的1分鐘相當於上述實施例圖2所示實施例的定時,上述時間戳記為0相當於圖2所示實施例中的時間戳記的取值為 指定值,來指示讀全量阻斷記錄,上述實施例中的時間戳記為0、1、2、3相當於圖2所示實施例中的時間戳記的取值;上述key相當於圖2所示實施例中的索引,上述timestamp相當於圖3所示實施例中的取值等於或者大於預設閾值的時間戳記。 It should be noted that 1 minute in the optional embodiment shown in FIG. 5 of the present invention corresponds to the timing of the embodiment shown in FIG. 2 of the above embodiment, and the time stamp is 0, which is equivalent to the embodiment in the embodiment shown in FIG. 2 . The value of the timestamp is a specified value to indicate that the full-time blocking record is read. The timestamp in the above embodiment is 0, 1, 2, and 3, which is equivalent to the value of the timestamp in the embodiment shown in FIG. 2; Corresponding to the index in the embodiment shown in FIG. 2, the timestamp is equivalent to the timestamp in which the value in the embodiment shown in FIG. 3 is equal to or greater than a preset threshold.

在上述實施例中,同步分為兩種,增量同步方式和全量同步方式,全量同步方式同步資料是這樣實現的:透過預先將全量資料提前進行分片快取,在第二設備進行讀取的時候,直接使用分片快取中的分片資料,即根據全量資料分片的數量N,透過N次類比增量同步方式實現全量資料同步的,降低了資料讀取壓力,在第一設備第一次同步給第二設備時,也不會因為資料量過大而同步失敗。 In the above embodiment, the synchronization is divided into two types, an incremental synchronization mode and a full-quantity synchronization mode. The full-quantity synchronization mode synchronization data is realized by: pre-sending the full amount of data in advance to perform fragmentation cache, and reading in the second device. At the time, the fragmentation data in the fragment cache is directly used, that is, according to the number N of the full-size data fragments, the full-scale data synchronization is realized by the N-class analog incremental synchronization method, thereby reducing the data reading pressure in the first device. When the second device is synchronized to the second device, the synchronization will not fail because the data volume is too large.

需要說明的是,對於前述的各方法實施例,為了簡單描述,故將其都表述為一系列的動作組合,但是本領域技術人員應該知悉,本發明並不受所描述的動作順序的限制,因為依據本發明,某些步驟可以採用其他順序或者同時進行。其次,本領域技術人員也應該知悉,說明書中所描述的實施例均屬於較佳實施例,所關於的動作和模組並不一定是本發明所必須的。 It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should understand that the present invention is not limited by the described action sequence. Because certain steps may be performed in other sequences or concurrently in accordance with the present invention. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

透過以上的實施方式的描述,本領域的技術人員可以清楚地瞭解到根據上述實施例的資料傳輸方法可借助軟體加必需的通用硬體平台的方式來實現,當然也可以透過硬體,但很多情況下前者是更佳的實施方式。基於這樣的理解,本發明的技術方案本質上或者說對現有技術做出貢獻 的部分可以以軟體產品的形式體現出來,該電腦軟體產品儲存在一個儲存媒體(如ROM/RAM、磁碟、光碟)中,包括若干指令用以使得一台終端設備(可以是手機,電腦,伺服器,或者網路設備等)執行本發明各個實施例所述的方法。 Through the description of the above embodiments, those skilled in the art can clearly understand that the data transmission method according to the above embodiment can be implemented by means of a software plus a necessary general hardware platform, and of course, can also be through hardware, but many In the case of the former is a better implementation. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, can be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, CD-ROM). The instructions include a number of instructions for causing a terminal device (which may be a cell phone, a computer, a server, or a network device, etc.) to perform the methods described in various embodiments of the present invention.

實施例2Example 2

根據本發明實施例,還提供了一種資料傳輸方法,圖6是根據本發明實施例2的資料傳輸方法的流程圖一,如圖6所示,該方法包括:步驟S602,第二設備向第一設備發送請求訊息,其中,該請求訊息中攜帶有與請求訊息對應的時間戳記;需要說明的是,上述第二設備可以是與上述實施例1中的電腦終端10的結構相同的一個電腦終端,在該電腦終端的環境中完成本實施例中的資料傳輸方法,但不限於此。上述發送請求訊息可以是定時發送請求訊息,可以是不定時發送請求訊息,可以根據具體的情況進行具體設定。 According to an embodiment of the present invention, a data transmission method is also provided. FIG. 6 is a flowchart 1 of a data transmission method according to Embodiment 2 of the present invention. As shown in FIG. 6, the method includes: Step S602, the second device is directed to A device sends a request message, wherein the request message carries a timestamp corresponding to the request message. It should be noted that the second device may be a computer terminal having the same structure as the computer terminal 10 in the first embodiment. The data transmission method in this embodiment is completed in the environment of the computer terminal, but is not limited thereto. The foregoing sending request message may be a timing sending request message, and may be a request message sent from time to time, and may be specifically set according to a specific situation.

步驟S604,在時間戳記的取值小於預設閾值的情況下,第二設備接收第一設備發送的分片資料;其中,分片資料是與時間戳記對應的在所述第一設備本地快取的分片資料,上述分片資料為對第一設備記錄的全量資料進行分片得到。 Step S604: The second device receives the fragment data sent by the first device, where the value of the timestamp is less than a preset threshold, where the fragment data is locally cached in the first device corresponding to the timestamp. The fragmentation data is obtained by fragmenting the full amount of data recorded by the first device.

上述時間戳記的取值可以是指定值,用於指示第二設 備讀取第一設備中的全量資料;在一個可選的實施例中,上述指定值可以是0,即在請求訊息中攜帶的時間戳記為0時,指示第二設備應當讀第一設備的全量資料。在一個可選的實施例中,在步驟S604之前,上述方法還包括:在時間戳記為指定值的情況下,第二設備觸發第一設備發送全量資料,接收第一設備發送的與指定值對應的分片資料。 The value of the timestamp may be a specified value for instructing the second device to read the full amount of data in the first device. In an optional embodiment, the specified value may be 0, that is, carried in the request message. When the timestamp is 0, it indicates that the second device should read the full amount of data of the first device. In an optional embodiment, before the step S604, the method further includes: when the time stamp is a specified value, the second device triggers the first device to send the full amount of data, and the first device sends the corresponding value corresponding to the specified value. Segmentation information.

需要說明的是,上述預設閾值可以是第一設備對上述全量資料進行分片後得到的分片數量,當然也可以是其他的值,一般該預設閾值可設定為小於10;上述全量資料可以是針對統一資源定位符url的阻斷記錄,也可以是針對功能變數名稱的阻斷記錄,也可以是兩者的組合,並不限於此。 It should be noted that the preset threshold may be the number of fragments obtained by the first device after fragmenting the full amount of data, and may of course be other values. Generally, the preset threshold may be set to be less than 10; It may be a blocking record for the uniform resource locator url, a blocking record for the function variable name, or a combination of the two, and is not limited thereto.

具體地,第一設備是如何對全量資料進行分片快取的,即上述分片資料是如何在第一設備中得到的,與上述實施例1中的相同,此處不再贅述。 Specifically, the first device performs the fragmentation cache on the full amount of data, that is, how the fragment data is obtained in the first device, which is the same as that in the first embodiment, and details are not described herein again.

上述步驟S604中,第二設備接收第一設備發送的分片資料可以表現為:第二設備接收在第一設備的本地快取中與索引對應的指定分片資料;其中,索引為上述時間戳記;第二設備接收第一設備發送的指定時間戳記;其中,指定時間戳記的取值為由上述時間戳記的取值加1得到。 In the foregoing step S604, the receiving, by the second device, the fragment data sent by the first device may be: the second device receives the specified fragment data corresponding to the index in the local cache of the first device; wherein the index is the time stamp The second device receives the specified timestamp sent by the first device; wherein the value of the specified timestamp is obtained by adding 1 to the value of the timestamp.

透過上述步驟,透過第二設備發送攜帶時間戳記的請求訊息,接收第一設備根據接收的請求訊息中的時間戳記,發送的該時間戳記對應的第一設備的快取中的分片資 料的方式,即第二設備按照時間戳記讀取在第一設備中預先進行分片快取的分片資料,降低了資料讀取的壓力,進而解決了系統之間進行全量更新資料時頻繁失敗的技術問題,提高了資料傳輸的效率。 Through the foregoing steps, the request message carrying the time stamp is sent by the second device, and the manner in which the first device sends the fragment data in the cache of the first device corresponding to the time stamp according to the time stamp in the received request message is received. That is, the second device reads the fragment data that is pre-sorted and cached in the first device according to the time stamp, thereby reducing the pressure of data reading, thereby solving the technical problem of frequent failures when the system updates the data in full. Improve the efficiency of data transmission.

舉個例子:第一設備的資料庫中通常記錄了千萬級別的資料記錄,此處為了方便理解,以較少資料記錄(80條記錄)為例,第二設備發送攜帶時間戳記為0的請求訊息後,按照相關技術中的方式,則第二設備將一次性讀取該80條記錄。而在本實施例中,第一設備對該80條記錄進行分片,分片可以進行均等分配也可以進行不均等分配,以均等分配為例,分為4片,每個分片有20條記錄,將每個分片所包含的資料寫入快取,並設定快取中的4個分片資料對應的索引0、1、2、3;當第二設備請求讀取第一設備的全量資料時,第一次請求中攜帶的時間戳記為0,則第二設備讀取第一設備的快取中以0為索引的分片資料;一段時間後(比如1分鐘),第二設備發送第二次請求,該第二次請求中攜帶時間戳記為1,則第二設備讀取第一設備的快取中以1為索引的分片資料;以此類推,直至第二設備將第一設備的快取中的分片資料讀取完畢。即本實施例透過第一設備將全量資料進行分片,第二設備分批讀取該第一設備的快取中的分片資料,相比於相關技術中的方案能夠降低資料的讀取壓力,縮短資料的傳送時間,提高了資料的傳輸效率。 For example, a data record of tens of millions of levels is usually recorded in the database of the first device. For the sake of easy understanding, for example, with less data records (80 records), the second device sends a time stamp of 0. After requesting the message, the second device will read the 80 records at a time according to the manner in the related art. In this embodiment, the first device performs fragmentation on the 80 records, and the fragments may be equally distributed or may be distributed unevenly. For example, the equal distribution is divided into four pieces, and each of the fragments has 20 pieces. Record, write the data contained in each slice to the cache, and set the index 0, 1, 2, 3 corresponding to the 4 pieces of data in the cache; when the second device requests to read the full amount of the first device When the data is sent, the time stamp carried in the first request is 0, and the second device reads the fragment data indexed by 0 in the cache of the first device; after a period of time (for example, 1 minute), the second device sends The second request, the second request carries a timestamp of 1, and the second device reads the fragment data indexed by 1 in the cache of the first device; and so on, until the second device will be the first The fragment data in the cache of the device is read. That is, in this embodiment, the full amount of data is fragmented by the first device, and the second device reads the fragmentation data in the cache of the first device in batches, which can reduce the reading pressure of the data compared to the scheme in the related art. , shorten the transmission time of data, and improve the efficiency of data transmission.

在一個可選實施例中,圖7是根據本發明實施例2的 資料傳輸方法的流程圖二,如圖7所示,上述方法還包括:步驟S702,在時間戳記的取值等於或者大於預設閾值的情況下,第二設備接收第一設備發送的從時間戳記指示的時間至目前時間產生的增量資料。 In an alternative embodiment, FIG. 7 is a flowchart 2 of a data transmission method according to Embodiment 2 of the present invention. As shown in FIG. 7, the method further includes: Step S702, the value of the timestamp is equal to or greater than In the case of setting the threshold, the second device receives the incremental data generated by the first device from the time indicated by the time stamp to the current time.

需要說明的是,在本發明實施例中,存在兩類時間戳記,第一類時間戳記可以是上述圖6所示實施例中的時間戳記,該時間戳記可以起到讀取全量資料中的分片資料的索引標識的作用,其可以是用個位數字比如0、1、2等表示;第二類時間戳記可以是真實的時間戳記,其表示一個真實的時間,即第二設備最近一次訪問第一設備的時間,其可以透過一個9位元的數位表示,即第二類時間戳記既可以起到標識的作用,也可以表示一個真實的時間。由於上述預設閾值一般為分片資料,其並不是很大的數位,因而作為可以用9位元數字表示真實時間戳記的第二類時間戳記一般是大於上述預設閾值的(即步驟S702中的等於或者大於預設閾值的時間戳記),因而可以將該第二類時間戳記作為一次全量資料讀取結束的標識,或者是一個正常的增量資料讀取的觸發標識。 It should be noted that, in the embodiment of the present invention, there are two types of time stamps, and the first type of time stamp may be the time stamp in the embodiment shown in FIG. 6 , and the time stamp may be used to read the scores in the full amount of data. The role of the index of the slice data, which may be represented by a one-digit number such as 0, 1, 2, etc.; the second type of time stamp may be a real time stamp, which represents a real time, that is, the last access of the second device The time of the first device, which can be represented by a 9-bit digit, that is, the second type of time stamp can serve both the identification and the real time. Since the preset threshold is generally fragmented data, it is not a large number of digits, so the second type of time stamp, which can represent the real time stamp with 9 digits, is generally greater than the preset threshold (ie, in step S702). The time stamp equal to or greater than the preset threshold, so that the second type of time stamp can be used as an identifier for the end of a full amount of data reading, or a trigger identifier for a normal incremental data reading.

需要說明的是,步驟S702中,時間戳記的取值大於或者等於預設閾值,表示第二設備發送的請求是一次正常的增量資料讀取請求,此時,第二設備需要將第二設備最近一次訪問第一設備的時刻(即上述的時間戳記指示的時間)至目前時間之間的增量資料讀取過來,在後續的時間 裡,第二設備一直以正常的增量同步方式讀取增量資料,直到時間點為整點或者半點為止,即直到第二設備收到以全量同步方式讀取資料的指示為止,以此類推。 It should be noted that, in step S702, the value of the timestamp is greater than or equal to the preset threshold, indicating that the request sent by the second device is a normal incremental data read request, and the second device needs to use the second device. The incremental data between the time when the last access to the first device (that is, the time indicated by the time stamp described above) is up to the current time is read, and in the subsequent time, the second device is always read in the normal incremental synchronization manner. Incremental data until the point in time is the hour or half, that is, until the second device receives an indication to read the data in full synchronous mode, and so on.

需要說明的是,在本發明的實施例中,上述第一設備與第二設備之間的資料通信可以使用http協議,但不限於此。上述方法可以應用於網路內容的監控與遮罩領域,比如,第一設備對網路的內容比如涉黃、涉毒、涉暴、以及涉恐內容等進行監控,或者其他設備對該內容進行監控,當監控到這些內容後,將該內容對應的網頁的統一資源定位符或者該內容出現的電腦所在的功能變數名稱記錄下來,然後將這些資料透過本發明實施例的方法同步到第二設備,第二設備可以再傳輸給其他設備或者第二設備本身根據獲得到統一資源定位符或者功能變數名稱對這些內容進行遮罩。 It should be noted that, in the embodiment of the present invention, the data communication between the first device and the second device may use the http protocol, but is not limited thereto. The above method can be applied to the field of monitoring and masking of network content. For example, the first device monitors content of the network such as yellow, poison, violence, and terrorism, or other devices perform the content. Monitoring, when the content is monitored, the uniform resource locator of the webpage corresponding to the content or the function variable name of the computer where the content appears is recorded, and then the data is synchronized to the second device by using the method of the embodiment of the present invention. The second device can be retransmitted to other devices or the second device itself masks the content according to the obtained uniform resource locator or function variable name.

為了更好的理解本發明,可以結合實施例1中的圖4和圖5所示的可選的實施例對本發明做進行一步的解釋,此處不再贅述。 For a better understanding of the present invention, the present invention can be explained in one step in combination with the optional embodiments shown in FIG. 4 and FIG. 5 in Embodiment 1, and details are not described herein again.

實施例3Example 3

根據本發明實施例,還提供了一種用於實施上述實施例1中的資料傳輸方法的裝置,圖8是根據本發明實施例3的資料傳輸裝置的結構方塊圖一,如圖8所示,該裝置,應用於第一設備,包括:接收模組80,用於定時接收來自第二設備的請求訊 息,其中,該請求訊息中攜帶有與本次接收的請求訊息對應的時間戳記;需要說明的是,這裡的定時可以是按照實際情況進行設定,兩次接收的請求訊息的時間間隔可以是固定的,比如設定每隔1分鐘接收一次請求訊息,也可以是不固定的,比如1分鐘後接收第二次請求訊息,再過3分鐘後接收第三次請求訊息,具體的可以根據實際情況進行設定。 An apparatus for implementing the data transmission method in Embodiment 1 is provided according to the embodiment of the present invention. FIG. 8 is a block diagram of the structure of the data transmission apparatus according to Embodiment 3 of the present invention, as shown in FIG. The device is applied to the first device, and includes: a receiving module 80, configured to periodically receive a request message from the second device, where the request message carries a timestamp corresponding to the request message received this time; The timing here can be set according to the actual situation. The time interval of the request message received twice can be fixed. For example, the request message is received every 1 minute, or it is not fixed, for example, after 1 minute. After receiving the second request message, the third request message is received after 3 minutes, and the specific request can be set according to the actual situation.

第一判斷模組82,與上述接收模組80連接,用於判斷時間戳記的取值是否小於預設閾值;上述時間戳記的取值可以是指定值,用於指示讀取第一設備中的全量資料;在一個可選的實施例中,上述指定值可以是0,即在請求訊息中攜帶的時間戳記為0時,指示第二設備應當讀第一設備的全量資料。 The first judging module 82 is connected to the receiving module 80, and is configured to determine whether the value of the timestamp is less than a preset threshold; the value of the timestamp may be a specified value for indicating reading in the first device. The full amount of data; in an optional embodiment, the specified value may be 0, that is, when the timestamp carried in the request message is 0, the second device is instructed to read the full amount of data of the first device.

在一個可選實施例中,圖9是根據本發明實施例3的資料傳輸裝置的結構方塊圖二,如圖9所示,上述裝置還包括:第二判斷模組90,與接收模組80連接,用於判斷時間戳記的取值是否為指定值,其中,該指定值用於指示讀取全量資料,其中,在判斷結果為是時,觸發將與時間戳記對應的分片資料同步至第二設備。 In an alternative embodiment, FIG. 9 is a block diagram of a data transmission device according to Embodiment 3 of the present invention. As shown in FIG. 9, the device further includes: a second determining module 90, and a receiving module 80. a connection, configured to determine whether the value of the timestamp is a specified value, wherein the specified value is used to indicate that the full amount of data is read, wherein, when the determination result is yes, triggering to synchronize the fragment data corresponding to the timestamp to the first Two devices.

第一同步模組84,與上述第一判斷模組82連接,用於在時間戳記的取值小於預設閾值時,按照時間戳記與第一設備在本地快取的分片資料的對應關係,將與時間戳記對應的分片資料同步至第二設備,其中,分片資料為對第 一設備記錄的全量資料進行分片得到。 The first synchronization module 84 is connected to the first judging module 82, and is configured to, according to the timestamp, the correspondence between the time stamp and the fragmented data of the first device in the local cache when the value of the timestamp is less than the preset threshold. The fragment data corresponding to the time stamp is synchronized to the second device, wherein the fragment data is obtained by fragmenting the full amount of data recorded by the first device.

需要說明的是,上述預設閾值可以是對上述全量資料進行分片後得到的分片數量,當然也可以是其他的值,一般該預設閾值可設定為小於10;上述全量資料可以是針對統一資源定位符url的阻斷記錄,也可以是針對功能變數名稱的阻斷記錄,也可以是兩者的組合,並不限於此。 It should be noted that the preset threshold may be a number of fragments obtained by fragmenting the full amount of data, and may be other values. Generally, the preset threshold may be set to be less than 10; The blocking record of the uniform resource locator url may also be a blocking record for the function variable name, or a combination of the two, and is not limited thereto.

上述第一同步模組84還用於以時間戳記的取值作為索引,將第一設備的本地快取中與該索引對應的指定分片資料同步至第二設備。 The first synchronization module 84 is further configured to synchronize the specified fragment data corresponding to the index in the local cache of the first device to the second device by using the value of the time stamp as an index.

在一個可選的實施例中,圖10是根據本發明實施例3的資料傳輸裝置的結構方塊圖三,如圖10所示,上述裝置還包括:快取模組100,與第一同步模組84連接,用於將第一設備的資料庫中與第一索引n對應的分片資料,寫入本地快取,並將n-1作為分片資料在第一設備的本地快取中的索引,其中,n小於或者等於對全量資料進行分片後得到的所有分片資料的總數量N,n、N均為正整數。 In an alternative embodiment, FIG. 10 is a structural block diagram of a data transmission apparatus according to Embodiment 3 of the present invention. As shown in FIG. 10, the apparatus further includes: a cache module 100, and a first synchronization mode. The group 84 is connected to write the fragment data corresponding to the first index n in the database of the first device to the local cache, and use n-1 as the fragment data in the local cache of the first device. The index, where n is less than or equal to the total number N, n, and N of all the pieces of data obtained after fragmenting the full amount of data are positive integers.

具體地,上述快取模組100還包括:判斷單元1001,用於判斷n是否小於N;第一讀取單元1002,與上述判斷單元1001連接,用於在n小於N的情況下,從所述資料庫中讀取n對應的分片資料,並在n對應的分片資料上附上值為n的時間戳記;第二讀取單元1003,與上述判斷單元1001連接,用 於在n等於N的情況下,從所述資料庫中讀取與n對應的分片資料,並在與n對應的分片資料上附上值為指定時刻的時間戳記;其中,所述指定時刻為所述第二設備上一次訪問所述第一設備的時刻;暫存單元1004,與上述第一讀取單元1002和第二讀取單元1003連接,用於將與n對應的分片資料寫入本地快取,並將n-1作為分片資料在本地快取中的索引。 Specifically, the cache module 100 further includes: a determining unit 1001, configured to determine whether n is less than N; the first reading unit 1002 is connected to the determining unit 1001, and is configured to use n in the case where n is smaller than N. The fragment data corresponding to n is read in the database, and a time stamp with a value of n is attached to the fragment data corresponding to n; the second reading unit 1003 is connected to the determining unit 1001 for equalizing In the case of N, the fragment data corresponding to n is read from the database, and a time stamp having a value of the specified time is attached to the fragment data corresponding to n; wherein the specified time is the The time when the second device accesses the first device at a time; the temporary storage unit 1004 is connected to the first reading unit 1002 and the second reading unit 1003, and is configured to write the fragment data corresponding to n to the local fast. Take and use n-1 as the index of the fragmented data in the local cache.

需要說明的是,上述暫存單元1004可以是按照發送格式將與n對應的分片資料寫入本地快取,這樣,在第二設備需要讀取時,第一設備不需要再對分片資料進行格式的轉變,而是直接返回給第二設備,降低了同步的時間,提高了同步的效率。 It should be noted that the temporary storage unit 1004 may write the fragment data corresponding to n to the local cache according to the transmission format, so that the first device does not need to re-segment the data when the second device needs to read. The format is changed, but directly returned to the second device, which reduces the synchronization time and improves the synchronization efficiency.

透過上述裝置,透過將全量資料進行快取分片的方式,然後根據接收的請求訊息中的時間戳記,按照時間戳記與快取中的分片資料的關係,將該時間戳記對應的快取中的分片資料依次同步到第二設備的方式,降低了資料讀取的壓力,進而解決了系統之間進行全量更新資料時頻繁失敗的技術問題,提高了資料傳輸的效率。 Through the above device, the cache is correspondingly cached according to the time stamp of the received request message, according to the time stamp in the received request message, and the relationship between the time stamp and the snapshot data in the cache. The shard data is sequentially synchronized to the second device, which reduces the pressure of data reading, thereby solving the technical problem of frequent failures when updating the data between the systems, and improving the efficiency of data transmission.

舉個例子:第一設備的資料庫中通常記錄了千萬級別的資料記錄,此處為了方便理解,以較少資料記錄(80條記錄)為例,在第一設備接收到攜帶時間戳記為0的請求訊息後,按照相關技術中的方式,則第一設備將該80條記錄一次性全部同步給第二設備。而在本實施例中,第一設備中的上述裝置對該80條記錄進行分片,分片可以 進行均等分配也可以進行不均等分配,以均等分配為例,分為4片,每個分片有20條記錄,暫存單元1004將每個分片所包含的資料寫入快取,並設定快取中的4個分片資料對應的索引0、1、2、3;當第二設備請求讀取第一設備的全量資料時,第一次請求中攜帶的時間戳記為0,則第一設備的第一同步模組84將快取中以0為索引的分片資料同步至第二設備;一段時間後(比如1分鐘),第一設備的接收模組80接收第二次請求,該第二次請求中攜帶時間戳記為1,則第一設備的第一同步模組84將快取中以1為索引的分片資料同步至第二設備;以此類推,直至將快取中的分片資料讀取完畢。即本實施例的上述裝置透過將全量資料進行分片,將分片後的資料依次同步至第二設備,即將全量資料分批同步至第二設備,相比於相關技術中的方案能夠降低資料的讀取壓力,縮短資料的傳送時間,提高了資料的傳輸效率。 For example, a data record of tens of millions of levels is usually recorded in the database of the first device. For the sake of easy understanding, for example, with less data records (80 records), the time stamp of the first device is received as After the request message of 0, according to the related art, the first device synchronizes all 80 records to the second device at one time. In the embodiment, the device in the first device fragments the 80 records, and the fragments can be equally distributed or distributed unevenly. For example, the equal distribution is divided into four pieces, each of which is divided into four pieces. The slice has 20 records, and the temporary storage unit 1004 writes the data contained in each slice to the cache, and sets the index 0, 1, 2, 3 corresponding to the 4 pieces of data in the cache; when the second device When requesting to read the full amount of data of the first device, the time stamp carried in the first request is 0, and the first synchronization module 84 of the first device synchronizes the fragment data indexed by 0 in the cache to the second After a period of time (for example, 1 minute), the receiving module 80 of the first device receives the second request, and the time stamp of the second request is 1; then the first synchronization module 84 of the first device will be fast. The fragment data indexed by 1 is synchronized to the second device; and so on, until the fragment data in the cache is read. That is, the device of the embodiment can perform the fragmentation of the full amount of data to the second device in sequence, that is, the full amount of data is synchronously synchronized to the second device, and the data can be reduced compared to the solution in the related art. The reading pressure shortens the data transmission time and improves the data transmission efficiency.

圖11是根據本發明實施例3的資料傳輸裝置的結構方塊圖四,如圖11所示,上述裝置還包括:第二同步模組1101,與上述第一判斷模組82連接,用於在時間戳記的取值等於或者大於預設閾值時,將從時間戳記指示的時間至目前時間產生的增量資料同步至第二設備。 Figure 11 is a block diagram showing the structure of a data transmission device according to a third embodiment of the present invention. As shown in Figure 11, the device further includes a second synchronization module 1101 connected to the first determination module 82 for When the value of the time stamp is equal to or greater than the preset threshold, the incremental data generated from the time indicated by the time stamp to the current time is synchronized to the second device.

需要說明的是,在本發明實施例中,存在兩類時間戳記,第一類時間戳記可以是上述圖8所示實施例中的時間戳記,該時間戳記可以起到讀取全量資料中的分片資料的 索引標識的作用,其可以是用個位數字比如0、1、2等表示;第二類時間戳記可以是真實的時間戳記,其表示一個真實的時間,即第二設備最近一次訪問第一設備的時間,其可以透過一個9位元的數位表示,即第二類時間戳記既可以起到標識的作用,也可以表示一個真實的時間。在由於上述預設閾值一般為分片資料,其不可能是個很大的數位,因而作為可以用9位元數字表示真實時間戳記的第二類時間戳記的取值一般是大於上述預設閾值的,因而可以將該第二類時間戳記作為一次全量資料讀取結束的標識,或者是一個正常的增量資料讀取的觸發標識。 It should be noted that, in the embodiment of the present invention, there are two types of time stamps, and the first type of time stamp may be the time stamp in the embodiment shown in FIG. 8 , and the time stamp can be used to read the scores in the full amount of data. The role of the index of the slice data, which may be represented by a one-digit number such as 0, 1, 2, etc.; the second type of time stamp may be a real time stamp, which represents a real time, that is, the last access of the second device The time of the first device, which can be represented by a 9-bit digit, that is, the second type of time stamp can serve both the identification and the real time. Since the preset threshold is generally fragmented data, it may not be a large number of digits, and thus the value of the second type of time stamp, which can represent the real time stamp with 9 digits, is generally greater than the preset threshold. Therefore, the second type time stamp can be used as an identifier for the end of a full data read, or a trigger identifier for a normal incremental data read.

需要說明的是,時間戳記的取值大於或者等於預設閾值,表示第二設備發送的請求是一次正常的增量資料讀取請求,此時,第二同步模組1101需要將第二設備最近一次訪問第一設備的時刻(即上述的時間戳記指示的時間)至目前時間之間的增量資料傳輸至第二設備,在後續的時間裡第一設備一直以正常的增量資料同步方式將增量資料同步至第二設備,直到時間點為整點或者半點為止,即直到收到第一設備以全量讀取同步方式將資料同步至第二設備的指示為止,以此類推。 It should be noted that the value of the timestamp is greater than or equal to the preset threshold, indicating that the request sent by the second device is a normal incremental data read request. At this time, the second synchronization module 1101 needs to bring the second device closest. The incremental data between the time when the first device is accessed (ie, the time indicated by the time stamp described above) to the current time is transmitted to the second device, and in the subsequent time, the first device always uses the normal incremental data synchronization mode. The incremental data is synchronized to the second device until the time point is an hour or a half point, that is, until an indication that the first device synchronizes the data to the second device in a full amount of read sync mode is received, and so on.

需要說明的是,在本發明的實施例中,第一設備中的上述裝置與第二設備之間的資料通信可以使用http協議,但不限於此。上述裝置可以應用於網路內容的監控與遮罩領域,比如,第一設備對網路的內容比如涉黃、涉毒、涉暴、以及涉恐內容等進行監控,或者其他設備對該內容進 行監控,當監控到這些內容後,將該內容對應的網頁的統一資源定位符或者該內容出現的電腦所在的功能變數名稱記錄下來,然後將這些資料透過上述裝置同步到第二設備,第二設備可以再傳輸給其他設備或者第二設備本身根據獲得到統一資源定位符或者功能變數名稱對這些內容進行遮罩。 It should be noted that, in the embodiment of the present invention, the data communication between the foregoing device and the second device in the first device may use the http protocol, but is not limited thereto. The above device can be applied to the field of monitoring and masking of network content. For example, the first device monitors content of the network such as yellow, poison, violence, and fearful content, or other devices perform the content. Monitoring, after monitoring the content, recording the uniform resource locator of the webpage corresponding to the content or the function variable name of the computer where the content appears, and then synchronizing the data to the second device through the device, the second device It can be retransmitted to other devices or the second device itself masks the content according to the obtained Uniform Resource Locator or Function Variable Name.

需要說明的是,上述模組第一同步模組84第二同步模組1101可以是第一設備中的同一個同步模組,也可以是第一設備中的不同的同步模組。 It should be noted that the second synchronization module 1101 of the first synchronization module 84 may be the same synchronization module in the first device, or may be a different synchronization module in the first device.

實施例4Example 4

根據本發明實施例,還提供了一種用於實施上述實施例2中的資料傳輸方法的裝置,圖12是根據本發明實施例4的資料傳輸裝置的結構方塊圖一,如圖12所示,該裝置,應用於第二設備,包括:發送模組1202,用於向第一設備發送請求訊息,其中,該請求訊息中攜帶有與請求訊息對應的時間戳記;需要說明的是,上述發送請求訊息可以是定時發送請求訊息,可以是不定時發送請求訊息,可以根據具體的情況進行具體設定。 An apparatus for implementing the data transmission method in Embodiment 2 is further provided. FIG. 12 is a block diagram of the structure of the data transmission apparatus according to Embodiment 4 of the present invention. As shown in FIG. The device is applied to the second device, and includes: a sending module 1202, configured to send a request message to the first device, where the request message carries a timestamp corresponding to the request message; The message may be a timed request message, or may be sent from time to time, and may be specifically set according to specific conditions.

第一接收模組1204,與上述發送模組1202連接,用於在時間戳記的取值小於預設閾值的情況下,接收第一設備發送的分片資料;其中,分片資料是與時間戳記對應的在第一設備本地快取的分片資料,上述分片資料為第一設 備記錄的全量資料進行分片得到。 The first receiving module 1204 is connected to the sending module 1202, and configured to receive the fragment data sent by the first device if the value of the time stamp is less than a preset threshold; wherein the fragment data is a time stamp Corresponding the fragmented data locally cached by the first device, the fragmented data is obtained by fragmenting the full amount of data recorded by the first device.

上述時間戳記可以是指定值,用於指示第二設備讀取第一設備中的全量資料;在一個可選的實施例中,上述指定值可以是0,即在請求訊息中攜帶的時間戳記為0時,指示第二設備應當讀第一設備的全量資料。在一個可選實施例中,上述裝置還包括:觸發模組,用於在時間戳記的取值為指定值的情況下,觸發第一設備發送全量資料;第三接收模組,與該觸發模組連接,用於接收第一設備發送的與指定值對應的分片資料,其中,指定值用於指示第二設備向所述第一設備讀取全量資料。 The timestamp may be a specified value for instructing the second device to read the full amount of data in the first device; in an optional embodiment, the specified value may be 0, that is, the timestamp carried in the request message is 0, indicating that the second device should read the full amount of data of the first device. In an optional embodiment, the device further includes: a triggering module, configured to: when the value of the timestamp is a specified value, trigger the first device to send the full amount of data; the third receiving module, and the triggering mode The group connection is configured to receive the fragment data corresponding to the specified value sent by the first device, where the specified value is used to instruct the second device to read the full amount of data to the first device.

需要說明的是,上述預設閾值可以是第一設備對上述全量資料進行分片後得到的分片數量,當然也可以是其他的值,一般該預設閾值可設定為小於10;上述全量資料可以是針對統一資源定位符url的阻斷記錄,也可以是針對功能變數名稱的阻斷記錄,也可以是兩者的組合,並不限於此。 It should be noted that the preset threshold may be the number of fragments obtained by the first device after fragmenting the full amount of data, and may of course be other values. Generally, the preset threshold may be set to be less than 10; It may be a blocking record for the uniform resource locator url, a blocking record for the function variable name, or a combination of the two, and is not limited thereto.

具體地,第一設備是如何對全量資料進行分片快取的,即上述分片資料是如何在第一設備中得到的,與上述實施例1中的相同,此處不再贅述。 Specifically, the first device performs the fragmentation cache on the full amount of data, that is, how the fragment data is obtained in the first device, which is the same as that in the first embodiment, and details are not described herein again.

在本發明的一個可選實施例中,圖13是根據本發明實施例4的資料傳輸裝置的結構方塊圖二,如圖13所示,上述第一接收模組1204可以包括:第一接收單元1302,用於接收在所述第一設備的本地快取中與索引對應的指定分片資料;其中,索引為上述時間戳記的取值;第 二接收單元1304,與上述第一接收單元1302連接,用於接收第一設備發送的指定時間戳記;其中,指定時間戳記的取值為由上述時間戳記的取值加1得到。 In an alternative embodiment of the present invention, FIG. 13 is a block diagram of a data transmission apparatus according to Embodiment 4 of the present invention. As shown in FIG. 13, the first receiving module 1204 may include: a first receiving unit. The first receiving unit 1304 is configured to receive the specified fragment data corresponding to the index in the local cache of the first device, where the index is the value of the time stamp; the second receiving unit 1304 is connected to the first receiving unit 1302. And receiving the specified timestamp sent by the first device; wherein the value of the specified timestamp is obtained by adding 1 to the value of the timestamp.

透過上述裝置,透過發送模組1202發送攜帶時間戳記的請求訊息,第一接收模組1204接收第一設備根據接收的請求訊息中的時間戳記,發送的該時間戳記對應的第一設備的快取中的分片資料的方式,即上述裝置按照時間戳記讀取在第一設備中預先進行分片快取的分片資料,降低了資料讀取的壓力,進而解決了系統之間進行全量更新資料時頻繁失敗的技術問題,提高了資料傳輸的效率。 The sending module 1202 sends a request message carrying a time stamp through the sending module 1202, and the first receiving module 1204 receives the first device's cache corresponding to the timestamp corresponding to the timestamp sent by the first device according to the received request message. The method of sharding data in the device, that is, the device reads the shard data of the sharding and sharding in the first device according to the time stamp, thereby reducing the pressure of reading the data, thereby solving the problem of fully updating the data between the systems. Technical problems that frequently fail, improve the efficiency of data transmission.

舉個例子:第一設備的資料庫中通常記錄了千萬級別的資料記錄,此處為了方便理解,以較少資料記錄(80條記錄)為例,第二設備發送攜帶時間戳記為0的請求訊息後,按照相關技術中的方式,則第二設備將一次性讀取該80條記錄。而在本實施例中,第一設備對該80條記錄進行分片,分片可以進行均等分配也可以進行不均等分配,以均等分配為例,分為4片,每個分片有20條記錄,將每個分片所包含的資料寫人快取,並設定快取中的4個分片資料對應的索引0、1、2、3;當第二設備中上述裝置中的發送模組1202請求讀取第一設備的全量資料時,第一次請求中攜帶的時間戳記為0,則上述裝置中的第一接收模組1204讀取第一設備的快取中以0為索引的分片資料;一段時間後(比如1分鐘),第二設備上述裝置中的發送模組1202發送第二次請求,該第二次請求中 攜帶時間戳記為1,則上述裝置中的第一接收模組1204讀取第一設備的快取中以1為索引的分片資料;以此類推,直至第二設備中的上述裝置將第一設備的快取中的分片資料讀取完畢。即本實施例透過第一設備將全量資料進行分片,上述裝置分批讀取該第一設備的快取中的分片資料,相比於相關技術中的方案能夠降低資料的讀取壓力,縮短資料的傳送時間,提高了資料的傳輸效率。 For example, a data record of tens of millions of levels is usually recorded in the database of the first device. For the sake of easy understanding, for example, with less data records (80 records), the second device sends a time stamp of 0. After requesting the message, the second device will read the 80 records at a time according to the manner in the related art. In this embodiment, the first device performs fragmentation on the 80 records, and the fragments may be equally distributed or may be distributed unevenly. For example, the equal distribution is divided into four pieces, and each of the fragments has 20 pieces. Record, write the data contained in each slice to the cache, and set the index 0, 1, 2, 3 corresponding to the 4 pieces of data in the cache; when the second device is in the above device When the 1202 requests to read the full amount of data of the first device, the timestamp carried in the first request is 0, and the first receiving module 1204 in the device reads the index indexed by 0 in the cache of the first device. After a period of time (for example, 1 minute), the sending module 1202 in the device of the second device sends a second request, and the second request carries a time stamp of 1, and the first receiving mode in the device The group 1204 reads the fragment data indexed by 1 in the cache of the first device; and so on, until the device in the second device reads the fragment data in the cache of the first device. That is, in this embodiment, the full amount of data is fragmented by the first device, and the device reads the fragment data in the cache of the first device in batches, which can reduce the reading pressure of the data compared to the scheme in the related art. Shorten the transmission time of data and improve the efficiency of data transmission.

圖14是根據本發明實施例4的資料傳輸裝置的結構方塊圖三,如圖14所示,上述裝置還包括:第二接收模組1402,與發送模組1204用於在時間戳記的取值大於或者等於預設閾值的情況下,接收第一設備發送的從時間戳記指示的時間至目前時間產生的增量資料。 FIG. 14 is a block diagram showing the structure of a data transmission apparatus according to Embodiment 4 of the present invention. As shown in FIG. 14, the apparatus further includes: a second receiving module 1402, and a value used by the sending module 1204 for time stamping. When the threshold is greater than or equal to the preset threshold, the incremental data generated by the first device from the time indicated by the time stamp to the current time is received.

需要說明的是,在本發明實施例中,存在兩類時間戳記,第一類時間戳記可以是上述圖12所示實施例中的時間戳記,該時間戳記可以起到讀取全量資料中的分片資料的索引標識的作用,其可以是用個位數字比如0、1、2等表示;第二類時間戳記可以是真實的時間戳記,其表示一個真實的時間,即第二設備最近一次訪問第一設備的時間,其可以透過一個9位元的數位表示,即第二類時間戳記既可以起到標識的作用,也可以表示一個真實的時間。在由於上述預設閾值一般為分片資料,其並不是很大的數位,因而作為可以用9位元數字表示真實時間戳記的第二類時間戳記一般是大於上述預設閾值的,因而可以將該第 二類時間戳記作為一次全量資料讀取結束的標識,或者是一個正常的增量資料讀取的開始的標識。 It should be noted that, in the embodiment of the present invention, there are two types of time stamps, and the first type of time stamp may be the time stamp in the embodiment shown in FIG. 12, and the time stamp may be used to read the scores in the full amount of data. The role of the index of the slice data, which may be represented by a one-digit number such as 0, 1, 2, etc.; the second type of time stamp may be a real time stamp, which represents a real time, that is, the last access of the second device The time of the first device, which can be represented by a 9-bit digit, that is, the second type of time stamp can serve both the identification and the real time. Since the preset threshold is generally fragmented data, it is not a large number of digits, so the second type of time stamp, which can represent the real time stamp with 9 digits, is generally larger than the preset threshold, and thus can be The second type of time stamp is used as an identifier for the end of a full data read, or an indication of the beginning of a normal incremental data read.

需要說明的是,時間戳記的取值大於或者等於預設閾值,表示第二設備中的上述裝置發送的請求是一次正常的增量資料讀取請求,此時,第二設備的上述裝置需要將第二設備最近一次訪問第一設備的時刻(即上述的時間戳記指示的時間)至目前時間之間的增量資料讀取過來,在後續的時間裡,上述裝置一直以正常的增量資料同步方式讀取增量資料,直到時間點為整點或者半點為止,即直到上述裝置收到以全量讀取同步方式讀取資料的指示為止,以此類推。 It should be noted that the value of the timestamp is greater than or equal to the preset threshold, and the request sent by the device in the second device is a normal incremental data read request. At this time, the device of the second device needs to be The incremental data between the time when the second device last accessed the first device (ie, the time indicated by the time stamp described above) to the current time is read, and in the subsequent time, the device is always synchronized with the normal incremental data. The method reads the incremental data until the time point is the whole point or half point, that is, until the above device receives the instruction to read the data in full reading synchronous mode, and so on.

需要說明的是,在本發明的實施例中,上述第一設備與第二設備中的上述裝置之間的資料通信可以使用http協議,但不限於此。上述裝置可以應用於網路內容的監控與遮罩領域,比如,第一設備對網路的內容比如涉黃、涉毒、涉暴、以及涉恐內容等進行監控,或者其他設備對該內容進行監控,當監控到這些內容後,將該內容對應的網頁的統一資源定位符或者該內容出現的電腦所在的功能變數名稱記錄下來,然後將這些資料透過上述裝置同步到第二設備,第二設備可以再傳輸給其他設備或者第二設備本身根據獲得到統一資源定位符或者功能變數名稱對這些內容進行遮罩。 It should be noted that, in the embodiment of the present invention, the data communication between the first device and the foregoing device in the second device may use the http protocol, but is not limited thereto. The above device can be applied to the field of monitoring and masking of network content. For example, the first device monitors content of the network such as yellow, poison, violence, and fearful content, or other devices perform the content. Monitoring, after monitoring the content, recording the uniform resource locator of the webpage corresponding to the content or the function variable name of the computer where the content appears, and then synchronizing the data to the second device through the device, the second device It can be retransmitted to other devices or the second device itself masks the content according to the obtained Uniform Resource Locator or Function Variable Name.

實施例5Example 5

本發明的實施例可以提供一種電腦終端,該電腦終端可以是電腦終端群中的任意一個電腦終端設備。可選地,在本實施例中,上述電腦終端也可以替換為行動終端等終端設備。 An embodiment of the present invention may provide a computer terminal, which may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the foregoing computer terminal may also be replaced with a terminal device such as a mobile terminal.

可選地,在本實施例中,上述電腦終端可以位於電腦網路的多個網路設備中的至少一個網路設備。 Optionally, in this embodiment, the computer terminal may be located in at least one network device of the plurality of network devices of the computer network.

在本實施例中,上述電腦終端可以執行應用程式的實施例1中的資料傳輸方法中的步驟的程式碼,具體詳見實施例1,此處不再贅述。 In this embodiment, the computer terminal can execute the code of the step in the data transmission method in the first embodiment of the application. For details, refer to the embodiment 1, and details are not described herein again.

可選地,圖15是根據本發明實施例的一種電腦終端的結構方塊圖。如圖15所示,該電腦終端A可以包括:一個或多個(圖中僅示出一個)處理器1502、記憶體1506、以及傳輸裝置1508。 Optionally, FIG. 15 is a block diagram showing the structure of a computer terminal according to an embodiment of the present invention. As shown in FIG. 15, the computer terminal A may include one or more (only one shown in the figure) processor 1502, memory 1506, and transmission device 1508.

其中,記憶體1506可用於儲存軟體程式以及模組,如本發明實施例中的安全性漏洞檢測方法和裝置對應的程式指令/模組,處理器1502透過運行儲存在記憶體內的軟體程式以及模組,從而執行各種功能應用以及資料處理,即實現上述的系統漏洞攻擊的檢測方法。記憶體1506可包括高速隨機記憶體,還可以包括非易失性記憶體,如一個或者多個磁性儲存裝置、快閃記憶體、或者其他非易失性固態記憶體。在一些實例中,記憶體可進一步包括相對於處理器1502遠端設定的記憶體1506,這些遠端存放器1506可以透過網路連接至終端A。上述網路的實例包括但不限於互聯網、企業內部網、局域網、行動通信網及其組 合。 The memory 1506 can be used to store software programs and modules, such as the security vulnerability detection method and the program instruction/module corresponding to the device in the embodiment of the present invention. The processor 1502 runs the software program and the module stored in the memory. The group, thereby performing various functional applications and data processing, that is, the detection method for implementing the above system vulnerability attack. The memory 1506 can include high speed random memory and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory. In some examples, the memory can further include a memory 1506 that is remotely located relative to the processor 1502, and the remote registers 1506 can be connected to the terminal A via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

處理器1502可以透過傳輸裝置1408調用記憶體1506儲存的資訊及應用程式,以執行實施例1中的步驟的應用程式。 The processor 1502 can invoke the information and application stored in the memory 1506 through the transmission device 1408 to execute the application in the steps in Embodiment 1.

採用本發明實施例,提供了一種電腦終端的方案。透過該電腦終端,執行上述實施例1中的步驟的程式碼,降低了資料讀取的壓力,進而解決了系統之間進行全量更新資料時頻繁失敗的技術問題,提高了資料傳輸的效率。 With the embodiment of the invention, a solution of a computer terminal is provided. Through the computer terminal, the code of the steps in the first embodiment is executed, the pressure of data reading is reduced, and the technical problem of frequent failures when updating the data between the systems is solved, and the efficiency of data transmission is improved.

本領域普通技術人員可以理解,圖15所示的結構僅為示意,電腦終端也可以是智慧手機(如Android手機、iOS手機等)、平板電腦、掌聲電腦以及行動互聯網設備(Mobile Internet Devices,MID)、PAD等終端設備。圖15其並不對上述電子裝置的結構造成限定。例如,電腦終端A還可包括比圖15中所示更多或者更少的元件(如網路介面、顯示裝置等),或者具有與圖15所示不同的配置。 A person skilled in the art can understand that the structure shown in FIG. 15 is only an illustration, and the computer terminal can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, an applause computer, and a mobile Internet device (MID). ), PAD and other terminal devices. Fig. 15 does not limit the structure of the above electronic device. For example, computer terminal A may also include more or fewer components (such as a network interface, display device, etc.) than shown in FIG. 15, or have a different configuration than that shown in FIG.

本領域普通技術人員可以理解上述實施例的各種方法中的全部或部分步驟是可以透過程式來指令終端設備相關的硬體來完成,該程式可以儲存於一電腦可讀儲存媒體中,儲存媒體可以包括:快閃記憶體盤、唯讀記憶體(Read-Only Memory,ROM)、隨機存取記憶體(Random Access Memory,RAM)、磁片或光碟等。 A person skilled in the art can understand that all or part of the steps of the foregoing embodiments can be completed by using a program to instruct a terminal device related hardware, and the program can be stored in a computer readable storage medium, and the storage medium can be Including: flash memory disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk.

實施例6Example 6

本發明的實施例可以提供一種電腦終端,該電腦終端可以是電腦終端群中的任意一個電腦終端設備。可選地,在本實施例中,上述電腦終端也可以替換為行動終端等終端設備。 An embodiment of the present invention may provide a computer terminal, which may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the foregoing computer terminal may also be replaced with a terminal device such as a mobile terminal.

可選地,在本實施例中,上述電腦終端可以位於電腦網路的多個網路設備中的至少一個網路設備。 Optionally, in this embodiment, the computer terminal may be located in at least one network device of the plurality of network devices of the computer network.

在本實施例中,上述電腦終端可以執行應用程式的實施例2中的資料傳輸方法中的步驟的程式碼,具體詳見實施例2,此處不再贅述。 In this embodiment, the computer terminal can execute the code of the step in the data transmission method in the second embodiment of the application. For details, see Embodiment 2, and details are not described herein again.

在本實施例中的電腦終端與實施例5中的電腦終端的結構類似,包括處理器、記憶體以及傳輸裝置,其中,記憶體用於儲存實施例2中的資料傳輸方法的步驟的程式碼,處理器用於透過傳輸裝置調用記憶體儲存的資訊及應用程式,以執行實施例2中的步驟的程式碼。具體步驟詳見實施例2中的方法,此處不再贅述。 The computer terminal in this embodiment is similar in structure to the computer terminal in the embodiment 5, and includes a processor, a memory, and a transmission device, wherein the memory is used to store the code of the step of the data transmission method in the second embodiment. The processor is configured to invoke the information and application stored in the memory through the transmission device to execute the code of the steps in Embodiment 2. For details, refer to the method in Embodiment 2, and details are not described herein again.

實施例7Example 7

本發明的實施例還提供了一種儲存媒體。可選地,在本實施例中,上述儲存媒體可以用於保存上述實施例一所提供的資料傳輸方法所執行的程式碼。 Embodiments of the present invention also provide a storage medium. Optionally, in the embodiment, the storage medium may be used to save the code executed by the data transmission method provided in the first embodiment.

可選地,在本實施例中,上述儲存媒體可以位於電腦網路中電腦終端群中的任意一個電腦終端中,或者位於行動終端群中的任意一個行動終端中。 Optionally, in this embodiment, the storage medium may be located in any one of the computer terminal groups in the computer network, or in any one of the mobile terminal groups.

可選地,在本實施例中,儲存媒體被設定為儲存用於 執行實施例1或者實施例2中的資料傳輸方法的步驟的程式碼,具體步驟詳見實施例1或者實施例2,此處不再贅述。 Optionally, in this embodiment, the storage medium is configured to store a code for performing the steps of the data transmission method in Embodiment 1 or Embodiment 2. For details, see Embodiment 1 or Embodiment 2, I won't go into details here.

上述本發明實施例序號僅僅為了描述,不代表實施例的優劣。 The serial numbers of the embodiments of the present invention are merely for the description, and do not represent the advantages and disadvantages of the embodiments.

在本發明的上述實施例中,對各個實施例的描述都各有側重,某個實施例中沒有詳述的部分,可以參見其他實施例的相關描述。 In the above-mentioned embodiments of the present invention, the descriptions of the various embodiments are different, and the parts that are not detailed in a certain embodiment can be referred to the related descriptions of other embodiments.

在本申請所提供的幾個實施例中,應該理解到,所揭露的技術內容,可透過其它的方式實現。其中,以上所描述的裝置實施例僅僅是示意性的,例如所述單元的劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外的劃分方式,例如多個單元或元件可以結合或者可以集成到另一個系統,或一些特徵可以忽略,或不執行。另一點,所顯示或討論的相互之間的耦合或直接耦合或通信連接可以是透過一些介面,單元或模組的間接耦合或通信連接,可以是電性或其它的形式。 In the several embodiments provided by the present application, it should be understood that the disclosed technical contents may be implemented in other manners. The device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner. For example, multiple units or components may be combined or integrated. Go to another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.

所述作為分離部件說明的單元可以是或者也可以不是物理上分開的,作為單元顯示的部件可以是或者也可以不是物理單元,即可以位於一個地方,或者也可以分佈到多個網路單元上。可以根據實際的需要選擇其中的部分或者全部單元來實現本實施例方案的目的。 The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. . Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.

另外,在本發明各個實施例中的各功能單元可以集成在一個處理單元中,也可以是各個單元單獨物理存在,也 可以兩個或兩個以上單元集成在一個單元中。上述集成的單元既可以採用硬體的形式實現,也可以採用軟體功能單元的形式實現。 In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of a hardware or a software functional unit.

所述集成的單元如果以軟體功能單元的形式實現並作為獨立的產品銷售或使用時,可以儲存在一個電腦可讀取儲存媒體中。基於這樣的理解,本發明的技術方案本質上或者說對現有技術做出貢獻的部分或者該技術方案的全部或部分可以以軟體產品的形式體現出來,該電腦軟體產品儲存在一個儲存媒體中,包括若干指令用以使得一台電腦設備(可為個人電腦、伺服器或者網路設備等)執行本發明各個實施例所述方法的全部或部分步驟。而前述的儲存媒體包括:U盤、唯讀記憶體(ROM,Read-Only Memory)、隨機存取記憶體(RAM,Random Access Memory)、行動硬碟、磁碟或者光碟等各種可以儲存程式碼的媒體。 The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, can be stored in a computer readable storage medium. Based on such an understanding, the technical solution of the present invention may contribute to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium. A number of instructions are included to cause a computer device (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: U disk, read-only memory (ROM), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disc, etc. Media.

以上所述僅是本發明的較佳實施方式,應當指出,對於本技術領域的普通技術人員來說,在不脫離本發明原理的前提下,還可以做出若干改進和潤飾,這些改進和潤飾也應視為本發明的保護範圍。 The above is only a preferred embodiment of the present invention, and it should be noted that those skilled in the art can make several improvements and retouchings without departing from the principles of the present invention. It should also be considered as the scope of protection of the present invention.

Claims (24)

一種資料傳輸方法,其特徵在於,該方法包括:第一設備定時接收來自第二設備的請求訊息,其中,該請求訊息中攜帶有與本次接收的該請求訊息對應的時間戳記;該第一設備判斷該時間戳記的取值是否小於預設閾值;及在該時間戳記的取值小於該預設閾值時,該第一設備按照該時間戳記與該第一設備在本地快取的分片資料的對應關係,將與該時間戳記對應的該分片資料同步至該第二設備,其中,該分片資料為對該第一設備記錄的全量資料進行分片得到。  A data transmission method, the method includes: the first device periodically receives a request message from the second device, where the request message carries a time stamp corresponding to the request message received this time; The device determines whether the value of the timestamp is less than a preset threshold; and when the value of the timestamp is less than the preset threshold, the first device fetches the fragmented data locally with the first device according to the timestamp. Corresponding relationship, the fragment data corresponding to the time stamp is synchronized to the second device, wherein the fragment data is obtained by fragmenting the full amount of data recorded by the first device.   根據申請專利範圍第1項所述的方法,其中,該方法還包括:在該時間戳記的取值等於或者大於該預設閾值時,該第一設備將從該時間戳記指示的時間至目前時間產生的增量資料同步至該第二設備。  The method of claim 1, wherein the method further comprises: when the value of the time stamp is equal to or greater than the preset threshold, the first device will use the time indicated by the time stamp to the current time. The generated incremental data is synchronized to the second device.   根據申請專利範圍第1項所述的方法,其中,該第一設備判斷該時間戳記的取值是否小於預設閾值之前,該方法還包括:該第一設備判斷該時間戳記的取值是否為指定值,其中,該指定值用於指示讀取該全量資料;並且,在判斷結果為是時,觸發將與該時間戳記對應的該分片資料同步至該第二設備。  The method of claim 1, wherein the method further comprises: determining, by the first device, whether the value of the timestamp is the value of the timestamp, if the first device determines whether the value of the timestamp is less than a preset threshold. And a specified value, wherein the specified value is used to indicate that the full amount of data is read; and, when the determination result is yes, triggering to synchronize the fragment data corresponding to the time stamp to the second device.   根據申請專利範圍第1項所述的方法,其中,將與該時間戳記對應的該分片資料同步至該第二設備包括:該第一設備以該時間戳記的取值作為索引,將該第一設備的本地快取中與該索引對應的指定分片資料同步至該第二設備。  The method of claim 1, wherein the synchronizing the fragment data corresponding to the time stamp to the second device comprises: the first device using the value of the time stamp as an index, The specified fragment data corresponding to the index in the local cache of a device is synchronized to the second device.   根據申請專利範圍第1項所述的方法,其中,該分片資料透過以下方式在該第一設備中得到:該第一設備將該第一設備的資料庫中與第一索引n對應的分片資料,寫入該本地快取,並將n-1作為該分片資料在該第一設備的本地快取中的索引,其中,n小於或者等於對該全量資料進行分片後得到的所有分片資料的總數量N,n、N均為正整數。  The method of claim 1, wherein the fragmentation data is obtained in the first device by the first device: the first device corresponding to the first index n in the database of the first device The slice data is written to the local cache, and n-1 is used as an index of the fragment data in the local cache of the first device, where n is less than or equal to all obtained after fragmenting the full amount of data. The total number of pieces of data N, n, and N are positive integers.   根據申請專利範圍第5項所述的方法,其中,該第一設備將該第一設備的資料庫中與該第一索引n對應的分片資料,寫入該本地快取,並將n-1作為該分片資料在該第一設備的本地快取中的索引包括:該第一設備判斷n是否小於N;在n小於N的情況下,該第一設備從該資料庫中讀取n對應的分片資料,並在n對應的分片資料上附上值為n的時間戳記;在n等於N的情況下,該第一設備從該資料庫中讀取與n對應的分片資料,並在與n對應的分片資料上附上值為指定時刻的時間戳記;其中,該指定時刻為該第二設備上一次訪問該第一設備的時刻;及 該第一設備將與n對應的分片資料寫入該本地快取,並將n-1作為該分片資料在該本地快取中的索引。  The method of claim 5, wherein the first device writes the fragment data corresponding to the first index n in the database of the first device to the local cache, and n- The index of the fragment data in the local cache of the first device includes: the first device determines whether n is less than N; and in the case where n is less than N, the first device reads n from the database. Corresponding fragment data, and a time stamp with a value of n is attached to the fragment data corresponding to n; in the case where n is equal to N, the first device reads the fragment data corresponding to n from the database. And attaching, to the fragment data corresponding to n, a time stamp whose value is a specified time; wherein the specified time is a time when the second device accesses the first device last time; and the first device corresponds to n The fragment data is written to the local cache, and n-1 is used as an index of the fragment data in the local cache.   根據申請專利範圍第1至6項中任一項所述的方法,其中,該全量資料包括以下至少之一:針對統一資源定位符的阻斷記錄,針對功能變數名稱的阻斷記錄。  The method of any one of claims 1 to 6, wherein the full amount of data comprises at least one of: a blocking record for a uniform resource locator, a blocking record for a function variable name.   一種資料傳輸方法,其特徵在於,該方法包括:第二設備向第一設備發送請求訊息,其中,該請求訊息中攜帶有與該請求訊息對應的時間戳記;及在該時間戳記的取值小於預設閾值的情況下,該第二設備接收該第一設備發送的分片資料;其中,該分片資料是與該時間戳記對應的在該第一設備本地快取的分片資料,該分片資料為對該第一設備記錄的全量資料進行分片得到。  A data transmission method, the method includes: the second device sends a request message to the first device, where the request message carries a timestamp corresponding to the request message; and the value of the timestamp is less than In the case of a preset threshold, the second device receives the fragment data sent by the first device, where the fragment data is a fragment data locally cached by the first device corresponding to the time stamp. The piece of data is obtained by fragmenting the full amount of data recorded by the first device.   根據申請專利範圍第8項所述的方法,其中,該方法還包括:在該時間戳記的取值等於或者大於該預設閾值的情況下,該第二設備接收該第一設備發送的從該時間戳記指示的時間至目前時間產生的增量資料。  The method of claim 8, wherein the method further comprises: if the value of the time stamp is equal to or greater than the preset threshold, the second device receives the The time indicated by the timestamp to the incremental data generated by the current time.   根據申請專利範圍第8項所述的方法,其中,該第二設備接收該第一設備發送的與該時間戳記對應的該第一設備在本地快取的分片資料之前,該方法還包括:在該時間戳記的取值為指定值的情況下,該第二設備觸發該第一設備發送該全量資料,接收該第一設備發送的與該指定值對應的該分片資料,其中,該指定值用於指示 該第二設備向該第一設備讀取該全量資料。  The method of claim 8, wherein the method further comprises: before the second device receives the fragmented data of the first device that is locally cached by the first device, the method further includes: If the value of the time stamp is a specified value, the second device triggers the first device to send the full amount of data, and receives the fragment data corresponding to the specified value sent by the first device, where the designation The value is used to instruct the second device to read the full amount of data to the first device.   根據申請專利範圍第8項所述的方法,其中,該第二設備接收該第一設備發送的分片資料包括:該第二設備接收在該第一設備的本地快取中與索引對應的指定分片資料;其中,該索引為該時間戳記的取值;及該第二設備接收該第一設備發送的指定時間戳記;其中,該指定時間戳記的取值為由該時間戳記的取值加1得到。  The method of claim 8, wherein the receiving, by the second device, the fragmentation data sent by the first device comprises: the second device receiving the designation corresponding to the index in the local cache of the first device a fragmentation data; wherein the index is a value of the timestamp; and the second device receives the specified timestamp sent by the first device; wherein the value of the specified timestamp is determined by the value of the timestamp 1 get.   根據申請專利範圍第8至11項中任一項所述的方法,其中,該全量資料包括以下至少之一:針對統一資源定位符的阻斷記錄,針對功能變數名稱的阻斷記錄。  The method of any one of clauses 8 to 11, wherein the full amount of data comprises at least one of: a blocking record for a uniform resource locator, a blocking record for a function variable name.   一種資料傳輸裝置,應用於第一設備,其特徵在於,該裝置包括:接收模組,用於定時接收來自第二設備的請求訊息,其中,該請求訊息中攜帶有與本次接收的該請求訊息對應的時間戳記;第一判斷模組,用於判斷該時間戳記的取值是否小於預設閾值;及第一同步模組,用於在該時間戳記的取值小於該預設閾值時,按照該時間戳記與該第一設備在本地快取的分片資料的對應關係,將與該時間戳記對應的該分片資料同步至該第二設備,其中,該分片資料為對該第一設備記錄的全量資料進行分片得到。  A data transmission device is applied to a first device, and the device includes: a receiving module, configured to periodically receive a request message from a second device, where the request message carries the request received this time a timestamp corresponding to the message; the first determining module is configured to determine whether the value of the timestamp is less than a preset threshold; and the first synchronization module is configured to: when the value of the timestamp is less than the preset threshold, And synchronizing the fragment data corresponding to the time stamp to the second device according to the correspondence between the time stamp and the fragmented data of the first device in the local cache, wherein the fragment data is the first The full amount of data recorded by the device is obtained by fragmentation.   根據申請專利範圍第13項所述的裝置,其中,該裝置還包括:第二同步模組,用於在該時間戳記等於或者大於該預設閾值時,將從該時間戳記指示的時間至目前時間產生的增量資料同步至該第二設備。  The device of claim 13, wherein the device further comprises: a second synchronization module, when the time stamp is equal to or greater than the preset threshold, from the time indicated by the time stamp to the current time The incremental data generated by the time is synchronized to the second device.   根據申請專利範圍第13項所述的裝置,其中,該裝置還包括:第二判斷模組,用於判斷該時間戳記的取值是否為指定值,其中,該指定值用於指示讀取該全量資料,其中,在判斷結果為是時,觸發將與該時間戳記對應的該分片資料同步至該第二設備。  The device of claim 13, wherein the device further comprises: a second determining module, configured to determine whether the value of the time stamp is a specified value, wherein the specified value is used to indicate that the reading is performed The full amount of data, wherein, when the determination result is yes, triggering to synchronize the fragment data corresponding to the time stamp to the second device.   根據申請專利範圍第13項所述的裝置,其中,該第一同步模組,還用於以該時間戳記的取值作為索引,將該第一設備的本地快取中與該索引對應的指定分片資料同步至該第二設備。  The device according to claim 13 , wherein the first synchronization module is further configured to use the value of the time stamp as an index to specify the local cache of the first device corresponding to the index. The fragmentation data is synchronized to the second device.   根據申請專利範圍第13項所述的裝置,其中,該裝置還包括:快取模組,用於將該第一設備的資料庫中與第一索引n對應的分片資料,寫入該本地快取,並將n-1作為該分片資料在該第一設備的本地快取中的索引,其中,n小於或者等於對該全量資料進行分片後得到的所有分片資料的總數量N,n、N均為正整數。  The device of claim 13, wherein the device further comprises: a cache module, configured to write the fragment data corresponding to the first index n in the database of the first device to the local device Cache, and use n-1 as an index of the fragment data in the local cache of the first device, where n is less than or equal to the total number of all the fragment data obtained after fragmenting the full amount of data. , n, N are positive integers.   根據申請專利範圍第17項所述的裝置,其中,該快取模組包括: 判斷單元,用於判斷n是否小於N;第一讀取單元,用於在n小於N的情況下,從該資料庫中讀取n對應的分片資料,並在n對應的分片資料上附上值為n的時間戳記;第二讀取單元,用於在n等於N的情況下,從該資料庫中讀取與n對應的分片資料,並在與n對應的分片資料上附上值為指定時刻的時間戳記;其中,該指定時刻為該第二設備上一次訪問該第一設備的時刻;及暫存單元,用於將與n對應的分片資料寫入該本地快取,並將n-1作為該分片資料在該本地快取中的索引。  The device of claim 17, wherein the cache module comprises: a judging unit configured to determine whether n is less than N; and a first reading unit configured to: when n is less than N, The data corresponding to n is read in the database, and a time stamp with a value of n is attached to the fragment data corresponding to n; the second reading unit is configured to use the database when n is equal to N. Reading the fragment data corresponding to n, and attaching a timestamp value of the specified time to the fragment data corresponding to n; wherein the specified time is the time when the second device accesses the first device last time And a temporary storage unit, configured to write the fragment data corresponding to n to the local cache, and use n-1 as an index of the fragment data in the local cache.   根據申請專利範圍第13至18項中任一項所述的裝置,其中,該全量資料包括以下至少之一:針對統一資源定位符的阻斷記錄,針對功能變數名稱的阻斷記錄。  The apparatus of any one of claims 13 to 18, wherein the full amount of data comprises at least one of: a blocked record for a uniform resource locator, a blocked record for a function variable name.   一種資料傳輸裝置,應用於第二設備,其特徵在於,該裝置包括:發送模組,用於向第一設備發送請求訊息,其中,該請求訊息中攜帶有與該請求訊息對應的時間戳記;及第一接收模組,用於在該時間戳記的取值小於預設閾值的情況下,接收該第一設備發送的分片資料;其中,該分片資料是與該時間戳記對應的在該第一設備本地快取的分片資料,該分片資料為該第一設備記錄的全量資料進行分片得到。  A data transmission device is applied to a second device, and the device includes: a sending module, configured to send a request message to the first device, where the request message carries a time stamp corresponding to the request message; And receiving, by the first receiving module, the fragmentation data sent by the first device, where the value of the timestamp is less than a preset threshold; wherein the fragmentation data is corresponding to the timestamp The fragmented data of the first device locally cached, and the fragmentation data is obtained by fragmenting the full amount of data recorded by the first device.   根據申請專利範圍第20項所述的裝置,其中,該裝置還包括: 第二接收模組,用於在該時間戳記的取值等於或者大於該預設閾值的情況下,接收該第一設備發送的從該時間戳記指示的時間至目前時間產生的增量資料。  The device of claim 20, wherein the device further comprises: a second receiving module, configured to receive the first device if the value of the time stamp is equal to or greater than the preset threshold The incremental data sent from the time indicated by the timestamp to the current time.   根據申請專利範圍第20項所述的裝置,其中,該裝置還包括:觸發模組,用於在該時間戳記的取值為指定值的情況下,觸發該第一設備發送該全量資料;及第三接收模組,用於接收該第一設備發送的與該指定值對應的該分片資料,其中,該指定值用於指示該第二設備向該第一設備讀取該全量資料。  The device of claim 20, wherein the device further comprises: a triggering module, configured to trigger the first device to send the full amount of data if the value of the timestamp is a specified value; and The third receiving module is configured to receive the fragment data that is sent by the first device and corresponding to the specified value, where the specified value is used to instruct the second device to read the full amount of data to the first device.   根據申請專利範圍第20項所述的裝置,其中,該第一接收模組包括:第一接收單元,用於接收在該第一設備的本地快取中與索引對應的指定分片資料;其中,該索引為該時間戳記的取值;及第二接收單元,用於接收該第一設備發送的指定時間戳記;其中,該指定時間戳記的取值為由該時間戳記的取值加1得到。  The device according to claim 20, wherein the first receiving module comprises: a first receiving unit, configured to receive the specified fragment data corresponding to the index in the local cache of the first device; The index is a value of the timestamp; and the second receiving unit is configured to receive the specified timestamp sent by the first device, where the value of the specified timestamp is obtained by adding 1 to the timestamp .   根據申請專利範圍第20至23項中任一項所述的裝置,其中,該全量資料包括以下至少之一:針對統一資源定位符的阻斷記錄,針對功能變數名稱的阻斷記錄。  The apparatus of any one of claims 20 to 23, wherein the full amount of data comprises at least one of: a blocking record for a uniform resource locator, a blocking record for a function variable name.  
TW106102231A 2017-01-20 2017-01-20 Data transmission method and device TWI738709B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW106102231A TWI738709B (en) 2017-01-20 2017-01-20 Data transmission method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW106102231A TWI738709B (en) 2017-01-20 2017-01-20 Data transmission method and device

Publications (2)

Publication Number Publication Date
TW201828082A true TW201828082A (en) 2018-08-01
TWI738709B TWI738709B (en) 2021-09-11

Family

ID=63960536

Family Applications (1)

Application Number Title Priority Date Filing Date
TW106102231A TWI738709B (en) 2017-01-20 2017-01-20 Data transmission method and device

Country Status (1)

Country Link
TW (1) TWI738709B (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7500020B1 (en) * 2003-12-31 2009-03-03 Symantec Operating Corporation Coherency of replicas for a distributed file sharing system
JP2006155817A (en) * 2004-11-30 2006-06-15 Toshiba Corp Signal output apparatus and signal output method
US8621108B2 (en) * 2008-05-08 2013-12-31 Dialogic Corporation System and method for monitoring user interface connectivity state
EP2178230A1 (en) * 2008-10-14 2010-04-21 Thomson Licensing Performance improvement of dual mode devices for data over cable applications

Also Published As

Publication number Publication date
TWI738709B (en) 2021-09-11

Similar Documents

Publication Publication Date Title
WO2017067415A1 (en) Data transmission method and device
US10855643B2 (en) Bluetooth low energy address resolving
CN107851267B (en) System and method for synchronizing data related to voice calls via dynamically assigned virtual phone numbers
TW202008157A (en) Wake-up, information pushing method and apparatus, computing device, and storage medium
CN103530362B (en) A kind of computer data reading/writing method for many copies distributed system
US9800488B2 (en) Method for setting heartbeat timer, terminal and server
CN111711611B (en) Data processing method, device, medium, equipment and application based on block chain
WO2020173231A1 (en) Resource request method, device and storage medium
CN108989043B (en) Block processing method and device and block link points
CN111352994B (en) Data synchronization method and related equipment and device
CN110830138B (en) Information processing method, electronic equipment and server
CN111694836B (en) Telemetry data error detection
WO2021068891A1 (en) Method, system, electronic device, and storage medium for storing and collecting temperature data
TW201828082A (en) Data transmission method and device solving the technical problem of frequent failures when full volume of data is updated
CN108460044B (en) Data processing method and device
CN111063183B (en) Bluetooth-based electric energy meter statistical method and device and storage medium
US10171613B2 (en) Client device, server, recording medium and information processing method
CN107038195B (en) Data synchronization method and device
KR20160026138A (en) Rapid sync method for cloud file system and cloud file system using the same
CN108810948B (en) Method for identifying real flow
CN113472469B (en) Data synchronization method, device, equipment and storage medium
TWI599260B (en) Local communication wireless network system and method thereof
CN113691614B (en) Information processing method and device
CN108768773B (en) Method for identifying real flow based on IP address
CN113077615B (en) Alarm information processing method and device and electronic equipment