[go: up one dir, main page]

CN105095354A - Data updating method and data updating device - Google Patents

Data updating method and data updating device Download PDF

Info

Publication number
CN105095354A
CN105095354A CN201510346871.3A CN201510346871A CN105095354A CN 105095354 A CN105095354 A CN 105095354A CN 201510346871 A CN201510346871 A CN 201510346871A CN 105095354 A CN105095354 A CN 105095354A
Authority
CN
China
Prior art keywords
cache
update
lock
switching
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510346871.3A
Other languages
Chinese (zh)
Inventor
潘青
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201510346871.3A priority Critical patent/CN105095354A/en
Publication of CN105095354A publication Critical patent/CN105095354A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching

Landscapes

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

Abstract

The invention discloses a data updating method and a data updating device. The data updating method comprises the following steps: writing updated data in an updated cache; storing the updated data in the updated cache in a storage to backup; and switching between the updated cache and a used cache, switching the original updated cache into the used cache, and switching the original used cache into the updated cache. The data updating method and the data updating device disclosed by the invention have the benefits that: the problem of slow data updating speed is solved; the data updating speed is increased; and thus, the service interruption time is reduced.

Description

数据更新的方法及装置Method and device for updating data

技术领域technical field

本发明涉及通信技术,具体涉及一种数据更新的方法及装置。The invention relates to communication technology, in particular to a method and device for updating data.

背景技术Background technique

随着网络爬虫抓取技术的发展,可以从互联网中实时获得数据,并可以使用这些数据开展相关业务。如何将使用的数据更新为实时获取的互联网中数据成为需要解决的问题。With the development of web crawler crawling technology, data can be obtained from the Internet in real time, and related businesses can be carried out using these data. How to update the used data to real-time Internet data has become a problem to be solved.

现有技术中,将获取的互联网中数据存储到硬盘存储器中,利用硬盘存储器进行数据更新。例如,将更新的数据存储到硬盘中,再将给更新数据读取到缓存中,具体应用中使用缓存中数据完成任务。此种方法缺陷在于,受硬盘存储器读取速度的限制,致使数据更新速度较慢。In the prior art, the acquired data in the Internet is stored in a hard disk storage, and the hard disk storage is used for data update. For example, store the updated data in the hard disk, and then read the updated data into the cache, and use the data in the cache to complete tasks in specific applications. The defect of this method is that, due to the limitation of the reading speed of the hard disk memory, the data updating speed is relatively slow.

发明内容Contents of the invention

鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的数据更新的方法及装置。In view of the above problems, the present invention is proposed to provide a data updating method and device for overcoming the above problems or at least partially solving the above problems.

依据本发明的一个方面,提供了一种数据更新的方法,所述方法包括:According to one aspect of the present invention, a method for updating data is provided, the method comprising:

将更新数据写入更新缓存中;Write the update data into the update cache;

将更新缓存中的更新数据存储到存储器中进行备份;storing the update data in the update cache into a memory for backup;

在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。Switch between update cache and use cache, switch the original update cache to use cache, and switch the original use cache to update cache.

可选地,所述在更新缓存与使用缓存间进行切换,具体包括:Optionally, the switching between updating the cache and using the cache specifically includes:

将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。The pointer of the update cache is exchanged with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache.

可选地,所述更新缓存具有更新锁,所述方法还包括:Optionally, the update cache has an update lock, and the method further includes:

当更新缓存与使用缓存间进行切换时,将所述更新锁锁定,以禁止对更新缓存进行写操作。When switching between updating the cache and using the cache, the update lock is locked to prohibit writing operations on the update cache.

可选地,所述方法还包括:Optionally, the method also includes:

当更新缓存与使用缓存间切换完成后,将所述更新锁解锁,以允许对更新缓存进行写操作。After the switch between updating the cache and using the cache is completed, the update lock is unlocked to allow writing operations on the update cache.

可选地,所述将所述更新锁锁定,以禁止对更新缓存进行写操作,具体包括:Optionally, the locking the update lock to prohibit writing operations on the update cache specifically includes:

将更新缓存的更新锁锁定;Lock the update lock of the update cache;

当接收到进程发送的对更新缓存的写请求时,判定更新缓存的更新锁的状态为锁定;When the write request to the update cache sent by the process is received, it is determined that the state of the update lock of the update cache is locked;

指示发送写请求的进程进行等待。Instructs the process sending the write request to wait.

可选地,所述将所述更新锁解锁,以允许对更新缓存进行写操作,具体包括:Optionally, the unlocking the update lock to allow the write operation to the update cache specifically includes:

将更新缓存的更新锁解锁;Unlock the update lock of the update cache;

将更新锁分配给发送写请求的进程,使所述进程对更新缓存进行写操作,并将更新锁锁定;Assign the update lock to the process sending the write request, make the process write the update cache, and lock the update lock;

在所述进程完成写操作后,解锁更新锁。After the process completes the write operation, the update lock is unlocked.

可选地,所述使用缓存具有切换锁,所述方法还包括:Optionally, the use cache has a toggle lock, and the method further includes:

当更新缓存与使用缓存间进行切换时,将所述切换锁锁定,以禁止对使用缓存进行读操作。When switching between updating the cache and using the cache, the switching lock is locked to prohibit reading operations on the using cache.

可选地,所述方法还包括:Optionally, the method also includes:

当更新缓存与使用缓存间切换完成后,将所述切换锁解锁,以允许对使用缓存进行读操作。After the switching between updating the cache and using the cache is completed, the switching lock is unlocked to allow a read operation on the using cache.

可选地,所述将所述切换锁锁定,以禁止对使用缓存进行读操作,具体包括:Optionally, the locking the switching lock to prohibit the read operation of the usage cache specifically includes:

将使用缓存的切换锁锁定;Lock the toggle lock using the cache;

当接收到进程发送的对使用缓存的读请求时,判定使用缓存的切换锁的状态为锁定;When receiving the read request sent by the process to use the cache, it is determined that the status of the switching lock using the cache is locked;

指示发送读请求的进程进行等待。Instructs the process sending the read request to wait.

可选地,所述将所述切换锁解锁,以允许对使用缓存进行读操作,具体包括:Optionally, the unlocking the switching lock to allow a read operation on the usage cache specifically includes:

将使用缓存的切换锁解锁;Unlock the toggle lock using the cache;

将切换锁分配给发送读请求的进程,使所述进程对使用缓存读操作,并将切换锁锁定;Assign the switch lock to the process that sends the read request, make the process use the cache read operation, and lock the switch lock;

在所述进程完成读操作后,解锁切换锁。After the process completes the read operation, the toggle lock is unlocked.

根据本发明的另一方面,提供了一种数据更新的装置,所述装置包括:According to another aspect of the present invention, a device for updating data is provided, the device comprising:

写入模块,适于将更新数据写入更新缓存中;A write module, adapted to write update data into the update cache;

备份模块,适于将更新缓存中的更新数据存储到存储器中进行备份;A backup module, adapted to store the update data in the update cache in the memory for backup;

切换模块,适于在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。The switch module is suitable for switching between the update cache and the use cache, switching the original update cache to the use cache, and switching the original use cache to the update cache.

可选地,所述切换模块,具体适于将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。Optionally, the switching module is specifically adapted to exchange the pointer of the update cache with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache.

可选地,所述更新缓存具有更新锁,所述装置还包括:Optionally, the update cache has an update lock, and the device further includes:

锁定模块,适于当更新缓存与使用缓存间进行切换时,将所述更新锁锁定,以禁止对更新缓存进行写操作。The locking module is adapted to lock the update lock when switching between updating the cache and using the cache, so as to prohibit writing operations on the update cache.

可选地,所述装置还包括:Optionally, the device also includes:

解锁模块,适于当更新缓存与使用缓存间切换完成后,将所述更新锁解锁,以允许对更新缓存进行写操作。The unlocking module is adapted to unlock the update lock after the switch between the update cache and the use cache is completed, so as to allow writing operations on the update cache.

可选地,所述锁定模块,具体包括:Optionally, the locking module specifically includes:

锁定子模块,适于当更新缓存与使用缓存间进行切换时,将更新缓存的更新锁锁定;The locking submodule is suitable for locking the update lock of the update cache when switching between updating the cache and using the cache;

判定子模块,适于当接收到进程发送的对更新缓存的写请求时,判定更新缓存的更新锁的状态为锁定;The judging submodule is adapted to determine that the state of the update lock of the update cache is locked when receiving the write request sent by the process to the update cache;

指示子模块,适于指示发送写请求的进程进行等待。The indication submodule is adapted to instruct the process sending the write request to wait.

可选地,所述解锁模块,具体包括:Optionally, the unlocking module specifically includes:

第一解锁子模块,适于当更新缓存与使用缓存间切换完成后,将更新缓存的更新锁解锁;The first unlocking submodule is adapted to unlock the update lock of the update cache after the switch between the update cache and the use cache is completed;

分配子模块,适于将更新锁分配给发送写请求的进程,使所述进程对更新缓存进行写操作,并将更新锁锁定;The allocation submodule is adapted to assign the update lock to the process sending the write request, so that the process performs a write operation on the update cache and locks the update lock;

第二解锁子模块,适于在所述进程完成写操作后,解锁更新锁。The second unlocking submodule is adapted to unlock the update lock after the process completes the write operation.

可选地,所述使用缓存具有切换锁,所述装置还包括:Optionally, the use cache has a toggle lock, and the device further includes:

锁定模块,适于当更新缓存与使用缓存间进行切换时,将所述切换锁锁定,以禁止对使用缓存进行读操作。The locking module is adapted to lock the switching lock when switching between updating the cache and using the cache, so as to prohibit reading operations on the using cache.

可选地,所述装置还包括:Optionally, the device also includes:

解锁模块,适于当更新缓存与使用缓存间切换完成后,将所述切换锁解锁,以允许对使用缓存进行读操作。The unlocking module is adapted to unlock the switch lock after the switching between the update cache and the use cache is completed, so as to allow the read operation on the use cache.

可选地,所述锁定模块,具体包括:Optionally, the locking module specifically includes:

锁定子模块,适于当更新缓存与使用缓存间进行切换时,将使用缓存的切换锁锁定;The locking sub-module is suitable for locking the switching lock of the cache when switching between updating the cache and using the cache;

判定子模块,适于当接收到进程发送的对使用缓存的读请求时,判定使用缓存的切换锁的状态为锁定;The judging submodule is adapted to determine that the state of the switching lock using the cache is locked when a read request for using the cache is received from the process;

指示子模块,适于指示发送读请求的进程进行等待。The indication submodule is adapted to instruct the process sending the read request to wait.

可选地,所述解锁模块,具体包括:Optionally, the unlocking module specifically includes:

第一解锁子模块,适于当更新缓存与使用缓存间切换完成后,将使用缓存的切换锁解锁;The first unlocking sub-module is suitable for unlocking the switching lock of the cache when the switch between the update cache and the cache is completed;

分配子模块,适于将切换锁分配给发送读请求的进程,使所述进程对使用缓存进行读操作,并将切换锁锁定;The distribution submodule is suitable for distributing the switch lock to the process sending the read request, so that the process performs a read operation on the use cache and locks the switch lock;

第二解锁子模块,适于在所述进程完成读操作后,解锁切换锁。The second unlocking submodule is adapted to unlock the switching lock after the process completes the read operation.

根据本发明的技术方案可以将更新数据写入更新缓存中,将更新缓存中的更新数据存储到存储器中进行备份,在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。如此,既在存储器中备份了更新数据保证更新数据不会丢失,又通过在更新缓存与使用缓存间进行切换,完成数据更新,使得更新速度显著提高,由此解决了数据更新速度较慢的问题,取得了提高数据更新速度,进而减少业务中断时间的有益效果。According to the technical solution of the present invention, the update data can be written into the update cache, the update data in the update cache can be stored in the memory for backup, the update cache and the use cache can be switched, the original update cache can be switched to the use cache, and the update cache can be switched to the use cache. Switch from using cache to update cache. In this way, the update data is backed up in the memory to ensure that the update data will not be lost, and the data update is completed by switching between the update cache and the use cache, so that the update speed is significantly improved, thus solving the problem of slow data update speed , which has the beneficial effect of increasing the data update speed and reducing the service interruption time.

上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention, it can be implemented according to the contents of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable , the specific embodiments of the present invention are enumerated below.

附图说明Description of drawings

通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiment. The drawings are only for the purpose of illustrating a preferred embodiment and are not to be considered as limiting the invention. Also throughout the drawings, the same reference numerals are used to designate the same components. In the attached picture:

图1示出了根据本发明一个实施例的数据更新的方法的流程图;Fig. 1 shows the flowchart of the method for updating data according to one embodiment of the present invention;

图2示出了根据本发明一个实施例的禁止对更新缓存进行写操作的方法的流程图;FIG. 2 shows a flow chart of a method for prohibiting writing operations to an update cache according to an embodiment of the present invention;

图3示出了根据本发明一个实施例的允许对更新缓存进行写操作的方法的流程图;FIG. 3 shows a flow chart of a method for allowing a write operation to an update cache according to an embodiment of the present invention;

图4示出了根据本发明一个实施例的禁止对使用缓存进行读操作的方法的流程图;FIG. 4 shows a flow chart of a method for prohibiting a read operation on a usage cache according to an embodiment of the present invention;

图5示出了根据本发明一个实施例的允许对使用缓存进行读操作的方法的流程图;FIG. 5 shows a flowchart of a method for allowing a read operation to use a cache according to an embodiment of the present invention;

图6示出了根据本发明一个实施例的数据更新的方法的流程图;FIG. 6 shows a flowchart of a method for updating data according to an embodiment of the present invention;

图7示出了根据本发明一个实施例的数据更新的装置的结构图;FIG. 7 shows a structural diagram of a device for updating data according to an embodiment of the present invention;

图8示出了根据本发明一个实施例的数据更新的装置的结构图;以及FIG. 8 shows a structural diagram of a device for updating data according to an embodiment of the present invention; and

图9示出了根据本发明一个实施例的数据更新的装置的结构图。Fig. 9 shows a structural diagram of an apparatus for updating data according to an embodiment of the present invention.

具体实施方式Detailed ways

下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided for more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

图1示出了根据本发明一个实施例的数据更新的方法的流程图,该方法可用于各种设备,例如网络中服务提供商的各种业务服务器、及各种终端。如图1所示,该方法包括如下步骤S110-S130。Fig. 1 shows a flowchart of a method for updating data according to an embodiment of the present invention, and the method can be used in various devices, such as various service servers of service providers in the network, and various terminals. As shown in Fig. 1, the method includes the following steps S110-S130.

在步骤S110中,将更新数据写入更新缓存中。In step S110, update data is written into the update cache.

举例而言,服务器接收到数据源所在设备发送的更新数据,服务器将更新数据写入更新缓存中。当写入的更新数据达到预设数量时。例如更新缓存被写满时,开始执行后续更新缓存与使用缓存间进行切换的步骤。For example, the server receives the update data sent by the device where the data source is located, and the server writes the update data into the update cache. When the updated data written reaches the preset number. For example, when the update cache is full, a subsequent step of switching between updating the cache and using the cache is performed.

在步骤S120中,将更新缓存中的更新数据存储到存储器中进行备份。In step S120, the update data in the update cache is stored in the memory for backup.

举例而言,将更新缓存中的更新数据存到设备硬盘中进行备份,以免因更新缓存与使用缓存间进行切换时发生故障,而造成更新数据丢失。For example, the update data in the update cache is stored in the hard disk of the device for backup, so as to avoid the loss of update data due to a failure when switching between updating the cache and using the cache.

在步骤S130中,在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。In step S130, switch between the updated cache and the used cache, switch the original updated cache to the used cache, and switch the original used cache to the updated cache.

在一实施例中,所述在更新缓存与使用缓存间进行切换,具体包括:将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。In an embodiment, the switching between the update cache and the use cache specifically includes: exchanging the pointer of the update cache with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache .

本实施例中,通过更新缓存与使用缓存间指针交换的方式,实现更新缓存与使用缓存间切换,从而完成数据更新,使得业务能够及时使用更新后的数据为用户提供服务。采用此种数据更新方式,使得更新速度显著提高,由此解决了数据更新速度较慢的问题,取得了提高数据更新速度,进而减少业务中断时间的有益效果。In this embodiment, by exchanging pointers between the update cache and the use cache, the switch between the update cache and the use cache is realized, thereby completing the data update, so that the service can use the updated data to provide services for users in a timely manner. The adoption of this data update method significantly increases the update speed, thereby solving the problem of slow data update speed and achieving the beneficial effects of increasing the data update speed and reducing service interruption time.

在一实施例中,更新缓存具有更新锁,方法还包括:当更新缓存与使用缓存间进行切换时,将更新锁锁定,以禁止对更新缓存进行写操作。In an embodiment, the update cache has an update lock, and the method further includes: when switching between updating the cache and using the cache, locking the update lock to prohibit writing operations on the update cache.

进一步地,方法还包括:当更新缓存与使用缓存间切换完成后,将更新锁解锁,以允许对更新缓存进行写操作。Further, the method further includes: after the switch between updating the cache and using the cache is completed, unlocking the update lock to allow writing operations on the update cache.

举例而言,当进程对更新缓存进行写操作时,进程获得解锁状态的更新锁,将更新锁状态置为锁定,并对更新缓存进行写操作。其他进程要对更新缓存进行写操作时,查询发现更新锁状态为锁定,进行等待,等到更新锁状态为解锁后,该等待的进程获得解锁状态的更新锁,将更新锁状态置为锁定,并对更新缓存进行写操作。如此,当更新缓存与使用缓存间进行切换时,将更新锁锁定,从而禁止对更新缓存进行写操作。当更新缓存与使用缓存间切换完成后,解锁更新锁,从而允许对更新缓存进行写操作。For example, when a process performs a write operation on the update cache, the process obtains an update lock in an unlocked state, sets the update lock state to locked, and performs a write operation on the update cache. When other processes want to write to the update cache, the query finds that the update lock status is locked, and waits. After the update lock status is unlocked, the waiting process obtains the update lock in the unlocked status, sets the update lock status to locked, and Write operations to the update cache. In this way, when switching between updating the cache and using the cache, the update lock is locked, thereby prohibiting the write operation on the update cache. After the switch between updating the cache and using the cache is completed, the update lock is unlocked to allow writing operations on the update cache.

例如,如图2所示,所述将更新锁锁定,以禁止对更新缓存进行写操作,可包括如下步骤S210-S230。For example, as shown in FIG. 2 , the locking of the update lock to prohibit writing operations on the update cache may include the following steps S210-S230.

在步骤S210中,将更新缓存的更新锁锁定。In step S210, the update lock for updating the cache is locked.

在步骤S220中,当接收到进程发送的对更新缓存的写请求时,判定更新缓存的更新锁的状态为锁定。In step S220, when a write request to the update cache sent by the process is received, it is determined that the status of the update lock of the update cache is locked.

在步骤S230中,指示发送写请求的进程进行等待。In step S230, instruct the process sending the write request to wait.

又例如,如图3所示,所述将更新锁解锁,以允许对更新缓存进行写操作,可包括如下步骤S310-S330。For another example, as shown in FIG. 3 , unlocking the update lock to allow the write operation to the update cache may include the following steps S310-S330.

在步骤S310中,将更新缓存的更新锁解锁。In step S310, the update lock for updating the cache is unlocked.

在步骤S320中,将更新锁分配给发送写请求的进程,使进程对更新缓存进行写操作,并将更新锁锁定。In step S320, the update lock is assigned to the process sending the write request, so that the process performs a write operation on the update cache and locks the update lock.

在步骤S330中,当进程完成写操作后,解锁更新锁。In step S330, after the process completes the write operation, the update lock is unlocked.

在本实施例中,通过更新缓存的更新锁,保证在更新缓存与使用缓存间进行切换时,没有进程对更新缓存进行写操作,保证更新缓存中数据的稳定性。In this embodiment, by updating the update lock of the cache, it is ensured that no process writes to the update cache when switching between the update cache and the use cache, thereby ensuring the stability of data in the update cache.

在一实施例中,使用缓存具有切换锁,方法还包括:当更新缓存与使用缓存间进行切换时,将切换锁锁定,以禁止对使用缓存进行读操作。In an embodiment, the use cache has a switching lock, and the method further includes: when switching between updating the cache and using the cache, locking the switch lock to prohibit reading operations on the use cache.

进一步地,方法还包括:当更新缓存与使用缓存间切换完成后,将切换锁解锁,以允许对使用缓存进行读操作。Further, the method further includes: after the switching between the update cache and the use cache is completed, unlocking the switch lock to allow the read operation on the use cache.

举例而言,当进程对使用缓存进行读操作时,进程获得解锁状态的切换锁,将切换锁状态置为锁定,并对使用缓存进行读操作。其他进程要对使用缓存进行读操作时,查询发现切换锁状态为锁定,进行等待,等到切换锁状态为解锁后,该等待的进程获得解锁状态的切换锁,将切换锁状态置为锁定,并对使用缓存进行读操作。如此,当更新缓存与使用缓存间进行切换时,将切换锁锁定,从而禁止对使用缓存进行读操作。当更新缓存与使用缓存间切换完成后,解锁切换锁,从而允许对使用缓存进行读操作。For example, when a process performs a read operation on the use cache, the process obtains a switch lock in an unlocked state, sets the switch lock state to locked, and performs a read operation on the use cache. When other processes want to read the cache, the query finds that the switching lock status is locked, and waits until the switching lock status is unlocked, the waiting process obtains the switching lock in the unlocked state, sets the switching lock status to locked, and Use the cache for read operations. In this way, when switching between updating the cache and using the cache, the switching lock is locked, thereby prohibiting the read operation on the using cache. After the switch between updating the cache and using the cache is completed, the switch lock is unlocked to allow read operations on the using cache.

例如,如图4所示,所述将切换锁锁定,以禁止对使用缓存进行读操作,可包括如下步骤S410-S430。For example, as shown in FIG. 4 , the locking the switching lock to prohibit the read operation on the cache may include the following steps S410-S430.

在步骤S410中,将使用缓存的切换锁锁定。In step S410, the cached switching lock is locked.

在步骤S420中,当接收到进程发送的对使用缓存的读请求时,判定使用缓存的切换锁的状态为锁定。In step S420, when a read request for using the cache is received from the process, it is determined that the status of the switch lock for using the cache is locked.

在步骤S430中,指示发送读请求的进程进行等待。In step S430, instruct the process sending the read request to wait.

又例如,如图5所示,所述将切换锁解锁,以允许对使用缓存进行读操作,可包括如下步骤S510-S530。For another example, as shown in FIG. 5 , unlocking the switching lock to allow a read operation on the usage cache may include the following steps S510-S530.

在步骤S510中,将使用缓存的切换锁解锁。In step S510, the cached switching lock is unlocked.

在步骤S520中,将切换锁分配给发送读请求的进程,使进程对使用缓存进行读操作,并将切换锁锁定。In step S520, the switch lock is allocated to the process that sends the read request, so that the process performs a read operation on the usage cache and locks the switch lock.

在步骤S530中,当进程完成读操作后,解锁切换锁。In step S530, after the process completes the read operation, the switching lock is unlocked.

在本实施例中,通过使用缓存的切换锁,保证在更新缓存与使用缓存间进行切换时,没有进程对使用缓存进行读操作,保证使用缓存中数据的稳定性。In this embodiment, by using the switching lock of the cache, it is ensured that no process performs a read operation on the cache when switching between updating the cache and using the cache, thereby ensuring the stability of data in the cache.

图6示出了根据本发明一个实施例的数据更新的方法的流程图,该方法可用于各种服务器,例如网络中服务提供商的各种业务服务器。如图6所示,该方法包括如下步骤S602-S610。其中,更新缓存具有更新锁,使用缓存具有切换锁。Fig. 6 shows a flow chart of a method for updating data according to an embodiment of the present invention, and the method can be used in various servers, such as various service servers of service providers in the network. As shown in Fig. 6, the method includes the following steps S602-S610. Among them, the update cache has an update lock, and the use cache has a switch lock.

在步骤S602中,将更新数据写入更新缓存中。In step S602, update data is written into the update cache.

在步骤S604中,将更新缓存中的更新数据存储到存储器中进行备份。In step S604, the update data in the update cache is stored in the memory for backup.

在步骤S606中,将更新锁锁定,以禁止对更新缓存进行写操作,将切换锁锁定,以禁止对使用缓存进行读操作。In step S606, the update lock is locked to prohibit the write operation on the update cache, and the switching lock is locked to prohibit the read operation on the use cache.

在步骤S608中,将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。In step S608, the pointer of the update cache is exchanged with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache.

在步骤S610中,当更新缓存与使用缓存间切换完成后,将更新锁解锁,以允许对更新缓存进行写操作,将切换锁解锁,以允许对使用缓存进行读操作。In step S610, after the switch between the update cache and the use cache is completed, the update lock is unlocked to allow writing operations to the update cache, and the switching lock is unlocked to allow read operations to the use cache.

本实施例中,通过更新缓存与使用缓存间指针交换的方式,实现更新缓存与使用缓存间切换,从而完成数据更新,使得业务能够及时使用更新后的数据为用户提供服务。采用此种数据更新方式,使得更新速度显著提高,由此解决了数据更新速度较慢的问题,取得了提高数据更新速度,进而减少业务中断时间的有益效果。In this embodiment, by exchanging pointers between the update cache and the use cache, the switch between the update cache and the use cache is realized, thereby completing the data update, so that the service can use the updated data to provide services for users in a timely manner. The adoption of this data update method significantly increases the update speed, thereby solving the problem of slow data update speed and achieving the beneficial effects of increasing the data update speed and reducing service interruption time.

上述仅为本发明的数据更新的方法的实例性说明,本发明不限于此。凡在本发明的精神或原则之内所作的任何修改、等同替换、改进等,均包含在本发明的保护范围内。The foregoing is only an example description of the method for updating data in the present invention, and the present invention is not limited thereto. Any modification, equivalent replacement, improvement, etc. made within the spirit or principle of the present invention are included in the protection scope of the present invention.

图7示出了根据本发明一个实施例的数据更新的装置的结构图,该装置可用于各种设备,例如网络中服务提供商的各种业务服务器、及各种终端。如图7所示,该装置包括如下模块。Fig. 7 shows a structural diagram of an apparatus for updating data according to an embodiment of the present invention, and the apparatus can be used in various devices, such as various service servers of service providers in the network, and various terminals. As shown in Figure 7, the device includes the following modules.

写入模块710,适于将更新数据写入更新缓存中;A write module 710, adapted to write update data into the update cache;

备份模块720,适于将更新缓存中的更新数据存储到存储器中进行备份;The backup module 720 is adapted to store the update data in the update cache in the memory for backup;

切换模块730,适于在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。The switching module 730 is adapted to switch between the update cache and the use cache, switching the original update cache to the use cache, and switching the original use cache to the update cache.

在一实施例中,切换模块730,具体适于将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。In one embodiment, the switching module 730 is specifically adapted to exchange the pointer of the update cache with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache.

在一实施例中,如图8所示,更新缓存具有更新锁,装置还包括:In one embodiment, as shown in FIG. 8, the update cache has an update lock, and the device also includes:

锁定模块810,适于当更新缓存与使用缓存间进行切换时,将更新锁锁定,以禁止对更新缓存进行写操作。The lock module 810 is adapted to lock the update lock when switching between updating the cache and using the cache, so as to prohibit writing operations on the update cache.

在一实施例中,如图8所示,装置还包括:In one embodiment, as shown in Figure 8, the device further includes:

解锁模块820,适于当更新缓存与使用缓存间切换完成后,将更新锁解锁,以允许对更新缓存进行写操作。The unlocking module 820 is adapted to unlock the update lock after the switch between the update cache and the use cache is completed, so as to allow writing operations on the update cache.

在一实施例中,如图9所示,锁定模块810,具体包括:In one embodiment, as shown in FIG. 9, the locking module 810 specifically includes:

锁定子模块812,适于当更新缓存与使用缓存间进行切换时,将更新缓存的更新锁锁定;The locking submodule 812 is adapted to lock the update lock of the update cache when switching between updating the cache and using the cache;

判定子模块814,适于当接收到进程发送的对更新缓存的写请求时,判定更新缓存的更新锁的状态为锁定;The determination submodule 814 is adapted to determine that the state of the update lock of the update cache is locked when receiving the write request sent by the process to the update cache;

指示子模块816,适于指示发送写请求的进程进行等待。The instructing submodule 816 is adapted to instruct the process sending the write request to wait.

在一实施例中,如图9所示,解锁模块820,具体包括:In one embodiment, as shown in FIG. 9, the unlocking module 820 specifically includes:

第一解锁子模块822,适于当更新缓存与使用缓存间切换完成后,将更新缓存的更新锁解锁;The first unlocking submodule 822 is adapted to unlock the update lock of the update cache after the switch between the update cache and the use cache is completed;

分配子模块824,适于将更新锁分配给发送写请求的进程,使进程对更新缓存进行写操作,并将更新锁锁定;The allocation submodule 824 is adapted to allocate the update lock to the process sending the write request, so that the process performs a write operation on the update cache and locks the update lock;

第二解锁子模块826,适于在进程完成写操作后,解锁更新锁。The second unlocking submodule 826 is adapted to unlock the update lock after the process completes the write operation.

在一实施例中,如图8所示,使用缓存具有切换锁,装置还包括:In one embodiment, as shown in FIG. 8, the cache is used to switch locks, and the device further includes:

锁定模块810,适于当更新缓存与使用缓存间进行切换时,将切换锁锁定,以禁止对使用缓存进行读操作。The locking module 810 is adapted to lock the switching lock when switching between updating the cache and using the cache, so as to prohibit reading operations on the using cache.

锁定模块810可以分别具有将更新缓存的更新锁锁定和使用缓存的切换锁锁定的功能,也可以同时具有将更新缓存的更新锁锁定和使用缓存的切换锁锁定的功能。The locking module 810 may have the functions of locking the update lock for updating the cache and the switching lock for using the cache respectively, or may simultaneously have the functions of locking the update lock for updating the cache and the switching lock for using the cache.

在一实施例中,如图8所示,装置还包括:In one embodiment, as shown in Figure 8, the device further includes:

解锁模块820,适于当更新缓存与使用缓存间切换完成后,将切换锁解锁,以允许对使用缓存进行读操作。The unlocking module 820 is adapted to unlock the switch lock after the switch between the update cache and the use cache is completed, so as to allow the read operation on the use cache.

解锁模块820可以分别具有将更新缓存的更新锁解锁和使用缓存的切换锁解锁的功能,也可以同时具有将更新缓存的更新锁解锁和使用缓存的切换锁解锁的功能。The unlocking module 820 may have the functions of unlocking the update lock for updating the cache and unlocking the switching lock for using the cache respectively, or may simultaneously have the functions of unlocking the update lock for updating the cache and unlocking the switching lock for using the cache.

在一实施例中,如图9所示,锁定模块810,具体包括:In one embodiment, as shown in FIG. 9, the locking module 810 specifically includes:

锁定子模块812,适于当更新缓存与使用缓存间进行切换时,将使用缓存的切换锁锁定;The locking submodule 812 is adapted to lock the switching lock of the cache when switching between updating the cache and using the cache;

判定子模块814,适于当接收到进程发送的对使用缓存的读请求时,判定使用缓存的切换锁的状态为锁定;The judging submodule 814 is adapted to determine that the state of the switching lock using the cache is locked when receiving a read request sent by the process for using the cache;

指示子模块816,适于指示发送读请求的进程进行等待。The instructing submodule 816 is adapted to instruct the process sending the read request to wait.

在一实施例中,如图9所示,解锁模块820,具体包括:In one embodiment, as shown in FIG. 9, the unlocking module 820 specifically includes:

第一解锁子模块822,适于当更新缓存与使用缓存间切换完成后,将使用缓存的切换锁解锁;The first unlocking submodule 822 is adapted to unlock the switch lock for using the cache after the switch between updating the cache and using the cache is completed;

分配子模块824,适于将切换锁分配给发送读请求的进程,使进程对使用缓存进行读操作,并将切换锁锁定;The allocation submodule 824 is adapted to assign the switch lock to the process sending the read request, so that the process can perform a read operation on the use cache and lock the switch lock;

第二解锁子模块826,适于在进程完成读操作后,解锁切换锁。The second unlocking submodule 826 is adapted to unlock the switching lock after the process completes the read operation.

关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the apparatus in the foregoing embodiments, the specific manner in which each module executes operations has been described in detail in the embodiments related to the method, and will not be described in detail here.

本发明公开了如下技术方案。The invention discloses the following technical solutions.

A1、一种数据更新的方法,所述方法包括:A1, a method for updating data, said method comprising:

将更新数据写入更新缓存中;Write the update data into the update cache;

将更新缓存中的更新数据存储到存储器中进行备份;storing the update data in the update cache into a memory for backup;

在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。Switch between update cache and use cache, switch the original update cache to use cache, and switch the original use cache to update cache.

A2、根据A1所述的方法,其中,所述在更新缓存与使用缓存间进行切换,具体包括:A2. The method according to A1, wherein the switching between updating the cache and using the cache specifically includes:

将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。The pointer of the update cache is exchanged with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache.

A3、根据A1所述的方法,其中,所述更新缓存具有更新锁,所述方法还包括:A3. The method according to A1, wherein the update cache has an update lock, and the method also includes:

当更新缓存与使用缓存间进行切换时,将所述更新锁锁定,以禁止对更新缓存进行写操作。When switching between updating the cache and using the cache, the update lock is locked to prohibit writing operations on the update cache.

A4、根据A3所述的方法,其中,所述方法还包括:A4. The method according to A3, wherein the method also includes:

当更新缓存与使用缓存间切换完成后,将所述更新锁解锁,以允许对更新缓存进行写操作。After the switch between updating the cache and using the cache is completed, the update lock is unlocked to allow writing operations on the update cache.

A5、根据A3所述的方法,其中,所述将所述更新锁锁定,以禁止对更新缓存进行写操作,具体包括:A5. The method according to A3, wherein the locking the update lock to prohibit writing to the update cache specifically includes:

将更新缓存的更新锁锁定;Lock the update lock of the update cache;

当接收到进程发送的对更新缓存的写请求时,判定更新缓存的更新锁的状态为锁定;When the write request to the update cache sent by the process is received, it is determined that the state of the update lock of the update cache is locked;

指示发送写请求的进程进行等待。Instructs the process sending the write request to wait.

A6、根据A4所述的方法,其中,所述将所述更新锁解锁,以允许对更新缓存进行写操作,具体包括:A6. The method according to A4, wherein the unlocking the update lock to allow the write operation to the update cache specifically includes:

将更新缓存的更新锁解锁;Unlock the update lock of the update cache;

将更新锁分配给发送写请求的进程,使所述进程对更新缓存进行写操作,并将更新锁锁定;Assign the update lock to the process sending the write request, make the process write the update cache, and lock the update lock;

在所述进程完成写操作后,解锁更新锁。After the process completes the write operation, the update lock is unlocked.

A7、根据A1所述的方法,其中,所述使用缓存具有切换锁,所述方法还包括:A7. The method according to A1, wherein the use of the cache has a switching lock, and the method also includes:

当更新缓存与使用缓存间进行切换时,将所述切换锁锁定,以禁止对使用缓存进行读操作。When switching between updating the cache and using the cache, the switching lock is locked to prohibit reading operations on the using cache.

A8、根据A7所述的方法,其中,所述方法还包括:A8. The method according to A7, wherein the method also includes:

当更新缓存与使用缓存间切换完成后,将所述切换锁解锁,以允许对使用缓存进行读操作。After the switching between updating the cache and using the cache is completed, the switching lock is unlocked to allow a read operation on the using cache.

A9、根据A7所述的方法,其中,所述将所述切换锁锁定,以禁止对使用缓存进行读操作,具体包括:A9. The method according to A7, wherein the locking the switching lock to prohibit the read operation of the usage cache specifically includes:

将使用缓存的切换锁锁定;Lock the toggle lock using the cache;

当接收到进程发送的对使用缓存的读请求时,判定使用缓存的切换锁的状态为锁定;When receiving the read request sent by the process to use the cache, it is determined that the status of the switching lock using the cache is locked;

指示发送读请求的进程进行等待。Instructs the process sending the read request to wait.

A10、根据A8所述的方法,其中,所述将所述切换锁解锁,以允许对使用缓存进行读操作,具体包括:A10. The method according to A8, wherein the unlocking the switching lock to allow a read operation on the usage cache specifically includes:

将使用缓存的切换锁解锁;Unlock the toggle lock using the cache;

将切换锁分配给发送读请求的进程,使所述进程对使用缓存读操作,并将切换锁锁定;Assign the switch lock to the process that sends the read request, make the process use the cache read operation, and lock the switch lock;

在所述进程完成读操作后,解锁切换锁。After the process completes the read operation, the toggle lock is unlocked.

B11、一种数据更新的装置,所述装置包括:B11, a device for updating data, said device comprising:

写入模块,适于将更新数据写入更新缓存中;A write module, adapted to write update data into the update cache;

备份模块,适于将更新缓存中的更新数据存储到存储器中进行备份;A backup module, adapted to store the update data in the update cache in the memory for backup;

切换模块,适于在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。The switch module is suitable for switching between the update cache and the use cache, switching the original update cache to the use cache, and switching the original use cache to the update cache.

B12、根据B11所述的装置,其中,所述切换模块,具体适于将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。B12. The device according to B11, wherein the switching module is specifically adapted to exchange the pointer of the update cache with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache.

B13、根据B11所述的装置,其中,所述更新缓存具有更新锁,所述装置还包括:B13. The device according to B11, wherein the update cache has an update lock, and the device also includes:

锁定模块,适于当更新缓存与使用缓存间进行切换时,将所述更新锁锁定,以禁止对更新缓存进行写操作。The locking module is adapted to lock the update lock when switching between updating the cache and using the cache, so as to prohibit writing operations on the update cache.

B14、根据B13所述的装置,其中,所述装置还包括:B14. The device according to B13, wherein the device also includes:

解锁模块,适于当更新缓存与使用缓存间切换完成后,将所述更新锁解锁,以允许对更新缓存进行写操作。The unlocking module is adapted to unlock the update lock after the switch between the update cache and the use cache is completed, so as to allow writing operations on the update cache.

B15、根据B13所述的装置,其中,所述锁定模块,具体包括:B15. The device according to B13, wherein the locking module specifically includes:

锁定子模块,适于当更新缓存与使用缓存间进行切换时,将更新缓存的更新锁锁定;The locking submodule is suitable for locking the update lock of the update cache when switching between updating the cache and using the cache;

判定子模块,适于当接收到进程发送的对更新缓存的写请求时,判定更新缓存的更新锁的状态为锁定;The judging submodule is adapted to determine that the state of the update lock of the update cache is locked when receiving the write request sent by the process to the update cache;

指示子模块,适于指示发送写请求的进程进行等待。The indication submodule is adapted to instruct the process sending the write request to wait.

B16、根据B14所述的装置,其中,所述解锁模块,具体包括:B16. The device according to B14, wherein the unlocking module specifically includes:

第一解锁子模块,适于当更新缓存与使用缓存间切换完成后,将更新缓存的更新锁解锁;The first unlocking submodule is adapted to unlock the update lock of the update cache after the switch between the update cache and the use cache is completed;

分配子模块,适于将更新锁分配给发送写请求的进程,使所述进程对更新缓存进行写操作,并将更新锁锁定;The allocation submodule is adapted to assign the update lock to the process sending the write request, so that the process performs a write operation on the update cache and locks the update lock;

第二解锁子模块,适于在所述进程完成写操作后,解锁更新锁。The second unlocking submodule is adapted to unlock the update lock after the process completes the write operation.

B17、根据B11所述的装置,其中,所述使用缓存具有切换锁,所述装置还包括:B17. The device according to B11, wherein the use cache has a switching lock, and the device also includes:

锁定模块,适于当更新缓存与使用缓存间进行切换时,将所述切换锁锁定,以禁止对使用缓存进行读操作。The locking module is adapted to lock the switching lock when switching between updating the cache and using the cache, so as to prohibit reading operations on the using cache.

B18、根据B17所述的装置,其中,所述装置还包括:B18. The device according to B17, wherein the device also includes:

解锁模块,适于当更新缓存与使用缓存间切换完成后,将所述切换锁解锁,以允许对使用缓存进行读操作。The unlocking module is adapted to unlock the switch lock after the switching between the update cache and the use cache is completed, so as to allow the read operation on the use cache.

B19、根据B17所述的装置,其中,所述锁定模块,具体包括:B19. The device according to B17, wherein the locking module specifically includes:

锁定子模块,适于当更新缓存与使用缓存间进行切换时,将使用缓存的切换锁锁定;The locking sub-module is suitable for locking the switching lock of the cache when switching between updating the cache and using the cache;

判定子模块,适于当接收到进程发送的对使用缓存的读请求时,判定使用缓存的切换锁的状态为锁定;The judging submodule is adapted to determine that the state of the switching lock using the cache is locked when a read request for using the cache is received from the process;

指示子模块,适于指示发送读请求的进程进行等待。The indication submodule is adapted to instruct the process sending the read request to wait.

B20、根据B18所述的装置,其中,所述解锁模块,具体包括:B20. The device according to B18, wherein the unlocking module specifically includes:

第一解锁子模块,适于当更新缓存与使用缓存间切换完成后,将使用缓存的切换锁解锁;The first unlocking sub-module is suitable for unlocking the switching lock of the cache when the switch between the update cache and the cache is completed;

分配子模块,适于将切换锁分配给发送读请求的进程,使所述进程对使用缓存进行读操作,并将切换锁锁定;The distribution submodule is suitable for distributing the switch lock to the process sending the read request, so that the process performs a read operation on the use cache and locks the switch lock;

第二解锁子模块,适于在所述进程完成读操作后,解锁切换锁。The second unlocking submodule is adapted to unlock the switching lock after the process completes the read operation.

需要说明的是:It should be noted:

在此提供的算法和显示不与任何特定计算机、虚拟装置或者其它设备固有相关。各种通用装置也可以与基于在此的示教一起使用。根据上面的描述,构造这类装置所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays presented herein are not inherently related to any particular computer, virtual appliance, or other device. Various general purpose devices can also be used with the teachings based on this. The structure required to construct such an apparatus will be apparent from the foregoing description. Furthermore, the present invention is not specific to any particular programming language. It should be understood that various programming languages can be used to implement the content of the present invention described herein, and the above description of specific languages is for disclosing the best mode of the present invention.

在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure the understanding of this description.

类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, in order to streamline this disclosure and to facilitate an understanding of one or more of the various inventive aspects, various features of the invention are sometimes grouped together in a single embodiment, figure, or its description. This method of disclosure, however, is not to be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.

本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art can understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. Modules or units or components in the embodiments may be combined into one module or unit or component, and furthermore may be divided into a plurality of sub-modules or sub-units or sub-assemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method or method so disclosed may be used in any combination, except that at least some of such features and/or processes or units are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.

此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Furthermore, those skilled in the art will understand that although some embodiments described herein include some features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention. and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.

本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的数据更新设备中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components in the data updating device according to the embodiment of the present invention. The present invention can also be implemented as an apparatus or an apparatus program (for example, a computer program and a computer program product) for performing a part or all of the methods described herein. Such a program for realizing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet site, or provided on a carrier signal, or provided in any other form.

应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means can be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. does not indicate any order. These words can be interpreted as names.

Claims (10)

1.一种数据更新的方法,所述方法包括:1. A method for data update, said method comprising: 将更新数据写入更新缓存中;Write the update data into the update cache; 将更新缓存中的更新数据存储到存储器中进行备份;storing the update data in the update cache into a memory for backup; 在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。Switch between update cache and use cache, switch the original update cache to use cache, and switch the original use cache to update cache. 2.根据权利要求1所述的方法,其中,所述在更新缓存与使用缓存间进行切换,具体包括:2. The method according to claim 1, wherein the switching between updating the cache and using the cache specifically comprises: 将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。The pointer of the update cache is exchanged with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache. 3.根据权利要求1所述的方法,其中,所述更新缓存具有更新锁,所述方法还包括:3. The method according to claim 1, wherein the update cache has an update lock, the method further comprising: 当更新缓存与使用缓存间进行切换时,将所述更新锁锁定,以禁止对更新缓存进行写操作。When switching between updating the cache and using the cache, the update lock is locked to prohibit writing operations on the update cache. 4.根据权利要求3所述的方法,其中,所述方法还包括:4. The method of claim 3, wherein the method further comprises: 当更新缓存与使用缓存间切换完成后,将所述更新锁解锁,以允许对更新缓存进行写操作。After the switch between updating the cache and using the cache is completed, the update lock is unlocked to allow writing operations on the update cache. 5.根据权利要求3所述的方法,其中,所述将所述更新锁锁定,以禁止对更新缓存进行写操作,具体包括:5. The method according to claim 3, wherein the locking the update lock to prohibit writing operations to the update cache specifically comprises: 将更新缓存的更新锁锁定;Lock the update lock of the update cache; 当接收到进程发送的对更新缓存的写请求时,判定更新缓存的更新锁的状态为锁定;When the write request to the update cache sent by the process is received, it is determined that the state of the update lock of the update cache is locked; 指示发送写请求的进程进行等待。Instructs the process sending the write request to wait. 6.一种数据更新的装置,所述装置包括:6. A device for updating data, said device comprising: 写入模块,适于将更新数据写入更新缓存中;A write module, adapted to write update data into the update cache; 备份模块,适于将更新缓存中的更新数据存储到存储器中进行备份;A backup module, adapted to store the update data in the update cache in the memory for backup; 切换模块,适于在更新缓存与使用缓存间进行切换,将原更新缓存切换为使用缓存,将原使用缓存切换为更新缓存。The switch module is suitable for switching between the update cache and the use cache, switching the original update cache to the use cache, and switching the original use cache to the update cache. 7.根据权利要求6所述的装置,其中,所述切换模块,具体适于将更新缓存的指针与使用缓存的指针进行交换,使原更新缓存切换为使用缓存,原使用缓存切换为更新缓存。7. The device according to claim 6, wherein the switching module is specifically adapted to exchange the pointer of the update cache with the pointer of the use cache, so that the original update cache is switched to the use cache, and the original use cache is switched to the update cache . 8.根据权利要求6所述的装置,其中,所述更新缓存具有更新锁,所述装置还包括:8. The apparatus according to claim 6, wherein the update cache has an update lock, the apparatus further comprising: 锁定模块,适于当更新缓存与使用缓存间进行切换时,将所述更新锁锁定,以禁止对更新缓存进行写操作。The locking module is adapted to lock the update lock when switching between updating the cache and using the cache, so as to prohibit writing operations on the update cache. 9.根据权利要求8所述的装置,其中,所述装置还包括:9. The apparatus of claim 8, wherein the apparatus further comprises: 解锁模块,适于当更新缓存与使用缓存间切换完成后,将所述更新锁解锁,以允许对更新缓存进行写操作。The unlocking module is adapted to unlock the update lock after the switch between the update cache and the use cache is completed, so as to allow writing operations on the update cache. 10.根据权利要求8所述的装置,其中,所述锁定模块,具体包括:10. The device according to claim 8, wherein the locking module specifically comprises: 锁定子模块,适于当更新缓存与使用缓存间进行切换时,将更新缓存的更新锁锁定;The locking submodule is suitable for locking the update lock of the update cache when switching between updating the cache and using the cache; 判定子模块,适于当接收到进程发送的对更新缓存的写请求时,判定更新缓存的更新锁的状态为锁定;The judging submodule is adapted to determine that the state of the update lock of the update cache is locked when receiving the write request sent by the process to the update cache; 指示子模块,适于指示发送写请求的进程进行等待。The indication submodule is adapted to instruct the process sending the write request to wait.
CN201510346871.3A 2015-06-19 2015-06-19 Data updating method and data updating device Pending CN105095354A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510346871.3A CN105095354A (en) 2015-06-19 2015-06-19 Data updating method and data updating device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510346871.3A CN105095354A (en) 2015-06-19 2015-06-19 Data updating method and data updating device

Publications (1)

Publication Number Publication Date
CN105095354A true CN105095354A (en) 2015-11-25

Family

ID=54575791

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510346871.3A Pending CN105095354A (en) 2015-06-19 2015-06-19 Data updating method and data updating device

Country Status (1)

Country Link
CN (1) CN105095354A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106294607A (en) * 2016-07-29 2017-01-04 北京奇虎科技有限公司 Data cached update method and updating device
CN107038174A (en) * 2016-02-04 2017-08-11 北京京东尚科信息技术有限公司 Method of data synchronization and device for data system
CN110086719A (en) * 2019-04-30 2019-08-02 深圳市腾讯网域计算机网络有限公司 Data processing method, device and server
CN110597646A (en) * 2019-09-16 2019-12-20 五八有限公司 Data reading and writing method and system, electronic equipment and storage medium
CN112286873A (en) * 2020-10-30 2021-01-29 西安奥卡云数据科技有限公司 Hash tree caching method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030225976A1 (en) * 2002-06-04 2003-12-04 Erdem Hokenek Method and apparatus for multithreaded cache with simplified implementation of cache replacement policy
CN101236530A (en) * 2008-01-30 2008-08-06 清华大学 A Dynamic Selection Method of Cache Replacement Policy
CN101631328A (en) * 2009-08-14 2010-01-20 北京星网锐捷网络技术有限公司 Synchronous method performing mutual exclusion access on shared resource, device and network equipment
CN102137139A (en) * 2010-09-26 2011-07-27 华为技术有限公司 Method and device for selecting cache replacement strategy, proxy server and system
CN103095686A (en) * 2012-12-19 2013-05-08 华为技术有限公司 Hot metadata access control method and server
CN103207841A (en) * 2013-03-06 2013-07-17 青岛海信传媒网络技术有限公司 Method and device for data reading and writing on basis of key-value buffer
CN104537119A (en) * 2015-01-26 2015-04-22 浪潮通信信息系统有限公司 Update method of cache data, data use terminal and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030225976A1 (en) * 2002-06-04 2003-12-04 Erdem Hokenek Method and apparatus for multithreaded cache with simplified implementation of cache replacement policy
CN101236530A (en) * 2008-01-30 2008-08-06 清华大学 A Dynamic Selection Method of Cache Replacement Policy
CN101631328A (en) * 2009-08-14 2010-01-20 北京星网锐捷网络技术有限公司 Synchronous method performing mutual exclusion access on shared resource, device and network equipment
CN102137139A (en) * 2010-09-26 2011-07-27 华为技术有限公司 Method and device for selecting cache replacement strategy, proxy server and system
CN103095686A (en) * 2012-12-19 2013-05-08 华为技术有限公司 Hot metadata access control method and server
CN103207841A (en) * 2013-03-06 2013-07-17 青岛海信传媒网络技术有限公司 Method and device for data reading and writing on basis of key-value buffer
CN104537119A (en) * 2015-01-26 2015-04-22 浪潮通信信息系统有限公司 Update method of cache data, data use terminal and system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107038174A (en) * 2016-02-04 2017-08-11 北京京东尚科信息技术有限公司 Method of data synchronization and device for data system
CN107038174B (en) * 2016-02-04 2020-11-24 北京京东尚科信息技术有限公司 Data synchronization method and device for data system
CN106294607A (en) * 2016-07-29 2017-01-04 北京奇虎科技有限公司 Data cached update method and updating device
CN110086719A (en) * 2019-04-30 2019-08-02 深圳市腾讯网域计算机网络有限公司 Data processing method, device and server
CN110597646A (en) * 2019-09-16 2019-12-20 五八有限公司 Data reading and writing method and system, electronic equipment and storage medium
CN112286873A (en) * 2020-10-30 2021-01-29 西安奥卡云数据科技有限公司 Hash tree caching method and device

Similar Documents

Publication Publication Date Title
CN104636181B (en) For migrating the method and system of virtual machine
CN105095354A (en) Data updating method and data updating device
US20110138102A1 (en) Data storage management using a distributed cache scheme
CN108322325B (en) Virtual machine management method and device
CN104281468A (en) Method and system for distributed virtual machine image management
CN109886693B (en) Consensus realization method, device, equipment and medium for block chain system
CN109408751A (en) A kind of data processing method, terminal, server and storage medium
CN108319496A (en) resource access method, service server, distributed system and storage medium
EP2998862A1 (en) Method, device, and system for memory management
JP2016508349A (en) Service migration across cluster boundaries
CN103716416B (en) IP configuration method and apparatus under cloud computing platform
US20190004870A1 (en) Hierarchical process group management
US12155621B2 (en) Network address translation between networks
CN109992415B (en) A container scheduling method and scheduling system
CN104954474A (en) Method and device for data updating in load balancing
CN109522043A (en) Method and device for managing configuration data and storage medium
CN103631869A (en) Method and device for releasing access pressure of server-side database
CN105791080A (en) Group message processing method and system, and electronic device
CN108292268A (en) System, method and apparatus for distributed consensus memory
US10652094B2 (en) Network traffic management for virtualized graphics devices
CN107209643B (en) Storage resource management in virtualized environment
US12248815B2 (en) Client-configurable retention periods for machine learning service-managed resources
US20220405135A1 (en) Scheduling in a container orchestration system utilizing hardware topology hints
JP2005182787A (en) Key cache management through multiple localities
US11281666B2 (en) Interception of database queries for delegation to an in memory data grid

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20151125