Data caching method, device and equipment and storage medium thereof
Patent Information
- Application Number
- CN202411020316.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2044-07-26
AI Technical Summary
[0004]本申请实施例的目的在于提出一种数据缓存方法、装置、设备及其存储介质,以解决现有技术在定时任务中使用str i ng类型保存点击完成时间的方式,占用内存较多,不利保存大量客户的点击完成数据到缓存中,存在服务器瞬时缓存压力过大,易造成宕机的问题
[0063] The data caching method described in the embodiment of this application extracts the timestamp field in the instantaneous high-concurrency cached data, performs binary conversion, segments and serializes the binary code, and replaces the original time. The stamp field facilitates subsequent caching of the time information in binary encoding form. Compared with String type time data storage, it greatly saves storage consumption and relieves the pressure on storage space. Applying the data caching method to the limited-time cumulative click activities of major financial platforms can lightly cache batches of time information, avoiding excessive instantaneous caching pressure on the server.
Smart Images

Figure CN118939696A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cache optimization technology, and is applied to time information cache scenarios, and in particular to a data cache method, device, equipment, and storage medium thereof. Background Art
[0002] At present, banks or local discount platforms sometimes design timed tasks to promote customer participation. For example, users need to complete clicks within a specific time period to proceed to the next activity. At this time, the user's click time needs to be recorded.
[0003] If there are many customers, and they log in to the platform at the same time to click, the system will enter a high concurrency state. At this time, every time a customer completes a task, the system will check whether the customer has completed the task in the current time by querying the database record. The system performance will be very poor, which is easy to cause blockage or database crash. At present, major systems will choose to use the String method to save customer numbers and click times. However, the use of the String type to save click completion time takes up a lot of memory, which is not conducive to saving a large number of customers' click completion data in the cache. There is a problem that the server instantaneous cache pressure is too large, which is easy to cause downtime. Summary of the invention
[0004] The purpose of the embodiments of the present application is to propose a data caching method, device, equipment and storage medium thereof, so as to solve the problem that the prior art uses the string type to save the click completion time in the scheduled task, which occupies a lot of memory and is not conducive to saving the click completion data of a large number of customers in the cache, and there is a problem that the server instantaneous cache pressure is too large, which is easy to cause downtime.
[0005] In order to solve the above technical problems, the embodiment of the present application provides a data caching method, which adopts the following technical solution:
[0006] A data caching method comprises the following steps:
[0007] Get batches of data to be cached;
[0008] According to a preset identification rule, identifying the timestamp field in the batch of data to be cached;
[0009] Convert the timestamp field into binary code using a preset conversion strategy;
[0010] Perform padding processing on the binary code, padding the binary code to N bits, and obtaining an N-bit binary code, wherein N is a positive integer and N%8 is 0, wherein N%8 represents a modulo operation of N on 8;
[0011] The N-bit binary code is segmented into a Byte type array;
[0012] Replacing the timestamp field with the Byte type array to obtain the replaced data to be cached;
[0013] The replaced data to be cached is cached in the target storage space.
[0014] Furthermore, the step of identifying the timestamp field in the batch of data to be cached according to a preset identification rule specifically includes:
[0015] The timestamp field contained in the batch of data to be cached is identified by a time characterization keyword identification method, wherein the time characterization keyword includes year, month, day, hour, minute, second, and / or
[0016] The timestamp field contained in the batch of data to be cached is identified through a time field display format, wherein the time field display format includes yyyy-MM-dd HH:mm:ss.
[0017] Furthermore, before executing the step of converting the timestamp field into binary code using a preset conversion strategy, the method further includes:
[0018] Time information is extracted from the timestamp field, and the extracted time information is converted into a numerical string in the format of yyyyMMddHHmmss.
[0019] Furthermore, the step of converting the timestamp field into binary code by using a preset conversion strategy specifically includes:
[0020] Get the last two digits of the year field as the first digit to be converted;
[0021] Get the month field number as the second number to be converted;
[0022] Get the day field number as the third number to be converted;
[0023] Get the hour field digit as the fourth digit to be converted;
[0024] Get the minute field digit as the fifth digit to be converted;
[0025] Get the second field digit as the sixth digit to be converted;
[0026] Respectively converting the first to-be-converted digit, the second to-be-converted digit, the third to-be-converted digit, the fourth to-be-converted digit, the fifth to-be-converted digit and the sixth to-be-converted digit into binary characters;
[0027] Performing padding processing on the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted, and the sixth digit to be converted, respectively;
[0028] Obtaining full-digit binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted, and the sixth digit to be converted, respectively;
[0029] The binary code is obtained by sequentially splicing the full-position binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted.
[0030] Furthermore, the step of completing the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted, respectively, specifically includes:
[0031] Determine whether the binary character corresponding to the first number to be converted is full of 8 bits;
[0032] Determine whether the binary character corresponding to the second number to be converted is full of 4 digits;
[0033] Determine whether the binary characters corresponding to the third digit to be converted and the fourth digit to be converted are full of 5 digits;
[0034] Determine whether the binary characters corresponding to the fifth digit to be converted and the sixth digit to be converted are full of 6 digits;
[0035] If any of the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively, does not meet the corresponding target number of digits, then the character 0 is filled in front of the corresponding binary character to fill the digits.
[0036] Furthermore, the step of padding the binary code to N bits to obtain an N-bit binary code specifically includes:
[0037] summing the digits of the full-digit binary characters respectively corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted, and the sixth digit to be converted to obtain a digit sum value;
[0038] Using the preset algorithm formula:
[0039] x=M%8,
[0040] Determine whether the sum of the digits is divisible by 8, wherein M represents the sum of the digits, and if x is 0, the sum of the digits is divisible by 8, otherwise, the sum of the digits is not divisible by 8;
[0041] If the sum of the digits is divisible by 8, an error message is sent to a preset monitoring terminal;
[0042] If the sum of the digits is not divisible by 8, y characters 0 are padded in front of the binary code to complete the digits, so as to obtain an N-digit binary code, wherein y=|8-x|, and N=M+y.
[0043] Furthermore, the step of segmenting the N-bit binary code into a Byte type array specifically includes:
[0044] The N-bit binary code is segmented according to a preset segmentation length to be segmented into Byte type arrays, wherein the preset segmentation length is 8 bits, and each Byte type array stores 8 bits of binary code;
[0045] After performing the step of replacing the timestamp field with the Byte type array to obtain the replaced data to be cached, the method further includes:
[0046] According to the order of the 8-bit binary code stored in each Byte type array in the N-bit binary code, all Byte type arrays are serialized and sorted to obtain a serialized Byte type array;
[0047] The step of replacing the timestamp field with the Byte type array to obtain the replaced data to be cached specifically includes:
[0048] The timestamp field is replaced with the serialized Byte type array to obtain the replaced data to be cached.
[0049] In order to solve the above technical problems, the embodiment of the present application also provides a data cache device, which adopts the following technical solution:
[0050] A data caching device, comprising:
[0051] A module for acquiring data to be cached, used to acquire batches of data to be cached;
[0052] A timestamp field identification module, used to identify the timestamp field in the batch of data to be cached according to a preset identification rule;
[0053] A binary code conversion module, used to convert the timestamp field into a binary code using a preset conversion strategy;
[0054] A binary code padding module, used for padding the binary code to N bits to obtain an N-bit binary code, wherein N is a positive integer and N%8 is 0, wherein N%8 represents a modulo operation of N on 8;
[0055] A binary code segmentation module is used to segment the N-bit binary code into a Byte type array;
[0056] A module for replacing data to be cached, used for replacing the timestamp field with the Byte type array to obtain the data to be cached after the replacement is completed;
[0057] The cache execution module is used to cache the replaced data to be cached into the target storage space.
[0058] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0059] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the above-mentioned data caching method when executing the computer-readable instructions.
[0060] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0061] A computer-readable storage medium stores computer-readable instructions, which implement the steps of the data caching method described above when executed by a processor.
[0062] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0063] The data caching method described in the embodiment of the present application extracts the timestamp field in the instantaneous high-concurrency cache data, performs binary conversion, performs segmentation processing and serialization on the binary code, and replaces the original timestamp field, so as to facilitate the subsequent caching of the time information in the form of binary code. Compared with the Stri ng type time data storage, it greatly saves storage consumption and relieves the pressure of storage space. The data caching method is applied to the time-limited cumulative click activities of major financial platforms, which can lightly cache batches of time information and avoid excessive pressure on the server instantaneous cache. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0065] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0066] Figure 2 is a flow chart of an embodiment of a data caching method according to the present application;
[0067] Figure 3 yes Figure 2 A flowchart of a specific embodiment of step 203 is shown;
[0068] Figure 4 yes Figure 3 A flowchart of a specific embodiment of step 308 is shown;
[0069] Figure 5 yes Figure 2 A flowchart of a specific embodiment of step 204 is shown;
[0070] Figure 6 is a structural diagram of an embodiment of a data cache device according to the present application;
[0071] Figure 7 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0072] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0073] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0074] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0075] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0076] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0077] The terminal devices 101, 102, and 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.
[0078] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0079] It should be noted that the data caching method provided in the embodiment of the present application is generally executed by a terminal device, and accordingly, the data caching device is generally arranged in the terminal device.
[0080] It should be understood that Figure 1The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0081] Continue to refer Figure 2 , shows a flow chart of an embodiment of a data caching method according to the present application. The data caching method comprises the following steps:
[0082] Step 201, obtaining batches of data to be cached.
[0083] In this embodiment, the batch of data to be cached includes user click data of various promotion platforms. Specifically, the user click data has the characteristic of instantaneous high concurrency. If all user click data are directly added to the cache space, it will cause excessive instantaneous storage pressure and easily cause server downtime. The data caching method described in this application can reduce the instantaneous cache pressure.
[0084] Step 202: Identify the timestamp field in the batch of data to be cached according to a preset identification rule.
[0085] In this embodiment, the step of identifying the timestamp field in the batch of data to be cached according to a preset identification rule specifically includes: identifying the timestamp field contained in the batch of data to be cached by using a time characterization keyword identification method, wherein the time characterization keyword includes year, month, day, hour, minute, and second, and / or identifying the timestamp field contained in the batch of data to be cached by using a time field display format, wherein the time field display format includes yyyy-MM-dd HH:mm:ss.
[0086] Specifically, the time representation keyword also includes an English keyword corresponding to the Chinese character keyword, and the time field display format also includes a time display format defined by a user.
[0087] By identifying the timestamp field in the batch of data to be cached, the batch of time data can be converted and processed to reduce the cache pressure of the server.
[0088] Step 203: convert the timestamp field into binary code using a preset conversion strategy.
[0089] In this embodiment, before executing the step of converting the timestamp field into binary code using a preset conversion strategy, the method further includes: extracting time information from the timestamp field, and converting the extracted time information into a numerical string in the format of yyyyMMddHHmmss.
[0090] By extracting the time information in the timestamp field and converting it into pure numerical values, subsequent binary conversion is facilitated.
[0091] Continue to refer Figure 3 , Figure 3 yes Figure 2 The flowchart of a specific embodiment of step 203 shown includes:
[0092] Step 301, obtaining the last two digits corresponding to the year field as the first digit to be converted;
[0093] Step 302, obtaining the month field number as the second number to be converted;
[0094] Step 303, obtaining the day field digit as the third digit to be converted;
[0095] Step 304, obtaining the hour field digit as the fourth digit to be converted;
[0096] Step 305, obtaining the minute field digit as the fifth digit to be converted;
[0097] Step 306, obtaining the second field digit as the sixth digit to be converted;
[0098] Step 307, converting the first to-be-converted number, the second to-be-converted number, the third to-be-converted number, the fourth to-be-converted number, the fifth to-be-converted number and the sixth to-be-converted number into binary characters respectively;
[0099] Step 308, performing padding processing on the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively;
[0100] Continue to refer Figure 4 , Figure 4 yes Figure 3 The flowchart of a specific embodiment of step 308 shown includes:
[0101] Step 401, determining whether the binary character corresponding to the first number to be converted is full of 8 bits;
[0102] Since the first digits to be converted, i.e. the last two digits of the year, are between 00 and 99, an 8-bit binary character can meet the conversion requirement.
[0103] Step 402, determining whether the binary character corresponding to the second number to be converted is full of 4 digits;
[0104] Since the second number to be converted, ie, the month information, includes a positive integer from 1 to 12, a 4-bit binary character can meet the conversion requirement.
[0105] Step 403, determining whether the binary characters corresponding to the third digit to be converted and the fourth digit to be converted are full of 5 digits;
[0106] Since the third number to be converted, i.e., date information, includes a positive integer from 1 to 31, and the fourth number to be converted, i.e., hour information, includes a positive integer from 0 to 23, a 5-bit binary character can meet the conversion requirements.
[0107] Step 404, determining whether the binary characters corresponding to the fifth digit to be converted and the sixth digit to be converted are full of 6 digits;
[0108] Since the fifth digit to be converted and the sixth digit to be converted, ie, the minute and second information, include positive integers from 0 to 59, a 6-bit binary character can meet the conversion requirement.
[0109] Step 405, if any binary character corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively does not meet the corresponding target number of digits, then fill the corresponding binary character with the character 0 to complete the number of digits.
[0110] In this embodiment, if any of the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively do not meet the corresponding target number of bits, then the character 0 is padded in front of the corresponding binary character to make up the number of bits. For example, if the binary character corresponding to the first digit to be converted is less than 8 bits, the character 0 is padded in front to make it up to 8 bits. The purpose is to make the number of bits corresponding to the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively clear before the binary code is padded to N bits, so as to facilitate the subsequent time restoration.
[0111] Of course, if the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively meet the corresponding target number of digits, step 309 is executed.
[0112] During specific execution, since the second number to be converted, i.e., the month information, contains a positive integer from 1 to 12, the third number to be converted, i.e., the date information, contains a positive integer from 1 to 31, the fourth number to be converted, i.e., the hour information, contains a positive integer from 0 to 23, the fifth number to be converted and the sixth number to be converted, i.e., the minute and second information, contain positive integers from 0 to 59, with a very high probability, the situation described in step 405 exists and padding processing is required, and padding processing is not performed only with a very small probability.
[0113] Step 309, obtaining the full-digit binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively;
[0114] Step 310, sequentially concatenate the full-position binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted, respectively, to obtain the binary code.
[0115] In this embodiment, the binary code conversion step provided is when the time information is complete in terms of year, month, day, hour, minute, and second. Of course, it does not exclude the mode in which the time information only contains one or a combination of year, month, day, hour, minute, and second. At this time, it is only necessary to obtain the target number to be converted according to the corresponding time information and perform the corresponding binary character conversion. By extracting the time information in the timestamp field, performing a pure numerical conversion, and then performing a binary conversion, it is convenient to cache the time information in a binary coding form in the subsequent process. Compared with the storage of String type time data, it greatly saves storage consumption and relieves the pressure of storage space.
[0116] Step 204, padding the binary code to N bits to obtain an N-bit binary code, wherein N is a positive integer and N%8 is 0, wherein N%8 represents a modulo operation of N to 8.
[0117] Continue to refer Figure 5 , Figure 5 yes Figure 2 The flowchart of a specific embodiment of step 204 shown includes:
[0118] Step 501, summing the digits of the full-digit binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted, to obtain a digit sum value;
[0119] Step 502, using a preset algorithm formula:
[0120] x=M%8,
[0121] Determine whether the sum of the digits is divisible by 8, wherein M represents the sum of the digits, and if x is 0, the sum of the digits is divisible by 8, otherwise, the sum of the digits is not divisible by 8;
[0122] Step 503, if the sum of the digits is divisible by 8, an error message is sent to a preset monitoring terminal;
[0123] Step 504: If the bit sum value is not divisible by 8, y characters 0 are added to the front of the binary code to complete the bit number, so as to obtain an N-bit binary code, where y=|8-x| and N=M+y.
[0124] Specifically, in the present embodiment, the time information is complete in terms of year, month, day, hour, minute, and second. Therefore, if the sum of the digits is divisible by 8, an error message is sent to the preset monitoring terminal. Of course, it is not excluded that the time information is not complete in terms of year, month, day, hour, minute, and second. For example, it only contains the year, or only contains the date, hour, and minute information. At this time, if the sum of the digits is divisible by 8, there is no need to send an error message, and step 205 is directly executed, depending on the actual time information extraction situation.
[0125] Step 205, segmenting the N-bit binary code into Byte type arrays.
[0126] In this embodiment, the step of segmenting the N-bit binary code into a Byte type array specifically includes: segmenting the N-bit binary code according to a preset segmentation length into a Byte type array, wherein the preset segmentation length is 8 bits, and each Byte type array stores 8 bits of binary code.
[0127] According to the time information given above, when the year, month, day, hour, minute and second are complete, it is obvious that the M value is 8+4+5+5+6+6=34, the x value is 2, the y value is 6, and the N value is 40, that is, the 40-bit binary code is divided into 8-bit lengths, and 5 Byte type arrays are obtained, that is, 5 8-bit binary codes composed of 0 and 1 are obtained. 1 Byte type array corresponds to the size of one byte in storage. Therefore, after the timestamp field is binary encoded, padded and split, the time information can be stored in 5 bytes. Compared with the Stri ng type data storing time information, a lot of storage space is saved and the storage pressure is reduced.
[0128] In actual use, step 205 may be executed first and then step 204. The difference is that if step 205 is executed first, the binary code obtained in step 203 is not padded first, that is, the binary code obtained in step 203 is directly segmented and divided into a Byte type array. At this time, the segmentation follows the segmentation from the tail of the binary code, and then the coding segment of the binary code head that is less than 8 bits is padded with 0.
[0129] Step 206: Replace the timestamp field with the Byte type array to obtain the replaced data to be cached.
[0130] In this embodiment, after performing the step of replacing the timestamp field with the Byte type array to obtain the replaced data to be cached, the method further includes: serializing and arranging all Byte type arrays according to the order of the 8-bit binary code stored in each Byte type array in the N-bit binary code to obtain a serialized Byte type array;
[0131] By serializing and organizing all Byte type arrays obtained after the segmentation process, it is convenient for subsequent serialized storage, so that the time information can be quickly restored when it is called later, avoiding the inability to restore the timestamp field.
[0132] In this embodiment, the step of replacing the timestamp field with the Byte type array to obtain the replaced data to be cached specifically includes: replacing the timestamp field with the serialized Byte type array to obtain the replaced data to be cached.
[0133] Similarly, the timestamp field is replaced with the serialized Byte type array to obtain the replaced data to be cached, which is convenient for subsequent serialized storage, so that the time information can be quickly restored when it is called later, avoiding the inability to restore the timestamp field.
[0134] Step 207: Cache the replaced data to be cached into the target storage space.
[0135] By extracting the time information in the timestamp field, converting it to pure numerical value, and then converting it to binary, segmenting and serializing the binary code, and replacing the original timestamp field, it is convenient to cache the time information in the form of binary code in the future. Compared with the storage of string type time data, it greatly saves storage consumption and relieves the pressure of storage space. The data caching method is applied to the time-limited cumulative click activities of major financial platforms, which can lightly cache the recorded time information and avoid excessive pressure on the server instantaneous cache.
[0136] This application extracts the timestamp field in the instantaneous high-concurrency cache data, performs binary conversion, performs segmentation and serialization on the binary code, and replaces the original timestamp field, so as to facilitate the subsequent caching of the time information in the form of binary code. Compared with the Stri ng type time data storage, it greatly saves storage consumption and relieves the pressure of storage space. The data caching method is applied to the time-limited cumulative click activities of major financial platforms, which can lightly cache batches of time information and avoid excessive pressure on the server instantaneous cache.
[0137] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0138] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0139] In the embodiment of the present application, by extracting the timestamp field in the instantaneous high-concurrency cache data, and then performing binary conversion, segmenting and serializing the binary code, and replacing the original timestamp field, it is convenient to cache the time information in the form of binary code in the future. Compared with the Stri ng type time data storage, it greatly saves storage consumption and relieves the pressure of storage space. The data caching method is applied to the time-limited cumulative click activities of major financial platforms, which can lightly cache batches of time information and avoid excessive pressure on the server instantaneous cache.
[0140] Further references Figure 6 , as a response to the above Figure 2 In order to realize the method shown in the figure, the present application provides an embodiment of a data cache device, and the device embodiment is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0141] like Figure 6As shown, the data cache device 600 described in this embodiment includes: a to-be-cached data acquisition module 601, a timestamp field identification module 602, a binary code conversion module 603, a binary code completion module 604, a binary code segmentation module 605, a to-be-cached data replacement module 606 and a cache execution module 607. Among them:
[0142] The to-be-cached data acquisition module 601 is used to acquire batches of to-be-cached data;
[0143] A timestamp field identification module 602, used to identify the timestamp field in the batch of data to be cached according to a preset identification rule;
[0144] A binary code conversion module 603, used to convert the timestamp field into a binary code using a preset conversion strategy;
[0145] A binary code padding module 604 is used to pad the binary code to N bits to obtain an N-bit binary code, where N is a positive integer and N%8 is 0, where N%8 represents a modulo operation of N on 8;
[0146] The binary code segmentation module 605 is used to segment the N-bit binary code into a Byte type array;
[0147] The to-be-cached data replacement module 606 is used to replace the timestamp field with the Byte type array to obtain the to-be-cached data after replacement;
[0148] The cache execution module 607 is used to cache the replaced data to be cached into the target storage space.
[0149] The data caching device proposed in this application belongs to the field of cache optimization technology and is applied to the time information caching scenario. By extracting the timestamp field in the instantaneous high-concurrency cache data, and then performing binary conversion, segmenting and serializing the binary code, and replacing the original timestamp field, it is convenient to cache the time information in the form of binary code in the future. Compared with the storage of Stri ng type time data, it greatly saves storage consumption and relieves the pressure of storage space. The data caching method is applied to the time-limited cumulative click activities of major financial platforms, which can lightly cache batches of time information and avoid excessive pressure on the server instantaneous cache.
[0150] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0151] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0152] To solve the above technical problems, the present application also provides a computer device. Figure 7 , Figure 7 This is a basic structural block diagram of the computer device in this embodiment.
[0153] The computer device 7 includes a memory 7a, a processor 7b, and a network interface 7c that are interconnected through a system bus. It should be noted that the figure only shows a computer device 7 having components 7a-7c, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital processor (DSP), an embedded device, etc.
[0154] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0155] The memory 7a includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 7a can be an internal storage unit of the computer device 7, such as a hard disk or memory of the computer device 7. In other embodiments, the memory 7a can also be an external storage device of the computer device 7, such as a plug-in hard disk equipped on the computer device 7, a smart memory card (Smart Med ia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 7a can also include both the internal storage unit of the computer device 7 and its external storage device. In this embodiment, the memory 7a is generally used to store the operating system and various application software installed on the computer device 7, such as a computer-readable instruction of a data caching method, etc. In addition, the memory 7a can also be used to temporarily store various types of data that have been output or are to be output.
[0156] The processor 7b may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 7b is generally used to control the overall operation of the computer device 7. In this embodiment, the processor 7b is used to run the computer-readable instructions stored in the memory 7a or process data, such as computer-readable instructions for running the data caching method.
[0157] The network interface 7c may include a wireless network interface or a wired network interface. The network interface 7c is generally used to establish a communication connection between the computer device 7 and other electronic devices.
[0158] The computer device proposed in this embodiment belongs to the field of cache optimization technology and is applied to time information caching scenarios. This application extracts the timestamp field in the instantaneous high-concurrency cache data, performs binary conversion, performs segmentation processing and serialization on the binary code, and replaces the original timestamp field, so as to facilitate the subsequent caching of the time information in the form of binary code. Compared with the storage of Stri ng type time data, it greatly saves storage consumption and alleviates the pressure of storage space. The data caching method is applied to the limited-time cumulative click activities of major financial platforms, which can lightly cache batches of time information and avoid excessive pressure on the server instantaneous cache.
[0159] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by a processor to enable the processor to perform the steps of the data caching method as described above.
[0160] The computer-readable storage medium proposed in this embodiment belongs to the field of cache optimization technology and is applied to time information caching scenarios. This application extracts the timestamp field in the instantaneous high-concurrency cache data, performs binary conversion, performs segmentation processing and serialization on the binary code, and replaces the original timestamp field, so as to facilitate the subsequent caching of the time information in the form of binary code. Compared with the storage of Stri ng type time data, it greatly saves storage consumption and alleviates the pressure of storage space. The data caching method is applied to the limited-time cumulative click activities of major financial platforms, which can lightly cache batches of time information and avoid excessive pressure on the server instantaneous cache.
[0161] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0162] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A data caching method, characterized in that: The steps include: Get batches of data to be cached; According to a preset identification rule, identifying the timestamp field in the batch of data to be cached; Convert the timestamp field into binary code using a preset conversion strategy; Perform padding processing on the binary code, padding the binary code to N bits, and obtaining an N-bit binary code, wherein N is a positive integer and N%8 is 0, wherein N%8 represents a modulo operation of N on 8; The N-bit binary code is segmented into a Byte type array; Replacing the timestamp field with the Byte type array to obtain the replaced data to be cached; The replaced data to be cached is cached in the target storage space.
2. The data caching method according to claim 1, characterized in that: The step of identifying the timestamp field in the batch of data to be cached according to a preset identification rule specifically includes: The timestamp field contained in the batch of data to be cached is identified by a time characterization keyword identification method, wherein the time characterization keyword includes year, month, day, hour, minute, second, and / or The timestamp field contained in the batch of data to be cached is identified through a time field display format, wherein the time field display format includes yyyy-MM-dd HH:mm:ss.
3. The data caching method according to claim 1, characterized in that: Before executing the step of converting the timestamp field into binary code using a preset conversion strategy, the method further includes: Time information is extracted from the timestamp field, and the extracted time information is converted into a numerical string in the format of yyyyMMddHHmmss.
4. The data caching method according to claim 1, characterized in that: The step of converting the timestamp field into binary code by using a preset conversion strategy specifically includes: Get the last two digits of the year field as the first digit to be converted; Get the month field number as the second number to be converted; Get the day field number as the third number to be converted; Get the hour field digit as the fourth digit to be converted; Get the minute field digit as the fifth digit to be converted; Get the second field digit as the sixth digit to be converted; Respectively converting the first to-be-converted digit, the second to-be-converted digit, the third to-be-converted digit, the fourth to-be-converted digit, the fifth to-be-converted digit and the sixth to-be-converted digit into binary characters; Performing padding processing on the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted, and the sixth digit to be converted, respectively; Obtaining full-digit binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted, and the sixth digit to be converted, respectively; The binary code is obtained by sequentially splicing the full-position binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted.
5. The data caching method according to claim 4, characterized in that: The step of completing the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively comprises: Determine whether the binary character corresponding to the first number to be converted is full of 8 bits; Determine whether the binary character corresponding to the second number to be converted is full of 4 digits; Determine whether the binary characters corresponding to the third digit to be converted and the fourth digit to be converted are full of 5 digits; Determine whether the binary characters corresponding to the fifth digit to be converted and the sixth digit to be converted are full of 6 digits; If any of the binary characters corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted and the sixth digit to be converted respectively, does not meet the corresponding target number of digits, then the character 0 is filled in front of the corresponding binary character to fill the digits.
6. The data caching method according to claim 4, characterized in that: The step of padding the binary code to N bits to obtain an N-bit binary code specifically includes: summing the digits of the full-digit binary characters respectively corresponding to the first digit to be converted, the second digit to be converted, the third digit to be converted, the fourth digit to be converted, the fifth digit to be converted, and the sixth digit to be converted to obtain a digit sum value; Using the preset algorithm formula: x=M%8, Determine whether the sum of the digits is divisible by 8, wherein M represents the sum of the digits, and if x is 0, the sum of the digits is divisible by 8, otherwise, the sum of the digits is not divisible by 8; If the sum of the digits is divisible by 8, an error message is sent to a preset monitoring terminal; If the sum of the digits is not divisible by 8, y characters 0 are padded in front of the binary code to complete the digits, so as to obtain an N-digit binary code, wherein y=|8-x|, and N=M+y.
7. The data caching method according to claim 1 or 6, characterized in that: The step of segmenting the N-bit binary code into a Byte type array specifically includes: The N-bit binary code is segmented according to a preset segmentation length to be segmented into Byte type arrays, wherein the preset segmentation length is 8 bits, and each Byte type array stores 8 bits of binary code; After performing the step of replacing the timestamp field with the Byte type array to obtain the replaced data to be cached, the method further includes: According to the order of the 8-bit binary code stored in each Byte type array in the N-bit binary code, all Byte type arrays are serialized and sorted to obtain a serialized Byte type array; The step of replacing the timestamp field with the Byte type array to obtain the replaced data to be cached specifically includes: The timestamp field is replaced with the serialized Byte type array to obtain the replaced data to be cached.
8. A data cache device, characterized in that: include: A module for acquiring data to be cached, used to acquire batches of data to be cached; A timestamp field identification module, used to identify the timestamp field in the batch of data to be cached according to a preset identification rule; A binary code conversion module, used to convert the timestamp field into a binary code using a preset conversion strategy; A binary code padding module, used for padding the binary code to N bits to obtain an N-bit binary code, wherein N is a positive integer and N%8 is 0, wherein N%8 represents a modulo operation of N on 8; A binary code segmentation module is used to segment the N-bit binary code into a Byte type array; A module for replacing data to be cached, used for replacing the timestamp field with the Byte type array to obtain the data to be cached after the replacement is completed; The cache execution module is used to cache the replaced data to be cached into the target storage space.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the data caching method according to any one of claims 1 to 7 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the data caching method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Device and method for data persistent storage on basis of cache
CN106682193A
Sequence generation method and device, computer equipment and storage medium
CN110222048A
Large-scale monitoring data storage method and system and wearable device
CN112667628A
Simple encoding and decoding method suitable for time sequence database
CN113078908A
