Data caching method and device, electronic equipment and computer readable storage medium
By receiving data requests and determining whether to cache data based on the number of accesses, the problems of slow response to hot data and heavy storage service burden are solved, and efficient caching of real-time changing data is achieved.
Patent Information
- Application Number
- CN202011118269.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-19
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2041-06-07
AI Technical Summary
In the existing technology, the response speed of hot data is slow, the storage service is heavily burdened, and it is impossible to predict in advance the real-time changing data that needs to be cached.
By receiving data requests, it is determined whether the required data exists in the cache. If not, the data and its access count are obtained from the data storage source, and cached when the access count exceeds the threshold.
It realizes dynamic caching of real-time changing data, improves data response speed, and reduces the burden of storage services.
Smart Images

Figure CN112256733B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data caching, and in particular to a data caching method, device, electronic device, and computer-readable storage medium. Background Art
[0002] With the rapid development of information technology, mobile internet technology has also advanced by leaps and bounds. Whether it's the emergence of smart devices, the advent of the 5G era, or the application of technologies like big data, AI, and algorithms, all have given mobile devices the wings to soar. In real life, these technologies have enriched social interactions. The smartphone, in particular, has broken the time and space constraints of daily human interactions. It is a truly comprehensive handheld mobile device that integrates massive amounts of information, online audio-visual content, and leisure and entertainment, satisfying people's daily information needs and social interactions.
[0003] Internet businesses often encounter frequently accessed hot data. Repeated access to this data can increase the burden on storage services, leading to lags. Furthermore, the storage devices used by these services are often large and slow, making them incapable of responding quickly enough to hot data. Predictable hot data, such as major news and events, can be cached in advance. However, data whose popularity fluctuates in real time is difficult to predict, making it difficult to determine which data needs to be cached. Summary of the Invention
[0004] This summary is provided to briefly introduce concepts that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] In order to solve the above technical problems, the embodiments of the present disclosure propose the following technical solutions.
[0006] In a first aspect, an embodiment of the present disclosure provides a data caching method, comprising:
[0007] receiving a first request from a data request source;
[0008] In response to the first data requested by the first request not existing in the cache, sending a second request to a data storage source;
[0009] receiving the first data and an access count of the first data from the data storage source;
[0010] sending the first data to the data request source;
[0011] In response to the number of accesses to the first data being greater than a first threshold, the first data is cached.
[0012] In a second aspect, an embodiment of the present disclosure provides a data sending method, including:
[0013] receiving a second request from a data forwarding source;
[0014] In response to the source parameter in the second request being a data request source, accumulating the number of accesses to the first data corresponding to the second request;
[0015] The first data and the number of times the first data is accessed are sent to the data forwarding source.
[0016] In a third aspect, an embodiment of the present disclosure provides a data cache device, including:
[0017] A first receiving module, configured to receive a data request from a data request source;
[0018] a request sending module, configured to send a second request to a data storage source in response to the first data requested by the first request not existing in the cache;
[0019] a second receiving module, configured to receive the first data and the number of times the first data is accessed from the data storage source;
[0020] a first sending module, configured to send the first data to the data request source;
[0021] The data caching module is configured to cache the first data in response to the number of times the first data is accessed being greater than a first threshold.
[0022] In a fourth aspect, an embodiment of the present disclosure provides a data sending device, including:
[0023] A second receiving module, configured to receive a data request;
[0024] a second sending module, configured to send the first data corresponding to the data request and the number of times the first data is accessed to a data forwarding source in response to a source parameter in the data request being a data request source;
[0025] The first accumulation module is configured to accumulate the number of times the first data is accessed.
[0026] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, comprising: at least one processor; and
[0027] A memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any of the aforementioned methods.
[0028] In a sixth aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium, characterized in that the non-transitory computer-readable storage medium stores computer instructions, which are used to enable a computer to execute any of the aforementioned methods.
[0029] The embodiments of the present disclosure disclose a data caching method, apparatus, electronic device, and computer-readable storage medium. The data caching method includes: receiving a first request from a data request source; in response to the first data requested by the first request not being present in the cache, sending a second request to a data storage source; receiving the first data and the number of accesses to the first data from the data storage source; sending the first data to the data request source; and in response to the number of accesses to the first data being greater than a first threshold, caching the first data. The above method solves the problem that real-time changing data cannot be cached in advance by obtaining the number of accesses to the data and comparing it with the threshold to determine whether to cache it.
[0030] The above description is only an overview of the technical solution of the present disclosure. In order to more clearly understand the technical means of the present disclosure, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the following specifically cites preferred embodiments and describes them in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0032] Figure 1 A flowchart of a data caching method provided in an embodiment of the present disclosure;
[0033] Figure 2 A further flowchart of the data caching method provided in an embodiment of the present disclosure;
[0034] Figure 3 A further flowchart of the data caching method provided in an embodiment of the present disclosure;
[0035] Figure 4 A further flowchart of the data caching method provided in an embodiment of the present disclosure;
[0036] Figure 5 A further flowchart of the data caching method provided in an embodiment of the present disclosure;
[0037] Figure 6 A flowchart of a data transmission method provided by an embodiment of the present disclosure;
[0038] Figure 7 A further flowchart of the data sending method provided in an embodiment of the present disclosure;
[0039] Figure 8 A schematic diagram of an application scenario of the data caching method and the data sending method provided in an embodiment of the present disclosure.
[0040] Figure 9 A schematic diagram of the structure of an embodiment of a data cache device provided in an embodiment of the present disclosure;
[0041] Figure 10 A schematic structural diagram of an embodiment of a data sending device provided in an embodiment of the present disclosure;
[0042] Figure 11 The figure is a schematic structural diagram of an electronic device provided according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0043] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0044] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0045] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0046] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0047] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0048] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0049] Figure 1 This is a flow chart of an embodiment of a data caching method provided by an embodiment of the present disclosure. The data caching method provided by this embodiment can be executed by a data caching device. The data caching device can be implemented as software, or as a combination of software and hardware. The data caching device can be integrated into a device in a data caching system, such as a data caching server or a data caching terminal device. Figure 1 As shown, the method includes the following steps:
[0050] Step S101, receiving a first request from a data request source;
[0051] Optionally, the data request source includes various terminal devices or platform devices, etc., which send data requests to the data storage source to request the required data. Exemplarily, the data request source is a client device that joins the live broadcast room, which periodically pulls the latest messages in the live broadcast room from the live broadcast server.
[0052] Optionally, the data caching method is performed by a data caching device, which is exemplarily implemented as a proxy process on a server. It is understandable that the data caching device can also be implemented in other ways, such as a data caching device, etc., which will not be described in detail here.
[0053] Optionally, the first request includes an identifier of the requested target data and an identifier of the data request source, wherein the target data is specific data or a category of data. For example, in a live broadcast scenario, a terminal device in a live broadcast room can pull only messages from the anchor device or pull messages from the entire live broadcast room. Generally, if a client in a live broadcast room pulls messages from the entire live broadcast room each time, the identifier of the target data is the identifier of the live broadcast room, such as Live Broadcast Room 1; and the identifier of the data request source is the identifier of the client, such as Client 1.
[0054] Step S102 , in response to the first data requested by the first request not existing in the cache, sending a second request to a data storage source;
[0055] After receiving the first request, it is first determined whether the cache contains the first data requested by the first request, such as all the new data in Live Studio 1. If the number of times the data is pulled is not enough or the requested data is not hot data, the first data does not exist in the cache. At this time, the execution device of the data caching method will send a second request to the data storage source to request the first data, wherein the data storage source stores all the data that the data request source can obtain.
[0056] Optional, such as Figure 2 As shown, sending the second request to the data storage source further includes:
[0057] Step S201: Generate a second request, wherein the source parameter in the second request is the data request source;
[0058] Step S202: Send the second request to a data storage source.
[0059] In the above step S201, a second request is generated, wherein the second request includes a source parameter. Since the second request is generated by the execution device of the data caching method, its source parameter needs to be set to the data request source that actually requests the first data. Exemplarily, the source parameter is from. When the data request source is a client device, from=client is set.
[0060] After generating the second request, the second request is sent to a data storage source to request the first data requested by the first request.
[0061] Step S103: receiving the first data and the number of times the first data is accessed from the data storage source;
[0062] In this step, the first data requested by the first request is received from the data storage source, and the number of accesses to the first data is also received. Optionally, the number of accesses to the first data is the number of times the first data is read per unit time.
[0063] For example, the first data is message data in the first live broadcast room, and the number of accesses to the first data is the number of times messages in the first live broadcast room are pulled within 1 second. The number of accesses can reflect the popularity of the first live broadcast room. That is, the more accesses there are, the more attention the first live broadcast room receives, and the more times its message data is likely to be accessed.
[0064] Step S104: sending the first data to the data request source;
[0065] After obtaining the first data, it is sent to the data request source requesting the first data. Exemplarily, in a live broadcast scenario, after obtaining the message data of the first live broadcast room in the last 1 second, the execution device of the data caching method sends the message data to the client device that pulls the message data.
[0066] Step S105 : caching the first data in response to the number of accesses to the first data being greater than a first threshold.
[0067] The first threshold is a preset value; exemplarily, in a live broadcast scenario, if the number of accesses to the message data of the first live broadcast room is CountRoom1, if CountRoom1>K, where K is the first threshold, it means that the popularity of the first live broadcast room is very high, and more client devices may access the message data of the first live broadcast room or the client device may access the message data of the first live broadcast room multiple times, so the message data of the first live broadcast room is cached so that the message data can be quickly sent to the client device during subsequent access.
[0068] Optional, such as Figure 3 As shown, the data caching method further includes:
[0069] Step S301: In response to the first data requested by the first request existing in the cache, the first data in the cache is sent to the data request source.
[0070] Optionally, this step is performed in parallel with step S102. When the data requested by the first request exists in the cache, there is no need to request the first data from the data storage source, but the first data can be sent directly from the cache to the data request source.
[0071] Optionally, the first data is stored in the data cache with the identifier of the first data, and the identifier of the first data indicates the type or source of the first data. For example, in the above-mentioned live broadcast scenario, the ID of the live broadcast room can be used as the identifier of the message data of the live broadcast room. When stored in the cache, all message data of live broadcast room 1 are marked as live broadcast room 1, and the message data of live broadcast room 2 are marked as live broadcast room 2, and so on. In this way, after receiving the first request, the target data to be requested, such as the message data of live broadcast room 1, can be obtained through the target data parameters in the first request. At this time, the ID of live broadcast room 1 is used to query whether there is message data of live broadcast room 1 in the cache. If the message data of live broadcast room 1 is matched, the message data is directly sent to the client device that sent the first request.
[0072] Optional, such as Figure 3As shown, the method further includes:
[0073] Step S302: Accumulate the number of accesses to the first data in the cache.
[0074] When the first data is sent from the cache to the data request source, the number of times the first data has been accessed needs to be recorded in the execution device of the data caching method so that the popularity of the first data can be subsequently calculated. Specifically, a counter is used to record the number of times the first data has been accessed. Each time the first data is accessed, the value of the counter is incremented. When the number of times the first data has been accessed is needed, the value of the counter is directly read.
[0075] Since the popularity of data changes in real time, the current hot data may not be the hot data at the next moment, so it is necessary to dynamically update the data in the cache. Figure 4 As shown, the method further includes:
[0076] Step S401: In response to a first condition being met, sending a cache data update request to the data storage source, wherein the cache data update request includes a data tag in the cache and a number of access times of the data;
[0077] Step S402, receiving first data corresponding to the data tag and the number of times the first data is accessed from the data storage source;
[0078] Step S403 : In response to the access count of the first data being greater than a second threshold, the first data is used to update the data in the cache.
[0079] Optionally, in step S401, the first condition is a timer timeout. For example, the data in the cache is updated every 1 second, and a timer with a timeout of 1 second is set. Whenever the timer times out, a cache data update request is sent to the data storage source to update the data in the cache. The cache data update request includes a data tag in the cache and the number of times the data is accessed. The number of times the data is accessed is the number of times the data is read in the cache. Since the first data in the cache is not obtained from the data storage source, the data storage source does not have the accurate number of times the first data is accessed. In this case, the execution device of the data caching method needs to send the number of times the data is accessed to the data storage source when requesting to update the data in the cache, so that the data storage source can calculate the accurate number of times the data is accessed.
[0080] Optional, such as Figure 5 As shown, the sending of the cache data update request to the data storage source includes:
[0081] Step S501: Generate a second request;
[0082] Step S502: Setting the source parameter in the second request as the forwarding source to generate a cache data update request;
[0083] Step S503: Send the cache data update request to the data storage source.
[0084] In the above optional embodiment, the data update request is actually the second request, except that the source parameter in the second request is set to the forwarding source, that is, the execution device of the data caching method. For example, in a live broadcast scenario, the execution device of the data caching method is a proxy process. Then, setting from = proxy indicates that this is a request used by the proxy process to update the cache, and the data storage source is required to further calculate the data access count based on the access count in the cache data update request and return it.
[0085] In step S402, similar to step S103, first data and the number of accesses to the first data are received from the data storage source. The number of accesses to the first data is the number of accesses recalculated by the data storage source. Typically, the data storage source is connected to multiple devices executing the data caching method, each of which transmits the number of accesses to its cached data. In addition, there may be data accesses newly connected to the data storage source. The data storage source adds these number of accesses together to determine the actual number of accesses to the first data.
[0086] In step S402, the number of accesses to the first data is compared with a second threshold value to determine whether to update the first data in the cache. Optionally, the second threshold value is less than or equal to the first threshold value, wherein the first threshold value is a criterion for determining whether the data is hot data. Since the first data is updated, it means that before the update, the first data meets the condition that the number of accesses is greater than the first threshold value. Therefore, during subsequent updates, the second threshold value can also be made the same as the first threshold value. When the number of accesses to the updated first data is still greater than the first threshold value, it is still hot data, and therefore the new first data is used to update the first data in the cache.
[0087] Optionally, the second threshold can be smaller than the first threshold, such as the second threshold K' = 0.8K. This can filter out some normal fluctuations. For example, after a period of access, the number of visits to hotspot data may decrease, but then increase again, resulting in fluctuations around the first threshold. In this case, if the second threshold is set to the same as the first threshold, the hotspot data may change frequently. Setting the second threshold to a value smaller than the first threshold can effectively filter out such fluctuations.
[0088] Optionally, when the number of accesses to the first data exceeds a second threshold, the first data is used to update the data in the cache. For example, if the cache stores the latest 500 messages in Live Studio 1 and 300 messages are fetched each time, the oldest 300 messages in the cache are updated each time.
[0089] Optionally, the method further includes:
[0090] Step S404: In response to the number of accesses to the first data being less than a second threshold, the data in the cache is deleted.
[0091] When the number of accesses to the first data is less than the second threshold, it indicates that the first data is no longer hot data and storing it in the cache cannot guarantee the efficiency of cache usage. In this case, the corresponding data in the cache is deleted.
[0092] Figure 6 This is a flow chart of an embodiment of a data transmission method provided by an embodiment of the present disclosure. The data transmission method provided by this embodiment can be executed by a data transmission device. The data transmission device can be implemented as software or a combination of software and hardware. The data transmission device can be integrated into a device in a data transmission system, such as a data transmission server or a data transmission terminal device. Figure 6 As shown, the method includes the following steps:
[0093] Step S601, receiving a second request from a data forwarding source;
[0094] The execution device of the data sending method is the data storage source;
[0095] The data forwarding source is the data forwarding source in the above-mentioned data caching method embodiment, that is, the execution device of the data caching method, and the second request is the second request in the above-mentioned embodiment, which will not be repeated here.
[0096] Step S602: In response to the source parameter in the second request being a data request source, accumulating the number of accesses to the first data corresponding to the second request;
[0097] In this step, the value of the source parameter in the second request is determined. When the source parameter is a data request source, the number of accesses to the first data is directly accumulated. It can be understood that a counter is used to record the number of accesses to the first data. Whenever a data request source reads the first data, the value of the counter is accumulated.
[0098] Step S603: Send the first data and the number of times the first data is accessed to the data forwarding source.
[0099] In this step, the first data and the number of times the first data is accessed are sent to the data forwarding source, so that the data forwarding source can forward the first data to the data request source according to steps S101 to S105, and determine whether the first data is cached in the data forwarding source.
[0100] Furthermore, the data sending method further includes:
[0101] Step S701: In response to the source parameter of the second request being a data forwarding source, obtaining a first access count of first data in the second request;
[0102] Step S702: updating the access count of the first data according to the first access count of the first data;
[0103] Step S703: Send the first data and the updated access count of the first data to a data forwarding source.
[0104] The above steps S701-S702 describe the process in which the data storage source updates the actual access count of the first data based on the access count sent by the data forwarding source. As described in the above embodiment, when the source parameter of the second request is the data forwarding source, it means that the second request is a data update request, and the data storage source needs the actual access count of the first data, that is, the access count of the updated first data is obtained by adding the value of the counter in the data storage source and the access count of the first data in the second request. Afterwards, in step S703, the data storage source sends the access count of the first data and the updated first data to the data forwarding source, so that the data forwarding source can determine whether the first data is still hot data based on the access count of the updated first data, so as to determine whether the data in the cache is updated or deleted.
[0105] Through the cooperation of the embodiments of the above-mentioned data caching method and data sending method, the number of times the data is accessed can be recorded in real time, and whether the data is hot data can be dynamically judged based on the number of accesses to determine whether the data needs to be cached. This can solve the problem in the prior art that it is impossible to determine whether the data that changes in real time is hot data.
[0106] Figure 8 FIG. 1 is a schematic diagram of an application scenario of an embodiment of the present disclosure. Figure 8The figure shows a live broadcast application scenario. In this application scenario, there are multiple terminal devices 801-803 and a live broadcast server 804. The live broadcast server starts a proxy service process proxy for each terminal to provide the terminal device with a message data pulling service. The terminal devices 801-803 are all devices in the live broadcast room 1. The terminal devices 801-803 periodically pull the latest message data from the live broadcast server 804. When the message data needs to be pulled, the terminal device sends a data pull request to the live broadcast server 804. The live broadcast server 804 has a proxy service process proxy to process each pull request. The proxy first checks whether the cache contains the message data of the live broadcast room 1. If so, the data of the live broadcast room 1 is directly returned to the terminal device, and the number of accesses to the message data of the live broadcast room 1 in the cache is accumulated. After that, the proxy periodically updates the message data of the live broadcast room 1 from the live broadcast server. Specifically, the proxy sends a pull request, which includes the number of accesses to the message data of Live Room 1 in the cache. The live server adds the received number of accesses to the accumulated number of accesses on the live server to obtain the real number of accesses to the message data of Live Room 1, and returns the latest message data of Live Room 1 and the real number of accesses to the proxy. The proxy determines whether it needs to continue caching the message data of Live Room 1 based on the real number of accesses. If caching is required, the latest message data of Live Room 1 is used to update the data in the cache. If caching is not required, the data in Live Room 1 in the cache is deleted.
[0107] It is understandable that the above live broadcast scenario is only an example. The solution in the embodiment of the present disclosure can actually be applied to various data caching scenarios, such as accessing data in a database, etc., which will not be repeated here.
[0108] The embodiments of the present disclosure disclose a data caching method, apparatus, electronic device, and computer-readable storage medium. The data caching method includes: receiving a first request from a data request source; in response to the first data requested by the first request not being present in the cache, sending a second request to a data storage source; receiving the first data and the number of accesses to the first data from the data storage source; sending the first data to the data request source; and in response to the number of accesses to the first data being greater than a first threshold, caching the first data. The above method solves the problem that real-time changing data cannot be cached in advance by obtaining the number of accesses to the data and comparing it with the threshold to determine whether to cache it.
[0109] In the above, although the various steps in the above method embodiment are described in the above order, those skilled in the art should be aware that the steps in the embodiments of the present disclosure are not necessarily executed in the above order, and they can also be executed in other orders such as reverse order, parallel order, and cross order. Moreover, based on the above steps, those skilled in the art can also add other steps. These obvious variations or equivalent replacement methods should also be included in the scope of protection of the present disclosure and will not be repeated here.
[0110] Figure 9 This is a structural diagram of an embodiment of a data cache device provided by the present disclosure. Figure 9 As shown, the apparatus 900 includes: a first receiving module 901, a request sending module 902, a second receiving module 903, a first sending module 904 and a data caching module 905.
[0111] A first receiving module 901 is configured to receive a first request from a data request source;
[0112] A request sending module 902 is configured to send a second request to a data storage source in response to the first data requested by the first request not existing in the cache;
[0113] A second receiving module 903 is configured to receive the first data and the number of times the first data is accessed from the data storage source;
[0114] A first sending module 904 is configured to send the first data to the data request source;
[0115] The data caching module 905 is configured to cache the first data in response to the number of accesses to the first data being greater than a first threshold.
[0116] Furthermore, the data cache device 900 is further configured to:
[0117] In response to the first data requested by the first request existing in the cache, the first data in the cache is sent to the data request source.
[0118] Furthermore, the data cache device 900 is further configured to:
[0119] The number of accesses to the first data in the cache is accumulated.
[0120] Furthermore, the data cache device 900 is further configured to:
[0121] In response to satisfying the first condition, sending a cache data update request to the data storage source, wherein the cache data update request includes a data tag in the cache and a number of access times of the data;
[0122] receiving, from the data storage source, first data corresponding to the data tag and a number of access times of the first data;
[0123] In response to the access count of the first data being greater than a second threshold, the first data is used to update data in the cache.
[0124] Furthermore, the data cache device 900 is further configured to:
[0125] In response to the access count of the first data being less than a second threshold, the data in the cache is deleted.
[0126] Furthermore, the request sending module 902 is further configured to:
[0127] generating a second request, wherein a source parameter in the second request is the data request source;
[0128] The second request is sent to the data storage source.
[0129] Furthermore, the sending of the cache data update request to the data storage source includes:
[0130] generating a second request;
[0131] Setting the source parameter in the second request to a forwarding source to generate a cache data update request;
[0132] Sending the cache data update request to the data storage source.
[0133] Furthermore, the number of times the first data is accessed is the number of times the first data is read within a unit time.
[0134] Figure 9 The device shown can perform Figure 1-Figure 5 For the method of the embodiment shown in FIG. 1 , reference may be made to the description of the part not described in detail in this embodiment. Figure 1-Figure 5 The implementation process and technical effects of this technical solution can be found in Figure 1-Figure 5 The description in the illustrated embodiment will not be repeated here.
[0135] Figure 10 This is a structural diagram of an embodiment of a data sending device provided by the present disclosure. Figure 10 As shown, the device 1000 includes: a second receiving module 1001, an accumulation module 1002, and a second sending module 1003.
[0136] The second receiving module 1001 is configured to receive a second request from a data forwarding source;
[0137] an accumulation module 1002, configured to accumulate the number of accesses to the first data corresponding to the second request in response to the source parameter in the second request being a data request source;
[0138] The second sending module 1003 is configured to send the first data and the number of times the first data is accessed to the data forwarding source.
[0139] Furthermore, the data sending device 1000 is further configured to:
[0140] In response to a source parameter of the second request being a data forwarding source, obtaining a first access count of the first data in the second request;
[0141] updating the access count of the first data according to the first access count of the first data;
[0142] The first data and the access count of the updated first data are sent to a data forwarding source.
[0143] Figure 10 The device shown can perform Figure 6 and Figure 7 For the method of the embodiment shown in FIG. 1 , reference may be made to the description of the part not described in detail in this embodiment. Figure 6 and Figure 7 The implementation process and technical effects of this technical solution can be found in Figure 6 and Figure 7 The description in the illustrated embodiment will not be repeated here.
[0144] Reference below Figure 11 , which shows a schematic structural diagram of an electronic device 1100 suitable for implementing the embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 11 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0145] like Figure 11As shown, the electronic device 1100 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage device 1108 into a random access memory (RAM) 1103. Various programs and data required for the operation of the electronic device 1100 are also stored in the RAM 1103. The processing device 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0146] Typically, the following devices may be connected to the I / O interface 1105: an input device 1106 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1107 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1108 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1109. The communication device 1109 may allow the electronic device 1100 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 11 The electronic device 1100 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0147] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 1109, or installed from the storage device 1108, or installed from the ROM 1102. When the computer program is executed by the processing device 1101, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0148] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0149] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0150] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0151] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device is enabled to: obtain an input image and a first text; extract features of the input image to obtain a feature vector of the input image; encode the first text to obtain a feature vector of the first text; obtain a joint feature vector based on the feature vector of the input image and the feature vector of the first text; and decode the joint feature vector to generate a second text.
[0152] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0153] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0154] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit does not necessarily limit the unit itself.
[0155] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0156] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0157] According to one or more embodiments of the present disclosure, a data caching method is provided, including:
[0158] receiving a first request from a data request source;
[0159] In response to the first data requested by the first request not existing in the cache, sending a second request to a data storage source;
[0160] receiving the first data and an access count of the first data from the data storage source;
[0161] sending the first data to the data request source;
[0162] In response to the number of accesses to the first data being greater than a first threshold, the first data is cached.
[0163] Furthermore, the method further comprises:
[0164] In response to the first data requested by the first request existing in the cache, the first data in the cache is sent to the data request source.
[0165] Furthermore, the method further comprises:
[0166] The number of accesses to the first data in the cache is accumulated.
[0167] Furthermore, the method further comprises:
[0168] in response to the first condition being satisfied, sending a cache data update request to the data storage source, wherein the cache data update request comprises a data tag of data in the cache and a number of accesses of the data;
[0169] receiving, from the data storage source, first data corresponding to the data tag and a number of accesses of the first data;
[0170] in response to the number of accesses of the first data being greater than a second threshold, updating the data in the cache using the first data.
[0171] Further, the method further comprises:
[0172] in response to the number of accesses of the first data being less than the second threshold, deleting the data in the cache.
[0173] Further, the sending the second request to the data storage source comprises:
[0174] generating the second request, wherein a source parameter in the second request is the data request source;
[0175] sending the second request to the data storage source.
[0176] Further, the sending the cache data update request to the data storage source comprises:
[0177] generating a second request;
[0178] setting the source parameter in the second request as the forwarding source to generate the cache data update request;
[0179] sending the cache data update request to the data storage source.
[0180] Further, the number of accesses of the first data is a number of times the first data is read in a unit of time.
[0181] According to one or more embodiments of the present disclosure, a data sending method is provided, comprising:
[0182] receiving a second request from a data forwarding source;
[0183] in response to a source parameter in the second request being a data request source, accumulating a number of accesses of first data corresponding to the second request;
[0184] sending the first data and the number of accesses of the first data to the data forwarding source.
[0185] Further, the method further comprises:
[0186] In response to a source parameter of the second request being a data forwarding source, obtaining a first access count of the first data in the second request;
[0187] updating the access count of the first data according to the first access count of the first data;
[0188] The first data and the access count of the updated first data are sent to a data forwarding source.
[0189] According to one or more embodiments of the present disclosure, a data cache device is provided, including:
[0190] A first receiving module, configured to receive a first request from a data request source;
[0191] a request sending module, configured to send a second request to a data storage source in response to the first data requested by the first request not existing in the cache;
[0192] a second receiving module, configured to receive the first data and the number of times the first data is accessed from the data storage source;
[0193] a first sending module, configured to send the first data to the data request source;
[0194] The data caching module is configured to cache the first data in response to the number of times the first data is accessed being greater than a first threshold.
[0195] Furthermore, the data cache device is further used to:
[0196] In response to the first data requested by the first request existing in the cache, the first data in the cache is sent to the data request source.
[0197] Furthermore, the data cache device is further used to:
[0198] The number of accesses to the first data in the cache is accumulated.
[0199] Furthermore, the data cache device is further used to:
[0200] In response to satisfying the first condition, sending a cache data update request to the data storage source, wherein the cache data update request includes a data tag in the cache and a number of access times of the data;
[0201] receiving, from the data storage source, first data corresponding to the data tag and a number of accesses to the first data;
[0202] In response to the access count of the first data being greater than a second threshold, the first data is used to update the data in the cache.
[0203] Furthermore, the data cache device is further used to:
[0204] In response to the number of accesses to the first data being less than a second threshold, the data in the cache is deleted.
[0205] Furthermore, the request sending module is further configured to:
[0206] generating a second request, wherein a source parameter in the second request is the data request source;
[0207] The second request is sent to the data storage source.
[0208] Furthermore, the sending of the cache data update request to the data storage source includes:
[0209] generating a second request;
[0210] Setting the source parameter in the second request to a forwarding source to generate a cache data update request;
[0211] Sending the cache data update request to the data storage source.
[0212] Furthermore, the number of times the first data is accessed is the number of times the first data is read within a unit time.
[0213] According to one or more embodiments of the present disclosure, there is provided a data sending device, including:
[0214] A second receiving module, configured to receive a second request from a data forwarding source;
[0215] an accumulation module, configured to accumulate the number of accesses to the first data corresponding to the second request in response to a source parameter in the second request being a data request source;
[0216] The second sending module is configured to send the first data and the number of times the first data is accessed to the data forwarding source.
[0217] Furthermore, the data sending device is further configured to:
[0218] In response to a source parameter of the second request being a data forwarding source, obtaining a first access count of the first data in the second request;
[0219] updating the access count of the first data according to the first access count of the first data;
[0220] The first data and the access count of the updated first data are sent to a data forwarding source.
[0221] According to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any of the foregoing methods.
[0222] According to one or more embodiments of the present disclosure, a non-transitory computer-readable storage medium is provided, characterized in that the non-transitory computer-readable storage medium stores computer instructions for causing a computer to perform any of the foregoing methods.
[0223] The above description is merely preferred embodiments of the present disclosure and a description of the principles of the technology applied. It should be understood by those skilled in the art that the disclosed scope of the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combinations of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with each other to form technical solutions with similar functions disclosed in the present disclosure (but not limited to).
Claims
1. A data caching method, characterized in that: include: receiving a first request from a data request source; In response to the first data requested by the first request not existing in the cache, sending a second request to a data storage source; receiving the first data and an access count of the first data from the data storage source; sending the first data to the data request source; In response to the number of accesses to the first data being greater than a first threshold, caching the first data; The method further comprises: In response to the first condition being met, generating a second request, setting a source parameter in the second request as a forwarding source to generate a cache data update request; Sending the cache data update request to the data storage source, wherein the cache data update request includes a data tag in the cache and a data access count, so that the data storage source obtains a counter value, and adds the counter value to the data access count to obtain the updated access count of the first data, wherein the data storage source is provided with a counter, the data access count is the number of times the data is read in the cache, and the counter value is the access count of the first data when the source parameter of the second request is the data request source; receiving, from the data storage source, first data corresponding to the data tag and an updated access count of the first data; In response to the access count of the updated first data being greater than a second threshold, the first data is used to update the data in the cache, wherein the second threshold is less than the first threshold.
2. The data caching method according to claim 1, wherein: The method further comprises: In response to the first data requested by the first request existing in the cache, the first data in the cache is sent to the data request source.
3. The data caching method according to claim 2, wherein: The method further comprises: The number of accesses to the first data in the cache is accumulated.
4. The data caching method according to claim 1, wherein: The method further comprises: In response to the number of accesses to the first data being less than a second threshold, the data in the cache is deleted.
5. The data caching method according to claim 1, wherein: The sending the second request to the data storage source includes: generating a second request, wherein a source parameter in the second request is the data request source; The second request is sent to the data storage source. The data caching method according to claim 1 , wherein the number of accesses to the first data is the number of times the first data is read per unit time.
7. A data sending method, characterized in that: include: receiving a second request from a data forwarding source; In response to the source parameter in the second request being a data request source, accumulating the number of accesses to the first data corresponding to the second request; sending the first data and the number of accesses to the first data to the data forwarding source, so that the data forwarding source caches the first data when determining that the number of accesses to the first data is greater than a first threshold; The method further comprises: In response to a source parameter of the second request being a data forwarding source, obtaining a number of accesses to data in the second request, where the number of accesses to the data is the number of times the data is read from the cache, wherein the source parameter of the second request is the data forwarding source and the second request is a cache data update request; Obtaining a counter value, and adding the counter value to the access count of the data to obtain an updated access count of the first data, wherein a counter is provided in the data storage source, and the counter value is the access count of the first data when the source parameter of the second request is the data request source; The access counts of the first data and the updated first data are sent to a data forwarding source, so that the data forwarding source uses the first data to update the data in the cache when determining that the access count of the updated first data is greater than a second threshold, wherein the second threshold is less than the first threshold.
8. A data cache device, characterized in that: include: A first receiving module, configured to receive a data request from a data request source; a request sending module, configured to send a second request to a data storage source in response to the first data requested by the first request not existing in the cache; a second receiving module, configured to receive the first data and the number of times the first data is accessed from the data storage source; a first sending module, configured to send the first data to the data request source; a data caching module, configured to cache the first data in response to a number of accesses to the first data being greater than a first threshold; Also includes: In response to satisfying the first condition, generating a second request, setting a source parameter in the second request as a forwarding source to generate a cache data update request; Sending the cache data update request to the data storage source, wherein the cache data update request includes a data tag in the cache and a data access count, so that the data storage source obtains a counter value, and adds the counter value to the data access count to obtain the updated access count of the first data, wherein the data storage source is provided with a counter, the data access count is the number of times the data is read in the cache, and the counter value is the access count of the first data when the source parameter of the second request is the data request source; receiving, from the data storage source, first data corresponding to the data tag and an updated access count of the first data; In response to the access count of the updated first data being greater than a second threshold, the data in the cache is updated using the first data, wherein the second threshold is less than the first threshold.
9. A data sending device, characterized in that: include: A second receiving module, configured to receive a data request; a second sending module, configured to send, in response to a source parameter in the data request being a data request source, first data corresponding to the data request and a number of accesses to the first data to a data forwarding source, so that the data forwarding source, upon determining that the number of accesses to the first data is greater than a first threshold, caches the first data; a first accumulation module, configured to accumulate the number of times the first data is accessed; Also includes: In response to a source parameter of the second request being a data forwarding source, obtaining a number of accesses to data in the second request, where the number of accesses to the data is the number of times the data is read from the cache, wherein the source parameter of the second request is the data forwarding source and the second request is a cache data update request; Obtaining a counter value, and adding the counter value to the access count of the data to obtain an updated access count of the first data, wherein a counter is provided in the data storage source, and the counter value is the access count of the first data when the source parameter of the second request is the data request source; The access counts of the first data and the updated first data are sent to a data forwarding source, so that the data forwarding source uses the first data to update the data in the cache when determining that the access count of the updated first data is greater than a second threshold, wherein the second threshold is less than the first threshold.
10. An electronic device comprising: a memory for storing computer-readable instructions; as well as A processor is configured to execute the computer-readable instructions, so that the processor implements the method according to any one of claims 1 to 7 when executed.
11. A non-transitory computer-readable storage medium for storing computer-readable instructions, which, when executed by a computer, causes the computer to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Hotspot access processing method, cache access proxy device and distributed cache system
CN108683695A
Dimension data processing method and device and data query method and device
CN110990372A