WO2017092351A1 - Cache data update method and device - Google Patents

Cache data update method and device Download PDF

Info

Publication number
WO2017092351A1
WO2017092351A1 PCT/CN2016/089482 CN2016089482W WO2017092351A1 WO 2017092351 A1 WO2017092351 A1 WO 2017092351A1 CN 2016089482 W CN2016089482 W CN 2016089482W WO 2017092351 A1 WO2017092351 A1 WO 2017092351A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
keyword key
response data
request information
mapping relationship
Prior art date
Application number
PCT/CN2016/089482
Other languages
French (fr)
Chinese (zh)
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 US15/246,528 priority Critical patent/US20170155712A1/en
Publication of WO2017092351A1 publication Critical patent/WO2017092351A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • 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

Definitions

  • the embodiments of the present invention relate to the field of Internet technologies, and in particular, to a method and an apparatus for updating cache data.
  • the web server takes the Uniform Resource Locator (URL) sent by the client as a key, and sends the URL to the service server, and the web server receives the return result corresponding to the URL sent by the service server, and returns the result.
  • URL Uniform Resource Locator
  • the key-value is stored in pairs in the cache server.
  • the web server sets the expiration time of the key-value, as long as the client sends the next request information about the key within the expiration time, the web server.
  • the value corresponding to the key is obtained from the cache server, and the value is sent to the client to reduce the load of the service server and reduce the response delay of the client.
  • the service server identifies different data values by the data ID. However, when the data value corresponding to the data ID in the service server changes, if the client sends the request information about the key within the expiration time, the data value obtained by the client is still the old data value stored in the cache server. For the same key, and during the expiration time of the cache server, the update of the data value of the service server and the update of the data value in the cache server are not updated synchronously, that is, the real-time value of the data stored in the cache server is poor, resulting in poor performance. Guest The data acquired by the client user is data with errors; especially when the data acquired by the client user is data that requires high real-time performance, such as data such as live events and weather forecasts, and data obtained by the client with errors. , greatly reducing the user experience of the client user.
  • the embodiment of the invention provides a method and a device for updating cache data, and the main purpose is to synchronously update the data value in the cache server and the data value in the service server for the same keyword key in the cache server and the service server, thereby improving the client.
  • the end user gets the user experience of the real-time data value.
  • An embodiment of the present invention provides a method for updating cache data, including:
  • the service server sends the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and establishes a mapping relationship between the keyword key and the data ID; wherein, in the data request information
  • the keyword key is generated, and the keyword key is generated by the web server.
  • the web server After receiving the response data, stores the keyword key and its corresponding response data in a cache server.
  • the data ID is a unique identifier for storing the response data by the service server;
  • An embodiment of the present invention provides an apparatus for updating cached data, including:
  • a sending unit configured to send, according to the data request information sent by the web server, response data corresponding to the data request information to the web server;
  • a establishing unit configured to establish a mapping relationship between the keyword key and the data ID; wherein the data request information includes the keyword key, the keyword key is generated by the web server, and the web server receives After the response data, the keyword key and its corresponding response data are stored in a cache server, where the data ID is a unique identifier of the service server storing the response data;
  • a monitoring unit configured to monitor whether the response data corresponding to the data ID in the mapping relationship established in the establishing unit is updated
  • An acquiring unit configured to acquire the keyword key based on the mapping relationship when it is determined that the response data corresponding to the data ID monitored by the monitoring unit is updated;
  • a deleting unit configured to delete the keyword key and the corresponding response data in the cache server according to the keyword key acquired by the acquiring unit.
  • An embodiment of the present invention provides an electronic device, including:
  • One or more processors are One or more processors.
  • the memory stores instructions that are configured to be executed by the one or more processors, and the one or more processors can perform the following operations by executing the instructions:
  • the data request information includes the keyword key
  • the keyword key is generated by the web server
  • the web server receives the response data And storing the keyword key and its corresponding response data in a cache server, where the data ID is a unique identifier of the service server storing the response data;
  • Embodiments of the present invention provide a non-volatile computer readable storage medium in which a program capable of updating cache data is recorded, the program causing a computer to perform the following steps:
  • the data request information includes the keyword key
  • the keyword key is generated by the web server
  • the web server receives the response data And storing the keyword key and its corresponding response data in a cache server, where the data ID is a unique identifier of the service server storing the response data;
  • the method and device for updating the cached data provided by the embodiment of the present invention, after receiving the data request information sent by the web server, the service server asynchronously processes the request information, including: sending the response data corresponding to the data request information to the web a server and a mapping relationship between the keyword key and the data ID, wherein the data request information includes a keyword key, and the keyword key is generated by the web server, and when the web server receives the response data, the keyword key And the response data is stored in the cache server, the data ID is a unique identifier of the service server storing the response data; the service server monitors whether the response data corresponding to the data ID is updated based on the mapping relationship between the established keyword key and the data ID.
  • the embodiment of the present invention passes the established data ID and The mapping relationship between the key words, and the response data corresponding to the data ID is monitored in real time to ensure that the response data obtained by the client user is the real-time updated response data, so as to improve the accuracy of the client user to obtain the response data, and then Improve the user experience of client users.
  • FIG. 1 is a flowchart of a method for updating cache data according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram showing data interaction between a client, a web server, a cache server, and a service server;
  • FIG. 3 is a block diagram showing the structure of an apparatus for updating cached data according to an embodiment of the present invention
  • FIG. 4 is a block diagram showing the composition of another cache data updating apparatus according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a service server according to an embodiment of the present invention.
  • the embodiment of the invention provides a method for updating cache data, which is applied to the service server side. As shown in FIG. 1 , the method includes:
  • the service server sends the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and establishes a mapping relationship between the keyword key and the data ID.
  • the association relationship between the client, the web server, the cache server, and the service server will be described in detail by way of example.
  • the figure includes N clients and N cache servers, where N is a positive integer greater than 2; the client is based on HTTP-Hypertext transfer protocol (HTTP).
  • HTTP HTTP-Hypertext transfer protocol
  • the web server sends data request information, where the data request information includes a Uniform Resource Locator (URL).
  • URL Uniform Resource Locator
  • the web server After receiving the data request sent by the client, the web server generates a keyword key according to the URL, and based on the keyword, The key sends the response data value corresponding to the keyword key to the cache server.
  • URL Uniform Resource Locator
  • the response data value corresponding to the keyword key exists in the cache server, the response data value is obtained, and the response data value is sent to the client; if the cache server is If the response data value corresponding to the keyword key does not exist, the web server sends the data request information to the service server, where the data request information carries the keyword key, and after receiving the data request information sent by the web server, the service server Asynchronous processing, the asynchronous processing includes: performing data request information Should the information corresponding to the data request sent in response to the data value of the web server, and establishing a mapping relationship between key data and key ID.
  • the data request information includes the keyword key, and the keyword key is generated by the web server, and after receiving the response data value, the web server sends the keyword key and its corresponding response.
  • the data value is stored in a cache server, and the data ID is a unique identifier of the service server storing the response data value.
  • the data ID and the keyword key have a one-to-one mapping relationship, and the mapping is
  • the system is stored in the service server, and the keyword key and the response data value are also in a one-to-one correspondence, which is stored in the cache server, and the web server, the cache server, and the service server can communicate with each other.
  • the response data value corresponding to the keyword key is stored in the cache server, it indicates that the response data value is consistent with the response data value corresponding to the data ID in the service server, that is, the response data value is the latest. Response data.
  • the web server can communicate with the plurality of cache servers, wherein the cache server is a distributed cache server, and can respond to the data request information sent by the client in time.
  • the web server determine the timeliness of the cache server response data request information.
  • the web server encrypts the keyword key, and the encrypted keyword key is a random character.
  • the string server stores the keyword key randomly in the cache server, which improves the dispersibility of the keyword key and reduces the load on the cache server due to the excessive concentration of the keyword key.
  • the encryption of the keyword key and its corresponding data value may be implemented by, but not limited to, the following implementation manners, for example, a hash algorithm hash, including a message digest algorithm (MD5), and a specific embodiment of the present invention.
  • a hash algorithm hash including a message digest algorithm (MD5), and a specific embodiment of the present invention.
  • MD5 message digest algorithm
  • the implementation algorithm is not limited.
  • the web server is When the service server sends the data request information, if only the keyword key is sent, the service server cannot identify the specific data request information in the keyword key, and cannot respond to the web server. Therefore, the web server requests data from the service server. When you need to carry the keyword key into the data request information.
  • the web server has the most keyword key, and performs MD5 encryption operation on the keyword key.
  • the encrypted keyword key is: 9afbd22506aff85cc6dd395a57b1471d, and the encrypted keyword key of the web server is added to the data request information.
  • the service server sends the information to the service server, so that the service server can establish a mapping relationship with the data ID according to the keyword key.
  • the service server monitors whether the response data corresponding to the data ID is updated.
  • the data ID in the service server is not updated, but the data ID is The corresponding response data value is updated at any time, and the update change time is random. Therefore, the service server needs to monitor the response data value corresponding to the data ID to determine whether the response data value corresponding to the data ID is updated. .
  • the service server acquires the keyword key based on the mapping relationship, and deletes the keyword key and the corresponding response data in the cache server.
  • the value of the response data corresponding to the data ID is not updated when the service server performs the step 102, if the response data value is stored in the cache server, the value of the response data in the service server is consistent with the value of the response data stored in the cache server. Therefore, there is no need to actively invalidate the response data value in the cache server, and the active failure is to actively delete the response data value in the expiration time of the response data value in the cache server. If the value of the response data corresponding to the data ID is updated by the service server when the step 102 is performed, if the value of the response data is stored in the cache server, the value of the response data in the service server is inconsistent with the value of the response data stored in the cache server. Therefore, the response data value in the cache server needs to be actively invalidated, so that the response data value obtained by the client user is real-time updated data.
  • the active invalidation of the response data value in the cache server by the service server includes: first, the service server searches for and determines the keyword key corresponding to the data ID according to the mapping relationship between the keyword key and the data ID established in step 101; The response data value corresponding to the keyword key is obtained according to the keyword key; finally, the keyword key and its corresponding response data value are deleted.
  • the web server re-stores the keyword key and the corresponding response data value in the cache server.
  • the web server after receiving the response data value sent by the service server, stores the ⁇ keyword key, the response data value, and the expiration time expire> in the cache server, where The expiration time expire is set by the web server. If the service server does not update the response data value within the expiration time expire, when the client sends the data request information with the keyword key, the web server obtains the response data value from the cache server. And send it to the client; in the cache server, when the expiration time expire is reached, the cache server will delete ⁇ keyword key, response data value, expiration time expire>. Exemplarily, the web server will ⁇ keyword key, response data value, expiration time expire at 10:00.
  • the expiration time expire is set to 10 minutes; when the web server receives the data request information carried by the client 1 and carries the keyword key at 10:01, the web server obtains the keyword from the cache server.
  • the response data value corresponding to the key is sent to the client 1; when the web server receives the data request information carried by the client 2 and carries the keyword key at 10:30, the web server sends the key to the cache server to obtain the key.
  • the response data value corresponding to the word key, and the returned response data value is empty.
  • the cache server deletes the ⁇ keyword key, response data value, and expiration time expire>, therefore, the cache server does not Save ⁇ keyword key, response data value, expiration time expire>.
  • the method for updating the cached data provided by the embodiment of the present invention, after receiving the data request information sent by the web server, the service server asynchronously processing the request information, including: sending the response data value corresponding to the data request information to the web server And establishing a mapping relationship between the keyword key and the data ID, wherein the data request information includes a keyword key, and the keyword key is generated by the web server, and when the web server receives the response data value, the keyword key And the response data value is stored in the cache server, the data ID is a unique identifier of the service server storing the response data value; the service server monitors whether the response data value corresponding to the data ID is based on the mapping relationship between the established keyword key and the data ID.
  • the keyword key is obtained based on the mapping relationship, and the keyword key and its corresponding response data value are deleted from the cache server, so that the response data value in the cache server is implemented.
  • Active failure compared with the prior art, the present invention
  • the mapping relationship between the data ID and the keyword key is established, and the response data value corresponding to the data ID is monitored in real time to ensure that the response data value obtained by the client user is the real-time updated response data value, so as to improve the client.
  • the end user obtains the accuracy of the response data value, thereby improving the user experience of the client user.
  • step 101 the mapping relationship between the keyword key and the data ID is established in step 101, which may be implemented by using, but not limited to, the following manners:
  • Manner 1 The service server obtains the data ID from the data request information, and establishes a mapping relationship between the keyword key and the data ID.
  • the data request information sent by the web server includes a URL, and the data ID may exist in the URL. Therefore, when the service server establishes a mapping relationship between the keyword key and the data ID, the service server parses the data request information and obtains It contains the URL and determines the URL Whether there is a data ID in the middle, if there is a data ID, the data ID is obtained, and a mapping relationship between the data ID and the keyword key is established.
  • the encrypted keyword key is: 9afbd22506aff85cc6dd395a57b1471d
  • the service server determines that the data ID in the URL is 28845003.
  • the above is only an exemplary example, and the content of the URL, the format parameter included in the URL, and the encrypted keyword key are not specifically limited in the embodiment of the present invention.
  • the mapping relationship between the established data ID and the keyword key is stored in the redis database.
  • Table 1 shows the redis database provided by the embodiment of the present invention.
  • the mapping between the storage data ID and the keyword key is not limited.
  • the specific implementation manner and storage format of the mapping relationship between the data ID and the keyword key are not limited in the embodiment of the present invention.
  • Manner 2 The data ID is obtained from the response data value corresponding to the data request information, and a mapping relationship between the keyword key and the data ID is established.
  • the service server obtains and determines the data ID carried in the response data value by parsing the response data value, and establishes a relationship between the keyword and the data ID.
  • the mapping relationship wherein the mapping between the keyword key and the data ID is established by the service server, and the storage of the mapping relationship, refer to the related description of the foregoing manner 1.
  • the present invention does not establish a keyword with the service server.
  • the mapping relationship between the data IDs and the storage of the mapping relationships are described in detail.
  • the service server updates the response data value corresponding to the data ID
  • the editor of the response data value edits the response data value
  • Update of value From the technical implementation level, the service server receives the response when it receives the editor's click on the preset update component.
  • the update response data value is executed. Therefore, in the embodiment of the present invention, the service server can determine whether the response data value corresponding to the data ID is updated by monitoring the preset update component.
  • the preset update component of the embodiment of the present invention may be different due to different programming languages of the service server. Specifically, the preset update component may be a save component, an update component, a replacement component, etc., and the specific embodiment of the present invention.
  • the preset update component is not limited.
  • the keyword key and its corresponding response data value are stored in the cache server, and the keyword key and the data ID are stored in the service server, and the service server performs the deletion of the cache server according to the keyword key.
  • the preset function interface is invoked to establish an interaction relationship with the cache server, and the keyword key is obtained from the cache server based on the keyword key recognized by the cache server and the service server.
  • the corresponding response data value is deleted by the keyword key and its corresponding response data value.
  • the service server determines the field storing the key key in the cache server according to the keyword key; secondly, in the traversal manner, and finally determines the keyword in the keyword key field.
  • the keyword key and its corresponding response data value are deleted and deleted.
  • the specific implementation manner of deleting the keyword key and the corresponding response data value in the cache server of the service server is not limited in the embodiment of the present invention.
  • the embodiment of the present invention further provides an apparatus for updating cache data, where the apparatus is applied to a service server.
  • the apparatus includes:
  • the sending unit 31 is configured to send the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and the mapping between the data ID and the keyword key is one-to-one correspondence.
  • the mapping relationship is stored in the service server, and the keyword key and the response data value are also in a one-to-one correspondence, which is stored in the cache server, and the web server, the cache server, and the service server can communicate with each other.
  • the response data value corresponding to the keyword key is stored in the cache server, it indicates that the response data value is consistent with the response data value corresponding to the data ID in the service server, that is, the response data value is the latest. Response data;
  • the establishing unit 32 is configured to establish a mapping relationship between the keyword key and the data ID, where the data request information includes the keyword key, and the keyword key is generated by the web server, the web server After receiving the response data, the keyword key and its pair are The response data is stored in the cache server, and the data ID is a unique identifier of the service server storing the response data;
  • the monitoring unit 33 is configured to monitor whether the response data corresponding to the data ID in the mapping relationship established in the establishing unit 32 is updated, and the data ID is not updated, but the response data value corresponding to the data ID is If the change is updated at any time, the time of the update change is random. Therefore, the response data value corresponding to the data ID needs to be monitored to determine whether the response data value corresponding to the data ID is updated.
  • the obtaining unit 34 is configured to acquire the keyword key based on the mapping relationship when it is determined that the response data corresponding to the data ID monitored by the monitoring unit 33 is updated;
  • the deleting unit 35 is configured to delete the keyword key and the corresponding response data in the cache server according to the keyword key acquired by the obtaining unit 34, so that the response data value obtained by the client user is real-time. Updated data.
  • the establishing unit 32 includes:
  • the first establishing module 321 is configured to obtain the data ID from the data request information, and establish a mapping relationship between the keyword key and the data ID.
  • the second establishing module 322 is configured to obtain the data ID from the response data corresponding to the data request information, and establish a mapping relationship between the keyword key and the data ID.
  • the first establishing module 321 includes:
  • a parsing submodule 3211 configured to parse the data request information
  • the obtaining sub-module 3212 is configured to obtain the data ID in the uniform resource locator URL after the parsing sub-module 3211 parses the data request information;
  • the establishing sub-module 3213 is configured to establish a mapping relationship between the keyword key and the data ID acquired by the obtaining sub-module 3212.
  • the second establishing module 322 shown in FIG. 4 includes:
  • the parsing sub-module 3221 is configured to parse the response data corresponding to the data request information
  • a determining sub-module 3222 configured to determine, after the parsing sub-module 3221 parses the response data corresponding to the data request information, the data ID corresponding to the data;
  • the establishing submodule 3223 is configured to establish a mapping relationship between the keyword key and the data ID determined by the determining submodule 3222.
  • the device further includes:
  • the storage unit 36 is configured to store the mapping relationship in the database after the establishing unit 32 establishes a mapping relationship between the keyword key and the data ID.
  • the monitoring unit 33 is further configured to monitor the preset update component to determine whether the response data corresponding to the data ID is updated, and the preset update component is configured to perform response data corresponding to the data ID. Update.
  • the deleting unit 35 includes:
  • the obtaining module 351 is configured to invoke the preset function interface to obtain the keyword key and the corresponding response data in the cache server.
  • the deleting module 352 is configured to delete the keyword key and the corresponding response data acquired by the obtaining module 351.
  • the method for updating the cached data provided by the embodiment of the present invention, after receiving the data request information sent by the web server, the service server asynchronously processing the request information, including: sending the response data corresponding to the data request information to the web server, and Establishing a mapping relationship between the keyword key and the data ID, wherein the data request information includes a keyword key generated by the web server, and when the web server receives the response data, the keyword key and the response are The data is stored in the cache server, and the data ID is a unique identifier of the service server storing the response data; the service server monitors whether the response data corresponding to the data ID is updated based on the mapping relationship between the established keyword key and the data ID, when the data is determined.
  • the keyword key is obtained based on the mapping relationship, and the keyword key and its corresponding response data are deleted from the cache server, so that the response data in the cache server is actively invalidated;
  • the mapping relationship between ey and real-time monitoring of the response data corresponding to the data ID ensures that the response data obtained by the client user is real-time updated response data, so as to improve the accuracy of the client user to obtain response data, thereby improving the accuracy.
  • FIG. 5 is a schematic structural diagram of a service server according to an embodiment of the present invention.
  • the server may include: a processor ( Processor) 51, communication interface (Communications Interface) 52, storage A memory 53 and a bus 54, wherein the processor 51, the communication interface 52, and the memory 53 complete communication with each other via the bus 54.
  • Communication interface 52 can be used for information transfer between the server and the client.
  • the processor 51 can call the logic instruction in the memory 53 to perform the following method: the service server sends the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and establishes a keyword key.
  • the data request information includes the keyword key
  • the keyword key is generated by the web server, and after receiving the response data, the web server
  • the keyword key and its corresponding response data are stored in the cache server, the data ID is a unique identifier of the service server storing the response data; monitoring whether the response data corresponding to the data ID is updated; if the data ID is determined If the corresponding response data is updated, the keyword key is obtained based on the mapping relationship, and the keyword key and the corresponding response data in the cache server are deleted according to the keyword key.
  • the logic instructions in the memory 53 described above may be implemented in the form of a software functional unit and sold or used as a stand-alone product, and may be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
  • the instructions are used 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: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
  • the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without deliberate labor.
  • the points may be embodied in the form of a software product, which may be stored in a computer readable storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., including instructions for causing a computer device (which may be a personal computer)
  • the server, or network device, etc. performs the methods described in various embodiments or portions of the embodiments.

Landscapes

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

Abstract

Disclosed are a cache data update method and device. The method comprises: a service server sending, according to data request information sent by a web server, response data corresponding to the data request information to the web server, and establishing a mapping relationship between a keyword key and data ID (101); the service server monitoring whether response data corresponding to the data ID is updated (102); and if it is determined that the response data corresponding to the data ID is updated, the service server acquiring the keyword key based on the mapping relationship, and deleting the keyword key in a cache server and the response data corresponding thereto (103). By means of a mapping relationship established between data ID and a keyword key, and real-time monitoring of response data corresponding to the data ID, it is guaranteed that response data acquired by a client user is response data updated in real time, so that the accuracy of the client user acquiring the response data is improved, and thus the user experience of the client user is improved.

Description

缓存数据的更新方法及装置Method and device for updating cached data
本申请基于申请号为201510864595X、申请日为2015年12月01日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。The present application is filed on the basis of the Chinese Patent Application No. PCT Application No. No. No. No. No. No. No. No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No
技术领域Technical field
本发明实施例涉及互联网技术领域,尤其涉及一种缓存数据的更新方法及装置。The embodiments of the present invention relate to the field of Internet technologies, and in particular, to a method and an apparatus for updating cache data.
背景技术Background technique
随着互联网的普及,人们对web服务器的访问效率的要求也越来越高,特别是针对互联网领域中多用户、高并发的问题。通过将历史访问的数据加入到缓存服务器中,该缓存服务器中数据的读取速度比业务服务器中数据的读取速度快。With the popularity of the Internet, people's access requirements for web servers are becoming more and more demanding, especially for multi-user and high concurrency issues in the Internet field. By adding historically accessed data to the cache server, the data in the cache server can be read faster than the data in the business server.
目前,web服务器将客户端发送的统一资源定位符(Uniform Resource Locator,URL)作为key,并将该URL发送至业务服务器,web服务器接收业务服务器发送的URL对应的返回结果,并将该返回结果作为value,将key-value成对保存到缓存服务器中。在将key-value成对保存到缓存服务器时,web服务器会设置该key-value的失效时间,只要当在失效时间之内,当客户端发送的下一个有关该key的请求信息时,web服务器从缓存服务器中获取与key对应的value,并将该value发送至客户端,以减轻业务服务器的负荷,减小了客户端的响应延迟。At present, the web server takes the Uniform Resource Locator (URL) sent by the client as a key, and sends the URL to the service server, and the web server receives the return result corresponding to the URL sent by the service server, and returns the result. As a value, the key-value is stored in pairs in the cache server. When the key-value is paired to the cache server, the web server sets the expiration time of the key-value, as long as the client sends the next request information about the key within the expiration time, the web server. The value corresponding to the key is obtained from the cache server, and the value is sent to the client to reduce the load of the service server and reduce the response delay of the client.
业务服务器通过数据ID对不同的数据value进行标识。但是,当业务服务器中数据ID对应的数据value发生变化,若客户端在失效时间内发送有关该key的请求信息,则客户端获取到的数据value仍然为缓存服务器中存储的旧数据value。针对相同的key,且在缓存服务器的失效时间内,由于业务服务器端数据value的更新与缓存服务器中数据value的更新不是同步更新的,即缓存服务器中存储的数据value的实时性较差,导致客 户端用户获取到的数据是存在误差的数据;特别是当客户端用户获取的数据是对实时性要求较高的数据,例如:直播赛事、天气预报等数据,客户端获取的存在误差的数据,大大降低客户端用户的用户体验。The service server identifies different data values by the data ID. However, when the data value corresponding to the data ID in the service server changes, if the client sends the request information about the key within the expiration time, the data value obtained by the client is still the old data value stored in the cache server. For the same key, and during the expiration time of the cache server, the update of the data value of the service server and the update of the data value in the cache server are not updated synchronously, that is, the real-time value of the data stored in the cache server is poor, resulting in poor performance. Guest The data acquired by the client user is data with errors; especially when the data acquired by the client user is data that requires high real-time performance, such as data such as live events and weather forecasts, and data obtained by the client with errors. , greatly reducing the user experience of the client user.
发明内容Summary of the invention
本发明实施例提供一种缓存数据的更新方法及装置,主要目的在于,针对缓存服务器与业务服务器中相同的关键字key,实现缓存服务器中数据value与业务服务器中数据value的同步更新,提高客户端用户获取实时数据value的用户体验。The embodiment of the invention provides a method and a device for updating cache data, and the main purpose is to synchronously update the data value in the cache server and the data value in the service server for the same keyword key in the cache server and the service server, thereby improving the client. The end user gets the user experience of the real-time data value.
本发明实施例提供一种缓存数据的更新方法,包括:An embodiment of the present invention provides a method for updating cache data, including:
业务服务器根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器,并建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;The service server sends the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and establishes a mapping relationship between the keyword key and the data ID; wherein, in the data request information The keyword key is generated, and the keyword key is generated by the web server. After receiving the response data, the web server stores the keyword key and its corresponding response data in a cache server. The data ID is a unique identifier for storing the response data by the service server;
监控所述数据ID对应的响应数据是否有更新;Monitoring whether the response data corresponding to the data ID is updated;
若确定所述数据ID对应的响应数据有更新,则基于所述映射关系获取所述关键字key,并根据所述关键字key删除所述缓存服务器中的所述关键字key与其对应的响应数据。If it is determined that the response data corresponding to the data ID is updated, acquiring the keyword key based on the mapping relationship, and deleting the keyword key and the corresponding response data in the cache server according to the keyword key .
本发明实施例提供一种缓存数据的更新装置,包括:An embodiment of the present invention provides an apparatus for updating cached data, including:
发送单元,用于根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器;a sending unit, configured to send, according to the data request information sent by the web server, response data corresponding to the data request information to the web server;
建立单元,用于建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;a establishing unit, configured to establish a mapping relationship between the keyword key and the data ID; wherein the data request information includes the keyword key, the keyword key is generated by the web server, and the web server receives After the response data, the keyword key and its corresponding response data are stored in a cache server, where the data ID is a unique identifier of the service server storing the response data;
监控单元,用于监控所述建立单元中建立的所述映射关系中的所述数据ID对应的响应数据是否有更新; a monitoring unit, configured to monitor whether the response data corresponding to the data ID in the mapping relationship established in the establishing unit is updated;
获取单元,用于当确定所述监控单元监控的所述数据ID对应的响应数据有更新时,基于所述映射关系获取所述关键字key;An acquiring unit, configured to acquire the keyword key based on the mapping relationship when it is determined that the response data corresponding to the data ID monitored by the monitoring unit is updated;
删除单元,用于根据所述获取单元获取的所述关键字key删除所述缓存服务器中的所述关键字key及其对应的响应数据。a deleting unit, configured to delete the keyword key and the corresponding response data in the cache server according to the keyword key acquired by the acquiring unit.
本发明实施例提供一种电子装置,包括:An embodiment of the present invention provides an electronic device, including:
一个或多个处理器;和One or more processors; and
存储器;Memory
其中所述存储器中存储有指令,经配置所述指令由所述一个或多个处理器执行,所述一个或多个处理器通过执行所述指令能进行如下操作:Wherein the memory stores instructions that are configured to be executed by the one or more processors, and the one or more processors can perform the following operations by executing the instructions:
根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器;Transmitting the response data corresponding to the data request information to the web server according to the data request information sent by the web server;
建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;Establishing a mapping relationship between the keyword key and the data ID; wherein the data request information includes the keyword key, the keyword key is generated by the web server, and the web server receives the response data And storing the keyword key and its corresponding response data in a cache server, where the data ID is a unique identifier of the service server storing the response data;
监控所述映射关系中的所述数据ID对应的响应数据是否有更新;Monitoring whether the response data corresponding to the data ID in the mapping relationship is updated;
当确定所述数据ID对应的响应数据有更新时,基于所述映射关系获取所述关键字key;When it is determined that the response data corresponding to the data ID is updated, acquiring the keyword key based on the mapping relationship;
根据获取的所述关键字key删除所述缓存服务器中的所述关键字key及其对应的响应数据。Deleting the keyword key and the corresponding response data in the cache server according to the obtained keyword key.
本发明实施例提供一种非易失性计算机可读取存储介质,其中记录了能对缓存数据进行更新的程序,所述程序使计算机执行如下步骤:Embodiments of the present invention provide a non-volatile computer readable storage medium in which a program capable of updating cache data is recorded, the program causing a computer to perform the following steps:
根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器;Transmitting the response data corresponding to the data request information to the web server according to the data request information sent by the web server;
建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;Establishing a mapping relationship between the keyword key and the data ID; wherein the data request information includes the keyword key, the keyword key is generated by the web server, and the web server receives the response data And storing the keyword key and its corresponding response data in a cache server, where the data ID is a unique identifier of the service server storing the response data;
监控所述映射关系中的所述数据ID对应的响应数据是否有更新;Monitoring whether the response data corresponding to the data ID in the mapping relationship is updated;
当确定所述数据ID对应的响应数据有更新时,基于所述映射关系获取所 述关键字key;When it is determined that the response data corresponding to the data ID is updated, acquiring the location based on the mapping relationship Keyword
根据获取的所述关键字key删除所述缓存服务器中的所述关键字key及其对应的响应数据。Deleting the keyword key and the corresponding response data in the cache server according to the obtained keyword key.
本发明实施例提供的缓存数据的更新方法及装置,业务服务器在接收到web服务器发送的数据请求信息之后,对该请求信息进行异步处理,包括:将该数据请求信息对应的响应数据发送至web服务器以及建立关键字key与数据ID之间的映射关系,其中,该数据请求信息中包含关键字key,该关键字key由web服务器生成,当web服务器接收到响应数据后,将该关键字key与响应数据存储于缓存服务器中,该数据ID为业务服务器存储响应数据的唯一标识;业务服务器基于建立的关键字key与数据ID之间的映射关系监控数据ID对应的响应数据是否有更新,当确定数据ID对应的响应数据有更新时,基于映射关系获取关键字key,并将该关键字key与其对应的响应数据从缓存服务器中删除,实现使缓存服务器中响应数据的主动失效;与现有技术相比,本发明实施例通过建立的数据ID与关键字key之间的映射关系,并对该数据ID对应的响应数据进行实时监控,确保客户端用户获取的响应数据为实时更新的响应数据,以提高客户端用户获取响应数据的准确性,进而提高了客户端用户的用户体验。The method and device for updating the cached data provided by the embodiment of the present invention, after receiving the data request information sent by the web server, the service server asynchronously processes the request information, including: sending the response data corresponding to the data request information to the web a server and a mapping relationship between the keyword key and the data ID, wherein the data request information includes a keyword key, and the keyword key is generated by the web server, and when the web server receives the response data, the keyword key And the response data is stored in the cache server, the data ID is a unique identifier of the service server storing the response data; the service server monitors whether the response data corresponding to the data ID is updated based on the mapping relationship between the established keyword key and the data ID. When it is determined that the response data corresponding to the data ID is updated, the keyword key is obtained based on the mapping relationship, and the keyword key and its corresponding response data are deleted from the cache server, so that the active response of the response data in the cache server is invalidated; Compared with the technology, the embodiment of the present invention passes the established data ID and The mapping relationship between the key words, and the response data corresponding to the data ID is monitored in real time to ensure that the response data obtained by the client user is the real-time updated response data, so as to improve the accuracy of the client user to obtain the response data, and then Improve the user experience of client users.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1示出了本发明实施例提供的一种缓存数据的更新方法的流程图;FIG. 1 is a flowchart of a method for updating cache data according to an embodiment of the present invention;
图2示出了客户端、web服务器、缓存服务器及业务服务器之间数据交互的示意图;2 is a schematic diagram showing data interaction between a client, a web server, a cache server, and a service server;
图3示出了本发明实施例提供的一种缓存数据的更新装置的组成框图;FIG. 3 is a block diagram showing the structure of an apparatus for updating cached data according to an embodiment of the present invention;
图4示出了本发明实施例提供的另一种缓存数据的更新装置的组成框图;FIG. 4 is a block diagram showing the composition of another cache data updating apparatus according to an embodiment of the present invention;
图5示出了本发明实施例提供的一种业务服务器的结构示意图。 FIG. 5 is a schematic structural diagram of a service server according to an embodiment of the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and 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 are within the scope of the present invention.
本发明实施例提供一种缓存数据的更新方法,该方法应用于业务服务器侧,如图1所示,所述方法包括:The embodiment of the invention provides a method for updating cache data, which is applied to the service server side. As shown in FIG. 1 , the method includes:
101、业务服务器根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器,并建立关键字key与数据ID之间的映射关系。101. The service server sends the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and establishes a mapping relationship between the keyword key and the data ID.
本发明实施例中,将以示例的形式详细说明客户端、web服务器、缓存服务器、业务服务器之间的关联关系。示例性的,如图2所示,图中包含N个客户端、N个缓存服务器,其中,N为大于2的正整数;客户端基于超文本传送协议(HTTP-Hypertext transfer protocol,HTTP)向web服务器发送数据请求信息,该数据请求信息中包含统一资源定位符(Uniform Resource Locator,URL),web服务器接收到客户端发送的数据请求之后,根据该URL生成关键字key,并基于该关键字key向缓存服务器发送获取关键字key对应的响应数据value,若缓存服务器中存在关键字key对应的响应数据value,则获取响应数据value,并将该响应数据value发送至客户端;若缓存服务器中不存在关键字key对应的响应数据value,则web服务器将数据请求信息发送至业务服务器,其中,该数据请求信息中携带有关键字key,在接收到web服务器发送的数据请求信息之后,业务服务器进行异步处理,所述异步处理包括:对数据请求信息进行响应,将所述数据请求信息对应的响应数据value发送至所述web服务器,以及建立关键字key与数据ID之间的映射关系。In the embodiment of the present invention, the association relationship between the client, the web server, the cache server, and the service server will be described in detail by way of example. Exemplarily, as shown in FIG. 2, the figure includes N clients and N cache servers, where N is a positive integer greater than 2; the client is based on HTTP-Hypertext transfer protocol (HTTP). The web server sends data request information, where the data request information includes a Uniform Resource Locator (URL). After receiving the data request sent by the client, the web server generates a keyword key according to the URL, and based on the keyword, The key sends the response data value corresponding to the keyword key to the cache server. If the response data value corresponding to the keyword key exists in the cache server, the response data value is obtained, and the response data value is sent to the client; if the cache server is If the response data value corresponding to the keyword key does not exist, the web server sends the data request information to the service server, where the data request information carries the keyword key, and after receiving the data request information sent by the web server, the service server Asynchronous processing, the asynchronous processing includes: performing data request information Should the information corresponding to the data request sent in response to the data value of the web server, and establishing a mapping relationship between key data and key ID.
其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据value后,将所述关键字key与其对应的响应数据value存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据value的唯一标识。The data request information includes the keyword key, and the keyword key is generated by the web server, and after receiving the response data value, the web server sends the keyword key and its corresponding response. The data value is stored in a cache server, and the data ID is a unique identifier of the service server storing the response data value.
需要说明的是,数据ID与关键字key是一一对应的映射关系,该映射关 系保存于业务服务器中,关键字key与响应数据value也是一一对应的关系,其保存于缓存服务器中,web服务器、缓存服务器及业务服务器之间能够相互通信交互。在本发明实施例中,若缓存服务器中存储有关键字key对应的响应数据value,则说明该响应数据value与业务服务器中数据ID对应的响应数据value是一致的,即该响应数据value是最新的响应数据。It should be noted that the data ID and the keyword key have a one-to-one mapping relationship, and the mapping is The system is stored in the service server, and the keyword key and the response data value are also in a one-to-one correspondence, which is stored in the cache server, and the web server, the cache server, and the service server can communicate with each other. In the embodiment of the present invention, if the response data value corresponding to the keyword key is stored in the cache server, it indicates that the response data value is consistent with the response data value corresponding to the data ID in the service server, that is, the response data value is the latest. Response data.
可选的,web服务器能够与多个缓存服务器进行通信交互,其中,所述缓存服务器为分布式高速缓存服务器,能够对客户端发送的数据请求信息进行及时响应。为了减轻缓存服务器的负载,确定缓存服务器响应数据请求信息的及时性,web服务器将关键字key保存至缓存服务器之前,web服务器将关键字key进行加密操作,加密后的关键字key为随机的字符串,在web服务器将关键字key随机的存储在缓存服务器中,提高关键字key的分散性,减小了由于关键字key过于集中,而导致该台缓存服务器的负荷过大。关键字key与其对应数据value进行加密可以采用但不局限于以下的实现方式,例如,哈希算法Hash,包括:消息摘要算法(Message-Digest Algorithm 5,MD5);本发明实施例对加密的具体实现算法不进行限定。Optionally, the web server can communicate with the plurality of cache servers, wherein the cache server is a distributed cache server, and can respond to the data request information sent by the client in time. In order to reduce the load of the cache server, determine the timeliness of the cache server response data request information. Before the web server saves the keyword key to the cache server, the web server encrypts the keyword key, and the encrypted keyword key is a random character. The string server stores the keyword key randomly in the cache server, which improves the dispersibility of the keyword key and reduces the load on the cache server due to the excessive concentration of the keyword key. The encryption of the keyword key and its corresponding data value may be implemented by, but not limited to, the following implementation manners, for example, a hash algorithm hash, including a message digest algorithm (MD5), and a specific embodiment of the present invention. The implementation algorithm is not limited.
需要说明的是,虽然关键字key是根据数据请求信息生成的,但是,由于该关键字key是加密后的,是不可逆转的,其目的在于为了减轻缓存服务器的负载,因此,web服务器在向业务服务器发送数据请求信息时,若仅发送关键字key,则业务服务器不能对该关键词key中的具体数据请求信息进行识别,无法对web服务器进行响应,因此,在web服务器向业务服务器请求数据时,需要将关键字key携带到数据请求信息中。It should be noted that although the keyword key is generated according to the data request information, since the keyword key is encrypted and is irreversible, the purpose is to reduce the load of the cache server, and therefore, the web server is When the service server sends the data request information, if only the keyword key is sent, the service server cannot identify the specific data request information in the keyword key, and cannot respond to the web server. Therefore, the web server requests data from the service server. When you need to carry the keyword key into the data request information.
示例性的,若客户端发送的数据请求信息中包含URL为:http://api.lesports.com/sms/v1/matches/28845003?caller=1001,web服务器将该URL最为关键字key,并对该关键字key进行MD5加密操作,加密后的关键字key为:9afbd22506aff85cc6dd395a57b1471d,web服务器该加密后的关键字key添加到数据请求信息中发送给业务服务器,以便该业务服务器对数据请求信息进行响应,同时,便于业务服务器根据该关键字key与数据ID建立映射关系。Exemplarily, if the data request information sent by the client includes the URL: http://api.lesports.com/sms/v1/matches/28845003? Caller=1001, the web server has the most keyword key, and performs MD5 encryption operation on the keyword key. The encrypted keyword key is: 9afbd22506aff85cc6dd395a57b1471d, and the encrypted keyword key of the web server is added to the data request information. The service server sends the information to the service server, so that the service server can establish a mapping relationship with the data ID according to the keyword key.
102、业务服务器监控所述数据ID对应的响应数据是否有更新。102. The service server monitors whether the response data corresponding to the data ID is updated.
本发明实施例中,业务服务器中的数据ID不会更新变化,但是该数据ID 对应的响应数据value时随时更新变化的,其更新变化的时间是随机的,因此,业务服务器需对该数据ID对应的响应数据value进行监控,以确定该数据ID对应的响应数据value是否有更新。In the embodiment of the present invention, the data ID in the service server is not updated, but the data ID is The corresponding response data value is updated at any time, and the update change time is random. Therefore, the service server needs to monitor the response data value corresponding to the data ID to determine whether the response data value corresponding to the data ID is updated. .
103、若确定所述数据ID对应的响应数据有更新,则业务服务器基于所述映射关系获取所述关键字key,并删除所述缓存服务器中所述关键字key及其对应的响应数据。103. If it is determined that the response data corresponding to the data ID is updated, the service server acquires the keyword key based on the mapping relationship, and deletes the keyword key and the corresponding response data in the cache server.
若执行步骤102时业务服务器未监控到数据ID对应的响应数据value有更新,若缓存服务器中存储有该响应数据value,则说明业务服务器中的响应数据value与缓存服务器中存储的响应数据value一致,因此,无需将缓存服务器中的响应数据value进行主动失效,所述主动失效为在缓存服务器中响应数据value的失效时间内,主动删除该响应数据value。若执行步骤102时业务服务器监控到数据ID对应的响应数据value有更新,若缓存服务器中存储有该响应数据value,则说明业务服务器中的响应数据value与缓存服务器中存储的响应数据value不一致,因此,需要将缓存服务器中的响应数据value进行主动失效,以便客户端用户获取到的响应数据value是实时更新后的数据。If the value of the response data corresponding to the data ID is not updated when the service server performs the step 102, if the response data value is stored in the cache server, the value of the response data in the service server is consistent with the value of the response data stored in the cache server. Therefore, there is no need to actively invalidate the response data value in the cache server, and the active failure is to actively delete the response data value in the expiration time of the response data value in the cache server. If the value of the response data corresponding to the data ID is updated by the service server when the step 102 is performed, if the value of the response data is stored in the cache server, the value of the response data in the service server is inconsistent with the value of the response data stored in the cache server. Therefore, the response data value in the cache server needs to be actively invalidated, so that the response data value obtained by the client user is real-time updated data.
业务服务器对缓存服务器中的响应数据value进行主动失效包括:首先,业务服务器根据步骤101中建立的关键字key与数据ID之间的映射关系,查找并确定该数据ID对应的关键字key;其次,根据该关键字key获取该关键字key对应的响应数据value;最后,将该关键字key及其对应的响应数据value删除。当客户端再次发送该关键字key对应的数据请求信息时,web服务器将该关键字key及对应的响应数据value重新存储于缓存服务器中。The active invalidation of the response data value in the cache server by the service server includes: first, the service server searches for and determines the keyword key corresponding to the data ID according to the mapping relationship between the keyword key and the data ID established in step 101; The response data value corresponding to the keyword key is obtained according to the keyword key; finally, the keyword key and its corresponding response data value are deleted. When the client sends the data request information corresponding to the keyword key again, the web server re-stores the keyword key and the corresponding response data value in the cache server.
需要说明的是,在本发明实施例中,web服务器在接收到业务服务器发送的响应数据value之后,将<关键词key,响应数据value,失效时间expire>存储于缓存服务器中,其中,所述失效时间expire为web服务器设置的,若在该失效时间expire内业务服务器没有更新响应数据value,当客户端发送有该关键字key的数据请求信息时,web服务器从缓存服务器中获取响应数据value,并将其发送给客户端;在缓存服务器内,当达到失效时间expire时,缓存服务器会将<关键词key,响应数据value,失效时间expire>删除。示例性的,web服务器在10:00将<关键词key,响应数据value,失效时间expire> 存储于缓存服务器中,其中,失效时间expire设置为10分钟;当web服务器在10:01接收到客户端1发送的携带有关键字key的数据请求信息时,web服务器从缓存服务器获取该关键字key对应的响应数据value,并将其发送给客户端1;当web服务器在10:30接收到客户端2发送的携带有关键字key的数据请求信息时,web服务器向缓存服务器发送获取该关键字key对应的响应数据value,返回的响应数据value为空,此时,由于超过失效时间expire,缓存服务器将<关键词key,响应数据value,失效时间expire>进行删除,因此,缓存服务器中未保存<关键词key,响应数据value,失效时间expire>。It should be noted that, in the embodiment of the present invention, after receiving the response data value sent by the service server, the web server stores the <keyword key, the response data value, and the expiration time expire> in the cache server, where The expiration time expire is set by the web server. If the service server does not update the response data value within the expiration time expire, when the client sends the data request information with the keyword key, the web server obtains the response data value from the cache server. And send it to the client; in the cache server, when the expiration time expire is reached, the cache server will delete <keyword key, response data value, expiration time expire>. Exemplarily, the web server will <keyword key, response data value, expiration time expire at 10:00. Stored in the cache server, wherein the expiration time expire is set to 10 minutes; when the web server receives the data request information carried by the client 1 and carries the keyword key at 10:01, the web server obtains the keyword from the cache server. The response data value corresponding to the key is sent to the client 1; when the web server receives the data request information carried by the client 2 and carries the keyword key at 10:30, the web server sends the key to the cache server to obtain the key. The response data value corresponding to the word key, and the returned response data value is empty. At this time, because the expiration time expire is exceeded, the cache server deletes the <keyword key, response data value, and expiration time expire>, therefore, the cache server does not Save <keyword key, response data value, expiration time expire>.
本发明实施例提供的缓存数据的更新方法,业务服务器在接收到web服务器发送的数据请求信息之后,对该请求信息进行异步处理,包括:将该数据请求信息对应的响应数据value发送至web服务器以及建立关键字key与数据ID之间的映射关系,其中,该数据请求信息中包含关键字key,该关键字key由web服务器生成,当web服务器接收到响应数据value后,将该关键字key与响应数据value存储于缓存服务器中,该数据ID为业务服务器存储响应数据value的唯一标识;业务服务器基于建立的关键字key与数据ID之间的映射关系监控数据ID对应的响应数据value是否有更新,当确定数据ID对应的响应数据value有更新时,基于映射关系获取关键字key,并将该关键字key与其对应的响应数据value从缓存服务器中删除,实现使缓存服务器中响应数据value的主动失效;与现有技术相比,本发明实施例通过建立的数据ID与关键字key之间的映射关系,并对该数据ID对应的响应数据value进行实时监控,确保客户端用户获取的响应数据value为实时更新的响应数据value,以提高客户端用户获取响应数据value的准确性,进而提高了客户端用户的用户体验。The method for updating the cached data provided by the embodiment of the present invention, after receiving the data request information sent by the web server, the service server asynchronously processing the request information, including: sending the response data value corresponding to the data request information to the web server And establishing a mapping relationship between the keyword key and the data ID, wherein the data request information includes a keyword key, and the keyword key is generated by the web server, and when the web server receives the response data value, the keyword key And the response data value is stored in the cache server, the data ID is a unique identifier of the service server storing the response data value; the service server monitors whether the response data value corresponding to the data ID is based on the mapping relationship between the established keyword key and the data ID. Update, when it is determined that the response data value corresponding to the data ID is updated, the keyword key is obtained based on the mapping relationship, and the keyword key and its corresponding response data value are deleted from the cache server, so that the response data value in the cache server is implemented. Active failure; compared with the prior art, the present invention In the example, the mapping relationship between the data ID and the keyword key is established, and the response data value corresponding to the data ID is monitored in real time to ensure that the response data value obtained by the client user is the real-time updated response data value, so as to improve the client. The end user obtains the accuracy of the response data value, thereby improving the user experience of the client user.
进一步的,作为对上述实施例的细化和扩展,在执行步骤101中建立关键字key与数据ID之间的映射关系,可以采用但不局限于以下的方式实现:Further, as a refinement and extension of the foregoing embodiment, the mapping relationship between the keyword key and the data ID is established in step 101, which may be implemented by using, but not limited to, the following manners:
方式一:业务服务器从所述数据请求信息中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系。Manner 1: The service server obtains the data ID from the data request information, and establishes a mapping relationship between the keyword key and the data ID.
在web服务器发送的数据请求信息中包含URL,该URL中可能会存在数据ID,因此,在业务服务器建立关键字key与数据ID之间的映射关系时,业务服务器对数据请求信息进行解析,获取其包含的URL,并确定该URL 中是否存在数据ID,若存在数据ID,则获取该数据ID,并建立数据ID与关键字key之间的映射关系。The data request information sent by the web server includes a URL, and the data ID may exist in the URL. Therefore, when the service server establishes a mapping relationship between the keyword key and the data ID, the service server parses the data request information and obtains It contains the URL and determines the URL Whether there is a data ID in the middle, if there is a data ID, the data ID is obtained, and a mapping relationship between the data ID and the keyword key is established.
示例性的,承由上述示例,客户端发送的数据请求信息中包含URL为:http://api.lesports.com/sms/v1/matches/28845003?caller=1001,且加密后的关键字key为:9afbd22506aff85cc6dd395a57b1471d,业务服务器确定该URL中的数据ID为28845003。以上仅为示例性的举例,本发明实施例对URL、URL中包含的格式参数以及加密后的关键字key等内容不进行具体限定。Exemplarily, according to the above example, the data request information sent by the client includes the URL: http://api.lesports.com/sms/v1/matches/28845003? Caller=1001, and the encrypted keyword key is: 9afbd22506aff85cc6dd395a57b1471d, and the service server determines that the data ID in the URL is 28845003. The above is only an exemplary example, and the content of the URL, the format parameter included in the URL, and the encrypted keyword key are not specifically limited in the embodiment of the present invention.
在本发明实施例中,将建立的数据ID与关键字key之间的映射关系存储于redis数据库中,示例性的,如表1所示,表1示出了本发明实施例提供的redis数据库存储数据ID与关键字key之间的映射关系,本发明实施例对业务服务器存储数据ID与关键字key之间的映射关系的具体实现方式、存储形式不进行限定。In the embodiment of the present invention, the mapping relationship between the established data ID and the keyword key is stored in the redis database. For example, as shown in Table 1, Table 1 shows the redis database provided by the embodiment of the present invention. The mapping between the storage data ID and the keyword key is not limited. The specific implementation manner and storage format of the mapping relationship between the data ID and the keyword key are not limited in the embodiment of the present invention.
表1Table 1
Figure PCTCN2016089482-appb-000001
Figure PCTCN2016089482-appb-000001
方式二:从所述数据请求信息对应的响应数据value中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系。Manner 2: The data ID is obtained from the response data value corresponding to the data request information, and a mapping relationship between the keyword key and the data ID is established.
在业务服务器中数据ID与响应数据value是一一对应的,因此,业务服务器通过对响应数据value进行解析,获取并确定该响应数据value中携带的数据ID,建立关键字与数据ID之间的映射关系,其中,有关业务服务器建立关键字key与数据ID之间的映射关系,以及该映射关系的存储,请参考上述方式一的有关描述,本发明在此不再对业务服务器建立关键字与数据ID之间的映射关系,以及该映射关系的存储进行一一赘述。In the service server, the data ID and the response data value are in one-to-one correspondence. Therefore, the service server obtains and determines the data ID carried in the response data value by parsing the response data value, and establishes a relationship between the keyword and the data ID. The mapping relationship, wherein the mapping between the keyword key and the data ID is established by the service server, and the storage of the mapping relationship, refer to the related description of the foregoing manner 1. The present invention does not establish a keyword with the service server. The mapping relationship between the data IDs and the storage of the mapping relationships are described in detail.
进一步的,业务服务器在对数据ID对应的响应数据value进行更新时,由该响应数据value的编辑人员对响应数据value进行编辑,编辑完成响应数据value后,点击预置更新组件,实现对响应数据value的更新。从技术实现层面讲,业务服务器在接收到编辑人员点击预置更新组件时,即接收到响应 数据value更新指令时,执行更新响应数据value。因此,本发明实施例中,业务服务器通过对预置更新组件进行监控,即可确定数据ID对应的响应数据value是否有更新。本发明实施例所述的预置更新组件因业务服务器的编程语言不同,可能会存在差异,具体的,预置更新组件可以为保存组件、更新组件、替换组件等等,具体的本发明实施例对预置更新组件不进行限定。Further, when the service server updates the response data value corresponding to the data ID, the editor of the response data value edits the response data value, and after editing the response data value, clicks the preset update component to implement the response data. Update of value. From the technical implementation level, the service server receives the response when it receives the editor's click on the preset update component. When the data value update instruction is executed, the update response data value is executed. Therefore, in the embodiment of the present invention, the service server can determine whether the response data value corresponding to the data ID is updated by monitoring the preset update component. The preset update component of the embodiment of the present invention may be different due to different programming languages of the service server. Specifically, the preset update component may be a save component, an update component, a replacement component, etc., and the specific embodiment of the present invention. The preset update component is not limited.
进一步的,所述关键字key与其对应的响应数据value存储于缓存服务器中,所述关键字key与数据ID存储于业务服务器中,业务服务器在执行根据所述关键字key删除所述缓存服务器中的所述关键字key与其对应的响应数据value时,调用预置函数接口,与缓存服务器建立交互关系,并基于缓存服务器与业务服务器共同能够识别的关键字key,从缓存服务器中获取关键字key对应的响应数据value,将关键字key与其对应的响应数据value删除。将关键字key与其对应的响应数据value删除时,首先,业务服务器根据关键字key;其次,通过遍历的方式在缓存服务器中确定存储关键字key的字段,最后,在关键字key字段中确定所述关键字key与其对应的响应数据value,并将其删除。本发明实施例对业务服务器删除缓存服务器中的关键字key与其对应的响应数据value的具体实现方式不进行限定。Further, the keyword key and its corresponding response data value are stored in the cache server, and the keyword key and the data ID are stored in the service server, and the service server performs the deletion of the cache server according to the keyword key. When the keyword key and the corresponding response data value thereof are used, the preset function interface is invoked to establish an interaction relationship with the cache server, and the keyword key is obtained from the cache server based on the keyword key recognized by the cache server and the service server. The corresponding response data value is deleted by the keyword key and its corresponding response data value. When the keyword key and its corresponding response data value are deleted, first, the service server determines the field storing the key key in the cache server according to the keyword key; secondly, in the traversal manner, and finally determines the keyword in the keyword key field. The keyword key and its corresponding response data value are deleted and deleted. The specific implementation manner of deleting the keyword key and the corresponding response data value in the cache server of the service server is not limited in the embodiment of the present invention.
进一步的,作为对上述图1所示方法的实现,本发明实施例还提供一种缓存数据的更新装置,该装置应用于业务服务器中,如图3所示,该装置包括:Further, as an implementation of the method shown in FIG. 1, the embodiment of the present invention further provides an apparatus for updating cache data, where the apparatus is applied to a service server. As shown in FIG. 3, the apparatus includes:
发送单元31,用于根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器,需要说明的是,数据ID与关键字key是一一对应的映射关系,该映射关系保存于业务服务器中,关键字key与响应数据value也是一一对应的关系,其保存于缓存服务器中,web服务器、缓存服务器及业务服务器之间能够相互通信交互。在本发明实施例中,若缓存服务器中存储有关键字key对应的响应数据value,则说明该响应数据value与业务服务器中数据ID对应的响应数据value是一致的,即该响应数据value是最新的响应数据;The sending unit 31 is configured to send the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and the mapping between the data ID and the keyword key is one-to-one correspondence. The mapping relationship is stored in the service server, and the keyword key and the response data value are also in a one-to-one correspondence, which is stored in the cache server, and the web server, the cache server, and the service server can communicate with each other. In the embodiment of the present invention, if the response data value corresponding to the keyword key is stored in the cache server, it indicates that the response data value is consistent with the response data value corresponding to the data ID in the service server, that is, the response data value is the latest. Response data;
建立单元32,用于建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对 应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;The establishing unit 32 is configured to establish a mapping relationship between the keyword key and the data ID, where the data request information includes the keyword key, and the keyword key is generated by the web server, the web server After receiving the response data, the keyword key and its pair are The response data is stored in the cache server, and the data ID is a unique identifier of the service server storing the response data;
监控单元33,用于监控所述建立单元32中建立的所述映射关系中的所述数据ID对应的响应数据是否有更新,数据ID不会更新变化,但是该数据ID对应的响应数据value时随时更新变化的,其更新变化的时间是随机的,因此,需对该数据ID对应的响应数据value进行监控,以确定该数据ID对应的响应数据value是否有更新;The monitoring unit 33 is configured to monitor whether the response data corresponding to the data ID in the mapping relationship established in the establishing unit 32 is updated, and the data ID is not updated, but the response data value corresponding to the data ID is If the change is updated at any time, the time of the update change is random. Therefore, the response data value corresponding to the data ID needs to be monitored to determine whether the response data value corresponding to the data ID is updated.
获取单元34,用于当确定所述监控单元33监控的所述数据ID对应的响应数据有更新时,基于所述映射关系获取所述关键字key;The obtaining unit 34 is configured to acquire the keyword key based on the mapping relationship when it is determined that the response data corresponding to the data ID monitored by the monitoring unit 33 is updated;
删除单元35,用于根据所述获取单元34获取的所述关键字key删除所述缓存服务器中的所述关键字key及其对应的响应数据,以便客户端用户获取到的响应数据value是实时更新后的数据。The deleting unit 35 is configured to delete the keyword key and the corresponding response data in the cache server according to the keyword key acquired by the obtaining unit 34, so that the response data value obtained by the client user is real-time. Updated data.
进一步的,如图4所示,所述建立单元32包括:Further, as shown in FIG. 4, the establishing unit 32 includes:
第一建立模块321,用于从所述数据请求信息中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系;The first establishing module 321 is configured to obtain the data ID from the data request information, and establish a mapping relationship between the keyword key and the data ID.
第二建立模块322,用于从所述数据请求信息对应的响应数据中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系。The second establishing module 322 is configured to obtain the data ID from the response data corresponding to the data request information, and establish a mapping relationship between the keyword key and the data ID.
进一步的,如图4所示,所述第一建立模块321包括:Further, as shown in FIG. 4, the first establishing module 321 includes:
解析子模块3211,用于对所述数据请求信息进行解析;a parsing submodule 3211, configured to parse the data request information;
获取子模块3212,用于在所述解析子模块3211对所述数据请求信息进行解析之后,获取统一资源定位符URL中的所述数据ID;The obtaining sub-module 3212 is configured to obtain the data ID in the uniform resource locator URL after the parsing sub-module 3211 parses the data request information;
建立子模块3213,用于建立所述关键字key与所述获取子模块3212获取的所述数据ID之间的映射关系。The establishing sub-module 3213 is configured to establish a mapping relationship between the keyword key and the data ID acquired by the obtaining sub-module 3212.
进一步的,如图4所示所述第二建立模块322包括:Further, the second establishing module 322 shown in FIG. 4 includes:
解析子模块3221,用于解析所述数据请求信息对应的响应数据;The parsing sub-module 3221 is configured to parse the response data corresponding to the data request information;
确定子模块3222,用于在所述解析子模块3221解析所述数据请求信息对应的响应数据之后,确定所述数据对应的所述数据ID;a determining sub-module 3222, configured to determine, after the parsing sub-module 3221 parses the response data corresponding to the data request information, the data ID corresponding to the data;
建立子模块3223,用于建立所述关键字key与所述确定子模块3222确定的所述数据ID之间的映射关系。The establishing submodule 3223 is configured to establish a mapping relationship between the keyword key and the data ID determined by the determining submodule 3222.
进一步的,如图4所示,所述装置还包括: Further, as shown in FIG. 4, the device further includes:
存储单元36,用于在所述建立单元32建立关键字key与数据ID之间的映射关系之后,将所述映射关系存储于数据库中。The storage unit 36 is configured to store the mapping relationship in the database after the establishing unit 32 establishes a mapping relationship between the keyword key and the data ID.
进一步的,所述监控单元33,还用于对预置更新组件进行监控,以确定数据ID对应的响应数据是否有更新,所述预置更新组件用于对所述数据ID对应的响应数据进行更新。Further, the monitoring unit 33 is further configured to monitor the preset update component to determine whether the response data corresponding to the data ID is updated, and the preset update component is configured to perform response data corresponding to the data ID. Update.
进一步的,如图4所示,所述删除单元35包括:Further, as shown in FIG. 4, the deleting unit 35 includes:
获取模块351,用于调用预置函数接口获取所述缓存服务器中所述关键字key及其对应的响应数据;The obtaining module 351 is configured to invoke the preset function interface to obtain the keyword key and the corresponding response data in the cache server.
删除模块352,用于将所述获取模块351获取的所述关键字key及其对应的响应数据删除。The deleting module 352 is configured to delete the keyword key and the corresponding response data acquired by the obtaining module 351.
本发明实施例提供的缓存数据的更新装置,业务服务器在接收到web服务器发送的数据请求信息之后,对该请求信息进行异步处理,包括:将该数据请求信息对应的响应数据发送至web服务器以及建立关键字key与数据ID之间的映射关系,其中,该数据请求信息中包含关键字key,该关键字key由web服务器生成,当web服务器接收到响应数据后,将该关键字key与响应数据存储于缓存服务器中,该数据ID为业务服务器存储响应数据的唯一标识;业务服务器基于建立的关键字key与数据ID之间的映射关系监控数据ID对应的响应数据是否有更新,当确定数据ID对应的响应数据有更新时,基于映射关系获取关键字key,并将该关键字key与其对应的响应数据从缓存服务器中删除,实现使缓存服务器中响应数据的主动失效;与现有技术相比,本发明实施例通过建立的数据ID与关键字key之间的映射关系,并对该数据ID对应的响应数据进行实时监控,确保客户端用户获取的响应数据为实时更新的响应数据,以提高客户端用户获取响应数据的准确性,进而提高了客户端用户的用户体验。The method for updating the cached data provided by the embodiment of the present invention, after receiving the data request information sent by the web server, the service server asynchronously processing the request information, including: sending the response data corresponding to the data request information to the web server, and Establishing a mapping relationship between the keyword key and the data ID, wherein the data request information includes a keyword key generated by the web server, and when the web server receives the response data, the keyword key and the response are The data is stored in the cache server, and the data ID is a unique identifier of the service server storing the response data; the service server monitors whether the response data corresponding to the data ID is updated based on the mapping relationship between the established keyword key and the data ID, when the data is determined. When the response data corresponding to the ID is updated, the keyword key is obtained based on the mapping relationship, and the keyword key and its corresponding response data are deleted from the cache server, so that the response data in the cache server is actively invalidated; Compared with the data ID and the keyword k established by the embodiment of the present invention The mapping relationship between ey and real-time monitoring of the response data corresponding to the data ID ensures that the response data obtained by the client user is real-time updated response data, so as to improve the accuracy of the client user to obtain response data, thereby improving the accuracy. The user experience of the client user.
需要说明的是,针对上述缓存数据的更新装置,凡是本发明实施例中使用到的各个单元模块的功能都可以通过硬件处理器(hardware processor)来实现。It should be noted that, for the above-mentioned cache data update device, the functions of the respective unit modules used in the embodiments of the present invention can be implemented by a hardware processor.
示例性的,假设,所述缓存数据的更新装置为业务服务器,如图5所示,图5示出了本发明实施例提供的一种业务服务器的结构示意图,该服务器可以包括:处理器(processor)51、通信接口(Communications Interface)52、存储 器(memory)53和总线54,其中,处理器51、通信接口52、存储器53通过总线54完成相互间的通信。通信接口52可以用于服务器与客户端之间的信息传输。处理器51可以调用存储器53中的逻辑指令,以执行如下方法:业务服务器根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器,并建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;监控所述数据ID对应的响应数据是否有更新;若确定所述数据ID对应的响应数据有更新,则基于所述映射关系获取所述关键字key,并根据所述关键字key删除所述缓存服务器中的所述关键字key与其对应的响应数据。Illustratively, it is assumed that the update device of the cached data is a service server. As shown in FIG. 5, FIG. 5 is a schematic structural diagram of a service server according to an embodiment of the present invention. The server may include: a processor ( Processor) 51, communication interface (Communications Interface) 52, storage A memory 53 and a bus 54, wherein the processor 51, the communication interface 52, and the memory 53 complete communication with each other via the bus 54. Communication interface 52 can be used for information transfer between the server and the client. The processor 51 can call the logic instruction in the memory 53 to perform the following method: the service server sends the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and establishes a keyword key. a mapping relationship between the data ID and the data ID; wherein the data request information includes the keyword key, and the keyword key is generated by the web server, and after receiving the response data, the web server The keyword key and its corresponding response data are stored in the cache server, the data ID is a unique identifier of the service server storing the response data; monitoring whether the response data corresponding to the data ID is updated; if the data ID is determined If the corresponding response data is updated, the keyword key is obtained based on the mapping relationship, and the keyword key and the corresponding response data in the cache server are deleted according to the keyword key.
此外,上述的存储器53中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the logic instructions in the memory 53 described above may be implemented in the form of a software functional unit and sold or used as a stand-alone product, and may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used 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: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without deliberate labor.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部 分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the various embodiments can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware. Based on such understanding, the above technical solutions are essential or contributing to the prior art. The points may be embodied in the form of a software product, which may be stored in a computer readable storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., including instructions for causing a computer device (which may be a personal computer) The server, or network device, etc.) performs the methods described in various embodiments or portions of the embodiments.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。 It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not limited thereto; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that The technical solutions described in the foregoing embodiments are modified, or the equivalents of the technical features are replaced. The modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (16)

  1. 一种缓存数据的更新方法,其特征在于,包括:A method for updating cached data, comprising:
    业务服务器根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器,并建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;The service server sends the response data corresponding to the data request information to the web server according to the data request information sent by the web server, and establishes a mapping relationship between the keyword key and the data ID; wherein, in the data request information The keyword key is generated, and the keyword key is generated by the web server. After receiving the response data, the web server stores the keyword key and its corresponding response data in a cache server. The data ID is a unique identifier for storing the response data by the service server;
    监控所述数据ID对应的响应数据是否有更新;Monitoring whether the response data corresponding to the data ID is updated;
    若确定所述数据ID对应的响应数据有更新,则基于所述映射关系获取所述关键字key,并根据所述关键字key删除所述缓存服务器中的所述关键字key与其对应的响应数据。If it is determined that the response data corresponding to the data ID is updated, acquiring the keyword key based on the mapping relationship, and deleting the keyword key and the corresponding response data in the cache server according to the keyword key .
  2. 根据权利要求1所述的方法,其特征在于,建立关键字key与数据ID之间的映射关系,包括:The method according to claim 1, wherein the mapping between the keyword key and the data ID is established, including:
    从所述数据请求信息中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系;Obtaining the data ID from the data request information, establishing a mapping relationship between the keyword key and the data ID;
    或者,从所述数据请求信息对应的响应数据中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系。Alternatively, the data ID is obtained from the response data corresponding to the data request information, and a mapping relationship between the keyword key and the data ID is established.
  3. 根据权利要求2所述的方法,其特征在于,从所述数据请求信息中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系包括:The method according to claim 2, wherein the obtaining the data ID from the data request information, establishing a mapping relationship between the keyword key and the data ID comprises:
    对所述数据请求信息进行解析,获取统一资源定位符URL中的所述数据ID;Parsing the data request information to obtain the data ID in the uniform resource locator URL;
    建立所述关键字key与所述数据ID之间的映射关系。Establishing a mapping relationship between the keyword key and the data ID.
  4. 根据权利要求2所述的方法,其特征在于:从所述数据请求信息对应的响应数据中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系包括:The method according to claim 2, wherein the data ID is obtained from the response data corresponding to the data request information, and the mapping relationship between the keyword key and the data ID is established:
    解析所述数据请求信息对应的响应数据,确定所述响应数据对应的所述数据ID;Parsing the response data corresponding to the data request information, and determining the data ID corresponding to the response data;
    建立所述关键字key与所述数据ID之间的映射关系。Establishing a mapping relationship between the keyword key and the data ID.
  5. 根据权利要求1-4中任一项所述的方法,其特征在于,在建立关键字 key与数据ID之间的映射关系之后,所述方法还包括:Method according to any of the claims 1-4, characterized in that the keyword is established After the mapping between the key and the data ID, the method further includes:
    将所述映射关系存储于数据库中。The mapping relationship is stored in a database.
  6. 根据权利要求5所述的方法,其特征在于,监控所述数据ID对应的响应数据是否有更新包括:The method according to claim 5, wherein monitoring whether the response data corresponding to the data ID is updated comprises:
    对预置更新组件进行监控,以确定数据ID对应的响应数据是否有更新,所述预置更新组件用于对所述数据ID对应的响应数据进行更新。The preset update component is monitored to determine whether the response data corresponding to the data ID is updated, and the preset update component is configured to update the response data corresponding to the data ID.
  7. 根据权利要求6所述的方法,其特征在于,根据所述关键字key删除所述缓存服务器中的所述关键字key与其对应的响应数据包括:The method according to claim 6, wherein deleting the keyword key and the corresponding response data in the cache server according to the keyword key comprises:
    调用预置函数接口获取所述缓存服务器中所述关键字key及其对应的响应数据;Calling a preset function interface to obtain the keyword key and the corresponding response data in the cache server;
    将所述关键字key及其对应的响应数据删除。The keyword key and its corresponding response data are deleted.
  8. 一种缓存数据的更新装置,其特征在于,包括:An apparatus for updating cached data, comprising:
    发送单元,用于根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器;a sending unit, configured to send, according to the data request information sent by the web server, response data corresponding to the data request information to the web server;
    建立单元,用于建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;a establishing unit, configured to establish a mapping relationship between the keyword key and the data ID; wherein the data request information includes the keyword key, the keyword key is generated by the web server, and the web server receives After the response data, the keyword key and its corresponding response data are stored in a cache server, where the data ID is a unique identifier of the service server storing the response data;
    监控单元,用于监控所述建立单元中建立的所述映射关系中的所述数据ID对应的响应数据是否有更新;a monitoring unit, configured to monitor whether the response data corresponding to the data ID in the mapping relationship established in the establishing unit is updated;
    获取单元,用于当确定所述监控单元监控的所述数据ID对应的响应数据有更新时,基于所述映射关系获取所述关键字key;An acquiring unit, configured to acquire the keyword key based on the mapping relationship when it is determined that the response data corresponding to the data ID monitored by the monitoring unit is updated;
    删除单元,用于根据所述获取单元获取的所述关键字key删除所述缓存服务器中的所述关键字key及其对应的响应数据。a deleting unit, configured to delete the keyword key and the corresponding response data in the cache server according to the keyword key acquired by the acquiring unit.
  9. 根据权利要求8所述的装置,其特征在于,所述建立单元包括:The apparatus according to claim 8, wherein said establishing unit comprises:
    第一建立模块,用于从所述数据请求信息中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系;a first establishing module, configured to acquire the data ID from the data request information, and establish a mapping relationship between the keyword key and the data ID;
    第二建立模块,用于从所述数据请求信息对应的响应数据中获取所述数据ID,建立所述关键字key与所述数据ID之间的映射关系。 And a second establishing module, configured to acquire the data ID from the response data corresponding to the data request information, and establish a mapping relationship between the keyword key and the data ID.
  10. 根据权利要求9所述的装置,其特征在于,所述第一建立模块包括:The apparatus according to claim 9, wherein the first establishing module comprises:
    解析子模块,用于对所述数据请求信息进行解析;a parsing submodule, configured to parse the data request information;
    获取子模块,用于在所述解析子模块对所述数据请求信息进行解析之后,获取统一资源定位符URL中的所述数据ID;Obtaining a submodule, configured to obtain the data ID in the uniform resource locator URL after the parsing submodule parses the data request information;
    建立子模块,用于建立所述关键字key与所述获取子模块获取的所述数据ID之间的映射关系。And establishing a sub-module, configured to establish a mapping relationship between the keyword key and the data ID acquired by the acquiring sub-module.
  11. 根据权利要求9所述的装置,其特征在于,所述第二建立模块包括:The apparatus according to claim 9, wherein the second establishing module comprises:
    解析子模块,用于解析所述数据请求信息对应的响应数据;a parsing submodule, configured to parse the response data corresponding to the data request information;
    确定子模块,用于在所述解析子模块解析所述数据请求信息对应的响应数据之后,确定所述数据对应的所述数据ID;Determining a sub-module, after the parsing sub-module parses the response data corresponding to the data request information, determining the data ID corresponding to the data;
    建立子模块,用于建立所述关键字key与所述确定子模块确定的所述数据ID之间的映射关系。And establishing a submodule, configured to establish a mapping relationship between the keyword key and the data ID determined by the determining submodule.
  12. 根据权利要求8-11中任一项所述的装置,其特征在于,所述装置还包括:The device according to any one of claims 8-11, wherein the device further comprises:
    存储单元,用于在所述建立单元建立关键字key与数据ID之间的映射关系之后,将所述映射关系存储于数据库中。And a storage unit, configured to store the mapping relationship in the database after the establishing unit establishes a mapping relationship between the keyword key and the data ID.
  13. 根据权利要求12所述的装置,其特征在于,所述监控单元,还用于对预置更新组件进行监控,以确定数据ID对应的响应数据是否有更新,所述预置更新组件用于对所述数据ID对应的响应数据进行更新。The device according to claim 12, wherein the monitoring unit is further configured to monitor the preset update component to determine whether the response data corresponding to the data ID is updated, and the preset update component is configured to The response data corresponding to the data ID is updated.
  14. 根据权利要求13所述的装置,其特征在于,所述删除单元包括:The device according to claim 13, wherein the deleting unit comprises:
    获取模块,用于调用预置函数接口获取所述缓存服务器中所述关键字key及其对应的响应数据;An obtaining module, configured to invoke a preset function interface to obtain the keyword key and the corresponding response data in the cache server;
    删除模块,用于将所述获取模块获取的所述关键字key及其对应的响应数据删除。And a deleting module, configured to delete the keyword key and the corresponding response data acquired by the acquiring module.
  15. 一种电子装置,其特征在于,包括:An electronic device, comprising:
    一个或多个处理器;和One or more processors; and
    存储器;Memory
    其中所述存储器中存储有指令,经配置所述指令由所述一个或多个处理器执行,所述一个或多个处理器通过执行所述指令能进行如下操作:Wherein the memory stores instructions that are configured to be executed by the one or more processors, and the one or more processors can perform the following operations by executing the instructions:
    根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应 数据发送至所述web服务器;Responding to the data request information according to the data request information sent by the web server Data is sent to the web server;
    建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;Establishing a mapping relationship between the keyword key and the data ID; wherein the data request information includes the keyword key, the keyword key is generated by the web server, and the web server receives the response data And storing the keyword key and its corresponding response data in a cache server, where the data ID is a unique identifier of the service server storing the response data;
    监控所述映射关系中的所述数据ID对应的响应数据是否有更新;Monitoring whether the response data corresponding to the data ID in the mapping relationship is updated;
    当确定所述数据ID对应的响应数据有更新时,基于所述映射关系获取所述关键字key;When it is determined that the response data corresponding to the data ID is updated, acquiring the keyword key based on the mapping relationship;
    根据获取的所述关键字key删除所述缓存服务器中的所述关键字key及其对应的响应数据。Deleting the keyword key and the corresponding response data in the cache server according to the obtained keyword key.
  16. 一种非易失性计算机可读取存储介质,其特征在于,其中记录了能对缓存数据进行更新的程序,所述程序使计算机执行如下步骤:A non-volatile computer readable storage medium characterized in that a program capable of updating cached data is recorded, the program causing a computer to perform the following steps:
    根据web服务器发送的数据请求信息,将所述数据请求信息对应的响应数据发送至所述web服务器;Transmitting the response data corresponding to the data request information to the web server according to the data request information sent by the web server;
    建立关键字key与数据ID之间的映射关系;其中,所述数据请求信息中包含所述关键字key,所述关键字key由所述web服务器生成,所述web服务器接收到所述响应数据后,将所述关键字key与其对应的响应数据存储于缓存服务器中,所述数据ID为所述业务服务器存储响应数据的唯一标识;Establishing a mapping relationship between the keyword key and the data ID; wherein the data request information includes the keyword key, the keyword key is generated by the web server, and the web server receives the response data And storing the keyword key and its corresponding response data in a cache server, where the data ID is a unique identifier of the service server storing the response data;
    监控所述映射关系中的所述数据ID对应的响应数据是否有更新;Monitoring whether the response data corresponding to the data ID in the mapping relationship is updated;
    当确定所述数据ID对应的响应数据有更新时,基于所述映射关系获取所述关键字key;When it is determined that the response data corresponding to the data ID is updated, acquiring the keyword key based on the mapping relationship;
    根据获取的所述关键字key删除所述缓存服务器中的所述关键字key及其对应的响应数据。 Deleting the keyword key and the corresponding response data in the cache server according to the obtained keyword key.
PCT/CN2016/089482 2015-12-01 2016-07-08 Cache data update method and device WO2017092351A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US15/246,528 US20170155712A1 (en) 2015-12-01 2016-08-24 Method and device for updating cache data

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510864595.XA CN105868231A (en) 2015-12-01 2015-12-01 Cache data updating method and device
CN201510864595X 2015-12-01

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/246,528 Continuation US20170155712A1 (en) 2015-12-01 2016-08-24 Method and device for updating cache data

Publications (1)

Publication Number Publication Date
WO2017092351A1 true WO2017092351A1 (en) 2017-06-08

Family

ID=56623722

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/089482 WO2017092351A1 (en) 2015-12-01 2016-07-08 Cache data update method and device

Country Status (2)

Country Link
CN (1) CN105868231A (en)
WO (1) WO2017092351A1 (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143744A (en) * 2019-12-26 2020-05-12 杭州安恒信息技术股份有限公司 Method, device and equipment for detecting web assets and readable storage medium
CN111581213A (en) * 2020-05-06 2020-08-25 北京金堤科技有限公司 Information recording method, device and equipment
CN111813792A (en) * 2020-06-22 2020-10-23 上海悦易网络信息技术有限公司 Method and equipment for updating cache data in distributed cache system
CN112100653A (en) * 2020-08-21 2020-12-18 北京思特奇信息技术股份有限公司 Method and system for processing front-end sensitive information
CN112463379A (en) * 2020-11-27 2021-03-09 北京浪潮数据技术有限公司 Management method and system of virtual cache server, electronic equipment and storage medium
CN112506971A (en) * 2020-12-14 2021-03-16 福建福讯人才服务有限公司 Automatic data caching method and system based on redis
CN113127452A (en) * 2021-05-18 2021-07-16 京东科技控股股份有限公司 Data query method, device, equipment, storage medium and program product
CN114003593A (en) * 2021-11-02 2022-02-01 北京搜房科技发展有限公司 Method and device for clearing cache data, storage medium and electronic equipment
CN114003629A (en) * 2021-10-29 2022-02-01 深圳壹账通智能科技有限公司 Efficient pre-compiling type cache data management method, device, equipment and medium
CN114844947A (en) * 2022-04-29 2022-08-02 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium
CN115835147A (en) * 2022-11-23 2023-03-21 中国工商银行股份有限公司 Short message related information processing method and device

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108108180B (en) * 2016-11-24 2021-06-08 百度在线网络技术(北京)有限公司 Method and device for dynamically updating application during running
CN106815327A (en) * 2016-12-29 2017-06-09 南京欣网互联信息技术有限公司 One kind is for moving operation data resource regeneration method
CN107220276B (en) * 2017-04-14 2021-02-12 弘成科技发展有限公司 Examination ranking method in live broadcast and playback processes
CN109962965A (en) * 2017-12-26 2019-07-02 深圳联友科技有限公司 A kind of method and device of data buffer storage
CN108600320A (en) * 2018-03-23 2018-09-28 阿里巴巴集团控股有限公司 A kind of data cache method, apparatus and system
CN110162543A (en) * 2019-05-29 2019-08-23 北京奇艺世纪科技有限公司 A kind of information query method and device
CN110909007B (en) * 2019-10-25 2021-10-15 苏州浪潮智能科技有限公司 Data synchronization method, data synchronization device and storage medium
CN113313540B (en) * 2021-08-02 2021-09-28 云账户技术(天津)有限公司 Contract generation method and device, electronic equipment and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101127783A (en) * 2007-09-28 2008-02-20 北京金山软件有限公司 A website buffering method and device
US20100180208A1 (en) * 2009-01-15 2010-07-15 Kasten Christopher J Server side data cache system
CN102111449A (en) * 2011-02-23 2011-06-29 北京蓝汛通信技术有限责任公司 Method, device and system for updating data
CN103873451A (en) * 2012-12-17 2014-06-18 中国移动通信集团公司 Data synchronization method, equipment and system
CN104657401A (en) * 2014-10-21 2015-05-27 北京齐尔布莱特科技有限公司 Web cache updating method

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102541927B (en) * 2010-12-30 2013-11-13 北京新媒传信科技有限公司 Method and device for realizing data cache
CN103701929A (en) * 2014-01-02 2014-04-02 中安消技术有限公司 Method and device for realizing business data caching

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101127783A (en) * 2007-09-28 2008-02-20 北京金山软件有限公司 A website buffering method and device
US20100180208A1 (en) * 2009-01-15 2010-07-15 Kasten Christopher J Server side data cache system
CN102111449A (en) * 2011-02-23 2011-06-29 北京蓝汛通信技术有限责任公司 Method, device and system for updating data
CN103873451A (en) * 2012-12-17 2014-06-18 中国移动通信集团公司 Data synchronization method, equipment and system
CN104657401A (en) * 2014-10-21 2015-05-27 北京齐尔布莱特科技有限公司 Web cache updating method

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111143744B (en) * 2019-12-26 2023-10-13 杭州安恒信息技术股份有限公司 Method, device and equipment for detecting web asset and readable storage medium
CN111143744A (en) * 2019-12-26 2020-05-12 杭州安恒信息技术股份有限公司 Method, device and equipment for detecting web assets and readable storage medium
CN111581213A (en) * 2020-05-06 2020-08-25 北京金堤科技有限公司 Information recording method, device and equipment
CN111581213B (en) * 2020-05-06 2024-02-13 北京金堤科技有限公司 Information recording method, device and equipment
CN111813792A (en) * 2020-06-22 2020-10-23 上海悦易网络信息技术有限公司 Method and equipment for updating cache data in distributed cache system
CN112100653A (en) * 2020-08-21 2020-12-18 北京思特奇信息技术股份有限公司 Method and system for processing front-end sensitive information
CN112100653B (en) * 2020-08-21 2024-02-20 北京思特奇信息技术股份有限公司 Front-end sensitive information processing method and system
CN112463379A (en) * 2020-11-27 2021-03-09 北京浪潮数据技术有限公司 Management method and system of virtual cache server, electronic equipment and storage medium
CN112506971A (en) * 2020-12-14 2021-03-16 福建福讯人才服务有限公司 Automatic data caching method and system based on redis
CN113127452A (en) * 2021-05-18 2021-07-16 京东科技控股股份有限公司 Data query method, device, equipment, storage medium and program product
CN114003629A (en) * 2021-10-29 2022-02-01 深圳壹账通智能科技有限公司 Efficient pre-compiling type cache data management method, device, equipment and medium
CN114003593A (en) * 2021-11-02 2022-02-01 北京搜房科技发展有限公司 Method and device for clearing cache data, storage medium and electronic equipment
CN114844947A (en) * 2022-04-29 2022-08-02 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium
CN114844947B (en) * 2022-04-29 2024-03-26 北京达佳互联信息技术有限公司 Request processing method and device, electronic equipment and computer readable medium
CN115835147A (en) * 2022-11-23 2023-03-21 中国工商银行股份有限公司 Short message related information processing method and device

Also Published As

Publication number Publication date
CN105868231A (en) 2016-08-17

Similar Documents

Publication Publication Date Title
WO2017092351A1 (en) Cache data update method and device
CA2954294C (en) Website access method, apparatus, and website system
US9641468B2 (en) Method, server, client, and system for releasing instant messaging key-value data
WO2017114205A1 (en) Short link processing method, device and server
CN110019211A (en) The methods, devices and systems of association index
CN108429777B (en) Data updating method based on cache and server
CN107357896A (en) Expansion method, device, system and the data base cluster system of data-base cluster
EP3491808B1 (en) Interchangeable retrieval of content
US20170155712A1 (en) Method and device for updating cache data
US10324896B2 (en) Method and apparatus for acquiring resource
TW201317799A (en) Sharing control system and method for network resources download information
US20220210493A1 (en) Method and apparatus for downloading resources
US9075722B2 (en) Clustered and highly-available wide-area write-through file system cache
CN112513830A (en) Back-source method and related device in content distribution network
WO2014161261A1 (en) Data storage method and apparatus
CN107844488B (en) Data query method and device
WO2024124663A1 (en) Method and apparatus for supporting batch cdn cache refresh
WO2016082616A1 (en) Method and device for providing website authentication data for search engine
CN113127923A (en) Method and device for managing authority
CN114398372A (en) Data caching method and device
WO2019196225A1 (en) Resource file feedback method and apparatus
US10313469B2 (en) Method, apparatus and system for processing user generated content
US11057470B2 (en) Communication device and communication method for processing meta data
CN113742617A (en) Cache updating method and device
WO2017092350A1 (en) Method and device for improving cache hit ratio

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16869664

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16869664

Country of ref document: EP

Kind code of ref document: A1