Data updating method and device, equipment, medium and product
By recording and accumulating the number of operations of the target string in the cache table, the database performance pressure caused by frequent operations is solved, and the database performance optimization is achieved.
Patent Information
- Application Number
- CN202410977691.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-11-22
AI Technical Summary
In the case of frequent operation of character strings, the prior art causes excessive pressure on database performance and leads to business bottlenecks.
Reduce the number of updates of the database by recording the number of operations of the target string in the cache table and adding it to the database if certain conditions are met.
It effectively reduces the performance pressure of the database, improves system performance, and avoids the problems of excessive CPU utilization and master-slave latency caused by frequent updates.
Smart Images

Figure CN119003542A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data updating method, device, equipment, medium and product. Background Art
[0002] In some business scenarios, the corresponding business goals can be achieved by operating some strings. For example, after binding string A to string B, string A can be used to replace string B. Here, binding string A to other strings can be understood as an operation on string A. Using string A to replace the bound string can be understood as a business goal.
[0003] For business control purposes, the number of operations on strings is usually recorded in the database. Currently, when string operations are frequent, it may bring huge performance pressure to the database, thus causing business bottlenecks.
[0004] Therefore, a method that can reduce database performance pressure is urgently needed. Summary of the invention
[0005] In view of this, the present disclosure provides a data updating method, a data updating device, an electronic device, a computer-readable storage medium, and a computer program product, which can reduce the performance pressure of a database.
[0006] In a first aspect, the present disclosure provides a data updating method, the method comprising:
[0007] In response to an operation on a target string, updating a first operation count of the target string recorded from a specified time in a cache table, wherein the specified time is the time when a second operation count of the target string recorded in a database was last updated;
[0008] When the database update condition is met, based on the first operation count of the target character string in the cache table, the second operation count of the target character string in the database is updated.
[0009] In a second aspect, the present disclosure provides a data updating device, the device comprising:
[0010] a cache update module, configured to update, in response to an operation on a target string, a first operation count of the target string recorded from a specified time in a cache table, wherein the specified time is a time when a second operation count of the target string recorded in a database was last updated;
[0011] The database updating module is used to update the second operation number of the target string in the database based on the first operation number of the target string in the cache table when the database update condition is met.
[0012] In a third aspect, the present disclosure provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the above method by executing the computer instructions.
[0013] In a fourth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the above method.
[0014] In a fifth aspect, the present disclosure provides a computer program product, including computer instructions, and the computer instructions are used to enable a computer to execute the above method.
[0015] In the technical solutions of some embodiments of the present application, the first operation number of the target string recorded from the specified time is recorded in the cache table, and when the database update condition is met, the second operation number of the target string in the database is updated based on the first operation number of the target string in the cache table. In this way, the database can be updated once only when the target string is operated multiple times, that is, it is not necessary to update the database every time an operation occurs on the target string. Since the number of database updates is reduced, the performance pressure of the database can be greatly reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 is a flowchart of a data updating method provided by some embodiments of the present application;
[0018] Figure 2 is a module schematic diagram of a data updating device provided by some embodiments of the present disclosure;
[0019] Figure 3 It is a schematic diagram of the structure of an electronic device provided by some embodiments of the present disclosure. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0021] Embodiments of the present disclosure will be described in more detail below 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 being limited to the embodiments set forth herein. On the contrary, 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 only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0022] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below.
[0023] Herein, unless explicitly stated, executing a step “in response to A” does not mean executing the step immediately after “A” but may include one or more intermediate steps.
[0024] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition, use, storage or deletion of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0025] It is understandable that before using the technical solutions disclosed in the various embodiments of the present disclosure, the types, scopes of use, usage scenarios, etc. of the information involved in the present disclosure should be informed to relevant users and their authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations. The relevant users may include any type of right holders, such as individuals, enterprises, and groups.
[0026] For example, in response to receiving an active request from a user, a prompt message is sent to the relevant user to clearly prompt the relevant user that the operation requested to be performed will require obtaining and using the information of the relevant user, so that the relevant user can independently choose whether to provide information to software or hardware such as an electronic device, application, server or storage medium that executes the operation of the technical solution of the present disclosure based on the prompt message.
[0027] As an optional but non-limiting implementation, in response to receiving an active request from a relevant user, a prompt message is sent to the relevant user, for example, in the form of a pop-up window, in which the prompt message may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to select "agree" or "disagree" to provide information to the electronic device.
[0028] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0029] In some technologies, multiple strings that are allowed to be operated are provided, and the number of operations on each string is stored in the database. For any string, the number of operations on the string can be updated in the database each time the string is operated. The problem with this solution is that when multiple strings are frequently operated, the frequency of updating the number of operations in the database is also high, which will cause the database's write QPS (Queries Per Second) and the number of updated rows to increase accordingly, which in turn leads to excessive CPU (Central Processing Unit) utilization and master-slave delay problems in the database, which brings greater performance pressure to the database and becomes a business bottleneck.
[0030] In view of this, the present application provides a data update method that can reduce the performance pressure of the database. The data update method can be applied to electronic devices. The electronic devices include but are not limited to tablet computers, laptop computers, desktop computers, servers, etc. Figure 1 , which is a flow chart of a data updating method provided in some embodiments of the present application. Figure 1 In the data updating method, the data updating method comprises the following steps:
[0031] Step S11, in response to an operation on a target string, updating a first operation count of the target string recorded from a specified time in a cache table, wherein the specified time is the time when a second operation count of the target string recorded in a database was last updated.
[0032] In this embodiment, the second operation count recorded in the database may be the total operation count of the target string, and the second operation count may be updated by time period. The second operation count of the target string may be updated by time period, which means that at a time point, the operation count for the target string that occurred in a time period before the time point is accumulated to the second operation count for the target string in the database. For example, at 3:50, the operation count for the target string that occurred between 3:00 and 3:50 is accumulated to the second operation count for the target string in the database, and at 4:15, the operation count for the target string that occurred between 3:50 and 4:15 is accumulated to the second operation count for the target string in the database.
[0033] Based on the above database update principle, it is not necessary to update the database after each operation on the target string. For example, assuming that after the database is updated at 3:50, the second operation times of the target string is 50, and the target string is operated 5 times between 3:50 and 4:15. Then, at 4:15, the 5 operation times between 3:50 and 4:15 can be added to the second operation times of the database, that is, at 4:15, the second operation times of the target string recorded in the database are updated from 50 to 55. In this way, from 3:50 to 4:15, the database can be updated only once, without 5 updates.
[0034] The first operation count recorded in the cache table refers to the number of operations on the target string within the target time period. The target time period refers to the time period starting from the specified time. For example, assuming the specified time is 4:15 (i.e., the last time the second operation count of the target string recorded in the database was updated was 4:15), then the starting point of the target time period is 4:15.
[0035] In the target time period, each time the target character string is operated once, the first operation number in the cache table can be updated. In this way, the operation number of the target character string in the target time period can be recorded through the cache table.
[0036] Step S12: When the database update condition is met, based on the first operation count of the target string in the cache table, update the second operation count of the target string in the database.
[0037] Specifically, the database update condition is used to limit the time when the second operation number of the target string in the database is updated. For example, the database update condition may include one or more preset time points (such as 12 o'clock, 18 o'clock, etc.). When these preset time points are reached, it means that the database update condition is met and the second operation number of the target string in the database needs to be updated.
[0038] The so-called updating of the second operation count of the target string in the database is to add the first operation count of the target string in the cache table to the second operation count of the target string in the database. In this way, after the second operation count of the target string recorded in the database is updated last time, the operation count for the target string in the target time period is added to the database, thereby ensuring the accuracy of the second operation count of the target string recorded in the database.
[0039] In summary, in the technical solutions of some embodiments of the present application, by recording the first operation number of the target string starting from the specified time in the cache table, and when the database update condition is met, the second operation number of the target string in the database is updated based on the first operation number of the target string in the cache table. In this way, the database can be updated once only when the target string is operated multiple times, that is, it is not necessary to update the database every time an operation occurs on the target string. Since the number of database updates is reduced, the performance pressure of the database can be greatly reduced.
[0040] In addition, compared to the database, the cache table is located in the cache and can have a higher data access speed. Therefore, even if the first operation count in the cache table is updated every time the target string is operated, it will not cause excessive performance pressure on the cache table. Of course, considering that the cache is not a permanent storage, when the database update conditions are met, the first operation count of the target string in the cache table is promptly accumulated to the database, which can effectively prevent problems such as data loss in the cache table when unexpected situations such as power failure occur.
[0041] For ease of understanding, the solution of the present application is further described below in conjunction with a business scenario in a specific embodiment. In the business scenario of this embodiment, the operation on the target string includes binding the target string with other strings outside the target string, and unbinding the target string from other strings outside the target string. When the target string is bound to other strings, the target string can be used to replace the bound string, that is, the target string can have the same function and effect as the bound string. For example, assuming that string A is the device identification of device A, after binding the target string to string A, the target string can be used as the device identification of device A. Of course, after unbinding the target string from the bound string, the target string can no longer be used to replace the unbound string.
[0042] Normally, when determining whether the target string can be bound to other strings, it is necessary to determine the number of strings that the target string is currently bound to. If the number of strings that the target string is currently bound to is too many, then the target string can no longer be bound to other strings; if the number of strings that the target string is currently bound to is too few, then the target string can continue to be bound to other strings. For example, if the target string is currently bound to string A, string B, and string C, it can be considered that the number of strings that the target string is currently bound to is too many. In this case, the target string can no longer be bound to string D. However, if the target string is currently not bound to other strings or the number of strings bound to it is small (for example, only one string is bound), it can be considered that the number of strings that the target string is currently bound to is too few, and the target string will continue to be bound to string D.
[0043] In order to meet the above business scenarios, it is necessary to record the number of bindings and unbindings of the target string, and determine the number of strings currently bound to the target string based on the recorded number of bindings and unbindings. In addition, in the above business scenarios, when judging whether the number of strings currently bound to the target string is too large, the time limit requirement can be lower. For example, the number of strings bound to the target string at 3:15 recorded in the database can be used as the basis for judging whether the target string can continue to bind other strings at 4 o'clock. Therefore, the number of operations on the target string can be recorded based on the data update method of the present application.
[0044] Specifically, based on the above business scenario, in step S11, in response to the operation on the target string, updating the first operation count of the target string recorded from the specified time in the cache table may include:
[0045] If the operation on the target string is to bind the target string with other strings other than the target string, then the value of the first operation count is increased;
[0046] If the operation on the target string is to unbind the target string from other strings other than the target string, the value of the first operation number is reduced.
[0047] Specifically, based on the relevant description of step S11, since the first operation number in the cache table is used to record the number of operations on the target string in the target time period, the first operation number of the target string can be set to an initial value of 0 at the starting time point in the target time period (i.e., the above-mentioned specified time), and in the target time period, each time a new string is bound to the target string, the value of the first operation number is increased by 1, and each time a string is unbound from the target string, the value of the first operation number is reduced by 1. After the value of the first operation number is increased or decreased in this way, if the value of the first operation number is a positive value, it means that a new string is bound to the target string in the target time period, and the larger the positive value, the more new strings are bound. On the contrary, if the value of the first operation number is a negative value, it means that in the target time period, at least part of the strings that have been bound to the target string are unbound, and the larger the negative value, the more strings are unbound. Of course, if the value of the first operation number is 0, there can be two situations. The first case is that within the target time period, no new string is bound to the target string, nor is a string unbound from the target string; the second case is that within the target time period, the number of new strings bound to the target string is equal to the number of strings unbound from the target string. In short, the value of the first operation count can represent the dynamic changes of the strings bound and unbound to the target string within the target time period.
[0048] The initial value of the second operation count of the target string in the database can still be 0. It is understandable that since the second operation count in the database is the total operation count of the target string, and there is no unbinding operation when there is no binding operation, therefore, when the database update condition is met, after the first operation count of the target string in the cache table is added to the second operation count of the target string in the database, the value of the second operation count in the database cannot be negative, and the value of the second operation count in the database is the number of strings currently bound to the target string. Based on the numerical value of the second operation count, it can be determined whether new strings can continue to be bound to the target string.
[0049] In the above embodiment, by increasing or decreasing the value of the first operation times, the dynamic changes of the strings bound and unbound to the target string within the target time period can be recorded simultaneously through one parameter, thereby reducing the number of parameters.
[0050] Of course, in some other embodiments, the first operation number in the cache table may include a binding number and an unbinding number, and the initial values of the binding number and the unbinding number may be 0. Within the target time period, each time a new string is bound to the target string, the value of the binding number may be increased by 1, and each time a string is unbound from the target string, the value of the unbinding number may be increased by 1. When the database update condition is met, the difference between the binding number and the unbinding number may be accumulated to the second operation number of the target string in the database.
[0051] Based on the above business scenario, in some embodiments, after the first operation number is updated in the cache table, if the absolute value of the first operation number is greater than a threshold, it can be determined that the database update condition is met.
[0052] Specifically, when the absolute value of the first operation number is greater than the threshold, it means that the number of strings unbound or bound to the target string is too large within the target time period, and it is necessary to timely update the second operation number in the database based on the first operation number to avoid the problem of a large difference between the second operation number and the actual number of strings bound to the target string.
[0053] Furthermore, in some embodiments, if the absolute value of the first operation count of the target string in the cache table has not reached the threshold for a long time, the second operation count of the target string in the database may not be updated for a long time, which may cause the second operation count in the database to be inconsistent with the number of strings actually bound to the target string for a long time. To avoid this situation, based on the above-mentioned threshold-based judgment of whether the data meets the database update condition, the method of the present application may also include:
[0054] Detect the time interval between the current time and the specified time;
[0055] If the time interval reaches the preset time length, it is determined that the database update condition is met.
[0056] The preset duration can be set according to actual conditions, such as 1 hour, 2 hours, etc. In this way, when the absolute value of the first operation number in the cache table does not reach the threshold, the second operation number in the database can also be updated in time to ensure the accuracy of the data in the database.
[0057] In some embodiments, after the second operation count of the target string in the database is updated, the method of the present application may further include:
[0058] Reset the first operation count of the target string in the cache table to the initial value.
[0059] Specifically, after the second operation count of the target string in the database is updated, it indicates that a new target time period has arrived. Therefore, the second operation count in the cache table needs to be reset to ensure that the number of strings bound and unbound to the target string can be recorded within the new target time period.
[0060] In some other embodiments, after the second operation count of the target character string in the database is updated, the method of the present application may further include:
[0061] Delete the target string and the first operation count of the target string.
[0062] Furthermore, in a case where the target string and the first number of operations on the target string are deleted from the cache table, in response to an operation on the target string occurring within a new target time period, if the target string does not exist in the cache table, the target string can be created in the cache table, and an initial value can be set for the first number of operations on the target string, and based on the initial value, the first number of operations on the target string can be updated.
[0063] In the above embodiment, after deleting the target string and the first number of operations on the target string, if no operation on the target string occurs in the new target time period, it is not necessary to store the target string and the first number of operations on the target string in the cache table, so that the amount of data in the cache table can be reduced and the storage performance of the cache table can be improved. However, if an operation on the target string occurs in the new target time period, the target string is created in the cache table and an initial value is set for the target string, so that the first number of operations on the target string can be recorded in a timely manner in the new target time period.
[0064] Further, it can be known from the above related description that after the second operation number is updated, the value of the first operation number will be reset to the initial value, or the target string and the first operation number of the target string will be deleted. If the operation for the target string occurs again when the second operation number is updated, the first operation number is immediately updated, then after the second operation number is updated, as the value of the first operation number is reset or deleted, the last update of the second operation number will be eliminated, and then the last update of the first operation number cannot be recorded. For example, when the value of the first operation number is 5, the absolute value of the first operation number is greater than the threshold value, and the second operation number will be updated based on the value of the first operation number 5. However, during the update process of the second operation number, if the binding operation for the target string occurs again, and the value of the first operation number is updated to 6, then as the update of the second operation number is completed, the value of the first operation number will be reset to 0 or deleted, which is equivalent to the update of the value of the first operation number from 5 to 6. The second operation number in the database cannot be synchronized to this update, thereby causing the problem of inaccurate data in the database.
[0065] In view of this, in some embodiments, when the second operation count of the target character string in the database is updated, the method of the present application may further include:
[0066] If an operation on the target character string occurs again before the update of the second operation number is completed, suspending the update operation of the first operation number on the target character string;
[0067] After the second operation number is updated, in response to another operation on the target character string, the first operation number of the target character string is updated.
[0068] Specifically, after the second operation times are updated and the value of the first operation times is reset to 0, the first operation times of the target string can be updated in response to the next operation on the target string based on the reset value 0. In this way, the problem of the last update not being synchronized can be avoided.
[0069] In the above description, one of the target strings among multiple strings is taken as an example to explain how to update the number of operations on the string. When there are multiple strings that are allowed to be operated, if these strings and the first number of operations on these strings are all stored in the same cache table, it may cause the problem of too much data in the cache table, thereby affecting the cache performance. In view of this, in some embodiments, the number of cache tables can be multiple, and each cache table is used to store a specified number of strings and the first number of operations on each string. In this way, the amount of data in each cache table is moderate, which is conducive to ensuring cache performance.
[0070] When there are multiple cache tables, in response to the operation on the target string, updating the first operation count of the target string recorded from the specified time in the cache table in step S11 may include:
[0071] Determine a target cache table for storing a target character string among multiple cache tables;
[0072] The first operation count for updating the target string in the target cache table.
[0073] Specifically, there may be a corresponding relationship between the character string and the cache table, and based on the corresponding relationship, a target cache table for storing the target character string may be determined.
[0074] Furthermore, the correspondence between the string and the cache table can be expressed in a variety of ways. For example, a mapping table between a string and a cache table is directly maintained, and based on the mapping table, the cache table corresponding to the target string can be found. However, in the case of a large number of strings, the amount of data in the mapping table will inevitably be large, which will increase storage consumption and will be more time-consuming when searching. In view of this, in some embodiments of the present application, the following solution is proposed.
[0075] Specifically, in these embodiments, each cache table has a table identifier. Determining a target cache table for storing a target string in the plurality of cache tables may include:
[0076] Perform hash calculation on the target string to obtain the hash calculation result of the target string;
[0077] In multiple cache tables, search for a cache table that uses a hash calculation result of the target string as a table identifier;
[0078] The found cache table is used as the target cache table.
[0079] In this way, there is no need to maintain the mapping table between the string and the cache table, which reduces storage consumption. In addition, the time consumed by hash calculation is less than the time consumed by searching the mapping table, which improves the efficiency of data update.
[0080] Corresponding to the data updating method, the present disclosure also provides a data updating device. Figure 2 , which is a module diagram of a data updating device provided in some embodiments of the present disclosure. Figure 2 In the data updating device, the data updating device comprises:
[0081] A cache update module, configured to update, in response to an operation on a target string, a first operation count of the target string recorded from a specified time in a cache table, wherein the specified time is a time when a second operation count of the target string recorded in a database was last updated;
[0082] The database update module is used to update the second operation number of the target string in the database based on the first operation number of the target string in the cache table when the database update condition is met.
[0083] In some embodiments, the cache update module is specifically used to:
[0084] If the operation on the target string is to bind the target string with other strings other than the target string, then the value of the first operation count is increased;
[0085] If the operation on the target string is to unbind the target string from other strings other than the target string, the value of the first operation number is reduced.
[0086] In some embodiments, the database update module is specifically used to:
[0087] After the first operation number is updated in the cache table, if the absolute value of the first operation number is greater than a threshold, it is determined that the database update condition is met.
[0088] In some embodiments, the database update module is specifically used to:
[0089] Detect the time interval between the current time and the specified time;
[0090] If the time interval reaches the preset time length, it is determined that the database update condition is met.
[0091] In some embodiments, after the second operation count of the target character string in the database is updated, the database updating module is further used to:
[0092] The target string and the first operation count of the target string are deleted from the cache table, or the first operation count of the target string is reset to an initial value.
[0093] In some embodiments, when the target string and the first operation number of the target string are deleted from the cache table, the database update module is specifically used to:
[0094] If the target string does not exist in the cache table, create the target string in the cache table and set an initial value for the first operation count of the target string;
[0095] Based on the initial value, the first operation count of the target character string is updated.
[0096] In some embodiments, there are multiple cache tables, each of which is used to store a specified number of character strings and the first operation times of each character string; the cache update module is specifically used to:
[0097] Determine a target cache table for storing a target character string among multiple cache tables;
[0098] The first operation count for updating the target string in the target cache table.
[0099] In some embodiments, each cache table has a table identifier; the cache update module is specifically used to:
[0100] Perform hash calculation on the target string to obtain the hash calculation result of the target string;
[0101] In multiple cache tables, search for a cache table that uses a hash calculation result of the target string as a table identifier;
[0102] The found cache table is used as the target cache table.
[0103] In some embodiments, when the second operation count of the target character string in the database is updated, the database updating module is specifically used to:
[0104] If an operation on the target character string occurs again before the update of the second operation number is completed, suspending the update operation of the first operation number on the target character string;
[0105] After the second operation number is updated, in response to another operation on the target character string, the first operation number of the target character string is updated.
[0106] The configuration device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0107] The data updating device disclosed in the present invention has the same beneficial effects as the above-mentioned data updating method, which will not be described in detail here.
[0108] The present disclosure also provides an electronic device having the above Figure 1 The data updating device shown.
[0109] Combined with reference Figure 3 , is a schematic diagram of the structure of an electronic device provided by some embodiments of the present disclosure. Figure 3As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 3 A processor 10 is taken as an example.
[0110] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0111] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0112] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0113] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0114] The electronic device further comprises a communication interface 30 for the electronic device to communicate with other devices or a communication network.
[0115] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0116] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0117] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A data updating method, characterized in that: The method comprises: In response to an operation on a target string, updating a first operation count of the target string recorded from a specified time in a cache table, wherein the specified time is the time when a second operation count of the target string recorded in a database was last updated; When the database update condition is met, based on the first operation count of the target character string in the cache table, the second operation count of the target character string in the database is updated.
2. The method according to claim 1, characterized in that: In response to the operation on the target string, updating the first operation count of the target string recorded from the specified time in the cache table includes: If the operation on the target string is to bind the target string with other strings other than the target string, then increase the value of the first operation count; If the operation on the target string is to unbind the target string from other strings other than the target string, the value of the first operation count is reduced.
3. The method according to claim 1, characterized in that The method further comprises: After the first operation number is updated in the cache table, if the absolute value of the first operation number is greater than a threshold, it is determined that the database update condition is met.
4. The method according to claim 1, characterized in that: The method further comprises: Detecting the time interval between the current time and the specified time; If the time interval reaches a preset time length, it is determined that the database update condition is met.
5. The method according to claim 1, characterized in that After updating the second operation count of the target character string in the database, the method further includes: The target character string and the first operation count of the target character string are deleted from the cache table, or the first operation count of the target character string is reset to an initial value.
6. The method according to claim 5, characterized in that In the case where the target character string and the first operation count of the target character string are deleted in the cache table, updating the first operation count of the target character string recorded from a specified time in the cache table includes: In response to an operation on the target string, if the target string does not exist in the cache table, creating the target string in the cache table and setting an initial value for the first operation count of the target string; The first operation count of the target character string is updated based on the initial value.
7. The method according to claim 1, characterized in that There are multiple cache tables, each of which is used to store a specified number of character strings and the first operation times of each character string; In response to the operation on the target string, updating the first operation count of the target string recorded from the specified time in the cache table includes: Determining a target cache table for storing the target character string among the plurality of cache tables; The first operation count of updating the target character string in the target cache table.
8. The method according to claim 7, characterized in that Each of the cache tables has a table identifier; Determining a target cache table for storing the target character string among the plurality of cache tables includes: Performing a hash calculation on the target string to obtain a hash calculation result of the target string; Searching for a cache table that uses a hash calculation result of the target string as a table identifier among the plurality of cache tables; The found cache table is used as the target cache table.
9. The method according to claim 1, characterized in that: When updating the second operation count of the target character string in the database, the method further includes: Before the update of the second operation number is completed, if an operation on the target character string occurs again, suspending the update operation of the first operation number on the target character string; After the update of the second operation number is completed, in response to another operation on the target character string, the first operation number of the target character string is updated.
10. A data updating device, characterized in that: The device comprises: a cache update module, configured to update, in response to an operation on a target string, a first operation count of the target string recorded from a specified time in a cache table, wherein the specified time is a time when a second operation count of the target string recorded in a database was last updated; The database updating module is used to update the second operation number of the target string in the database based on the first operation number of the target string in the cache table when the database update condition is met.
11. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the data updating method according to any one of claims 1 to 9 by executing the computer instructions.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the data updating method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the data updating method according to any one of claims 1 to 9.
