A data caching method, device, equipment and storage medium thereof
By converting the timestamp field to binary encoding and splitting it into a byte array, the problem of excessive memory usage when storing click completion time as a string is solved, achieving efficient data caching and preventing server downtime.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PING AN BANK CO LTD
- Filing Date
- 2024-07-26
- Publication Date
- 2026-06-23
AI Technical Summary
Existing technologies that use string type to store click completion time in scheduled tasks consume a lot of memory and are not conducive to saving a large amount of customer click completion data to the cache, resulting in excessive instantaneous cache pressure on the server and easily causing downtime.
By acquiring a batch of data to be cached, identifying the timestamp field, converting it to binary encoding and padding it to N bits, dividing it into a Byte type array, and replacing the original timestamp field for caching.
It greatly saves storage consumption, alleviates storage space pressure, avoids excessive instantaneous cache pressure on the server, and ensures system stability.
Smart Images

Figure CN118939696B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cache optimization technology, and is applied to time information caching scenarios. In particular, it relates to a data caching method, apparatus, device and its storage medium. Background Technology
[0002] Currently, banks or local promotional platforms sometimes design timed tasks to encourage customer participation. For example, users need to click within a specific time period to proceed to the next step of the activity. In this case, it is necessary to record the user's click time.
[0003] If there are many customers logging into the platform and clicking simultaneously, the system will enter a high-concurrency state. In this case, each time a customer completes a task, the system checks the database to see if the customer has already completed the task within that time period. This results in poor system performance and can easily cause congestion or database crashes. Currently, many systems use strings to store customer IDs and click times. However, using strings to store click completion times consumes a lot of memory, making it difficult to store large amounts of customer click completion data in the cache. This can lead to excessive instantaneous cache pressure on the server, potentially causing downtime. Summary of the Invention
[0004] The purpose of this application is to propose a data caching method, apparatus, device and storage medium to solve the problem that the existing technology uses string type to save the click completion time in timed tasks, which occupies a lot of memory, is not conducive to saving a large number of customers' click completion data into the cache, and has the problem of excessive instantaneous cache pressure on the server, which can easily cause downtime.
[0005] To address the aforementioned technical problems, this application provides a data caching method, employing the following technical solution:
[0006] A data caching method includes the following steps:
[0007] Retrieve batch of data to be cached;
[0008] According to the preset recognition rules, the timestamp field in the batch of data to be cached is identified;
[0009] The timestamp field is converted into binary code using a preset conversion strategy;
[0010] The binary code is padded 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 N modulo 8.
[0011] The N-bit binary code is segmented into a Byte array;
[0012] Replace the timestamp field with the Byte type array to obtain the replaced data to be cached;
[0013] The replaced data 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 using a time-representation keyword identification method. The time-representation keywords include year, month, day, hour, minute, second, and / or...
[0016] The timestamp field in the batch of data to be cached is identified by the display format of the time field, wherein the display format of the time field includes yyyy-MM-dd HH:mm:ss.
[0017] Furthermore, before performing the step of converting the timestamp field to binary encoding using a preset conversion strategy, the method further includes:
[0018] The timestamp field is used to extract time information, and the extracted time information is converted into a numeric string in yyyyMMddHHmmss format.
[0019] Furthermore, the step of converting the timestamp field into binary encoding using a preset conversion strategy specifically includes:
[0020] Extract the last two digits of the year field as the first number to be converted;
[0021] Get the month field number as the second number to be converted;
[0022] Retrieve the date field number as the third number to be converted;
[0023] Retrieve the hour field number as the fourth number to be converted;
[0024] Retrieve the minute field number as the fifth number to be converted;
[0025] Retrieve the second field number as the sixth number to be converted;
[0026] The first, second, third, fourth, fifth, and sixth numbers to be converted are respectively converted into binary characters;
[0027] The binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted are padded.
[0028] Obtain the full-position binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted;
[0029] The binary code is obtained by sequentially concatenating the full-position binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted.
[0030] Furthermore, the step of padding the binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted specifically includes:
[0031] Determine whether the binary character corresponding to the first number to be converted is 8 bits or more;
[0032] Determine whether the binary character corresponding to the second number to be converted is at least 4 bits.
[0033] Determine whether the binary characters corresponding to the third and fourth numbers to be converted are each 5 bits long;
[0034] Determine whether the binary characters corresponding to the fifth and sixth numbers to be converted are 6 bits or more.
[0035] If any binary character in the binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted does not meet the target number of bits, then the corresponding binary character is padded with 0 characters to complete the number of bits.
[0036] Furthermore, the step of padding the binary code to N bits to obtain an N-bit binary code specifically includes:
[0037] For the full-bit binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted, the number of bits is summed to obtain the sum of the number of bits.
[0038] The preset algorithm formula is used:
[0039] ,
[0040] Determine whether the sum of the number of digits is divisible by 8, where M represents the sum of the number of digits. If the sum of the digits is 0, then the sum of the digits is divisible by 8; otherwise, the sum of the digits is not divisible by 8.
[0041] If the number of bits and the value are divisible by 8, an error message is sent to the preset monitoring terminal.
[0042] If the number of bits and the value are not divisible by 8, then pad the binary code with y zero characters to obtain an N-bit binary code. , .
[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 into Byte type arrays, wherein the preset segmentation length is 8 bits, and each Byte type array stores 8 bits of binary code.
[0045] Before 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] Serialize all Byte type arrays according to the order in which the 8-bit binary code is stored in each Byte type array within the N-bit binary code, 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] Replace the timestamp field with the serialized Byte type array to obtain the replaced data to be cached.
[0049] To address the aforementioned technical problems, embodiments of this application also provide a data caching device, employing the following technical solution:
[0050] A data caching device, comprising:
[0051] The module for retrieving cached data is used to retrieve batches of cached data.
[0052] The timestamp field recognition module is used to recognize the timestamp field in the batch of data to be cached according to preset recognition rules;
[0053] A binary encoding conversion module is used to convert the timestamp field into binary encoding using a preset conversion strategy;
[0054] The binary code padding module 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 N modulo 8.
[0055] The binary encoding segmentation module is used to segment the N-bit binary encoding into a Byte type array;
[0056] The cached data replacement module is used to replace the timestamp field with the Byte type array to obtain the replaced cached data;
[0057] The cache execution module is used to cache the replaced data to the target storage space.
[0058] To address the aforementioned technical problems, this application also provides a computer device that employs the following technical solution:
[0059] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the data caching method described above.
[0060] To address the aforementioned technical problems, this application also provides a computer-readable storage medium, employing the technical solution described below:
[0061] A computer-readable storage medium storing computer-readable instructions that, when executed by a processor, implement the steps of the data caching method described above.
[0062] Compared with the prior art, the embodiments of this application have the following main advantages:
[0063] The data caching method described in this application extracts the timestamp field from the instantaneous high-concurrency cached data, performs binary conversion, segments and serializes the binary encoding, and replaces the original timestamp field. This facilitates subsequent caching of the time information in binary encoding form, significantly reducing storage consumption and alleviating storage space pressure compared to storing time data in String type. Applying this data caching method to time-limited cumulative click activities on various financial platforms enables lightweight caching of batches of time information, avoiding excessive instantaneous caching pressure on the server. Attached Figure Description
[0064] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0065] Figure 1 This is an exemplary system architecture diagram to which this application can be applied;
[0066] Figure 2 This is a flowchart of an embodiment of the data caching method according to this application;
[0067] Figure 3 yes Figure 2 A flowchart of a specific embodiment of step 203 shown;
[0068] Figure 4 yes Figure 3 A flowchart of a specific embodiment of step 308 shown;
[0069] Figure 5 yes Figure 2 A flowchart of a specific embodiment of step 204 shown;
[0070] Figure 6 This is a schematic diagram of a structure of an embodiment of the data caching device according to this application;
[0071] Figure 7 This is a schematic diagram of the structure of one embodiment of the computer device according to this application. Detailed Implementation
[0072] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.
[0073] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0074] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0075] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0076] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social media platform software, etc.
[0077] Terminal devices 101, 102, and 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 players (Moving Picture Experts Group Audio Layer IV), laptops, and desktop computers, etc.
[0078] Server 105 can be a server that provides various services, such as a backend server that supports the pages displayed on terminal devices 101, 102, and 103.
[0079] It should be noted that the data caching method provided in this application embodiment is generally executed by the terminal device, and correspondingly, the data caching device is generally set in the terminal device.
[0080] It should be understood that Figure 1The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0081] Continue to refer to Figure 2 A flowchart of an embodiment of a data caching method according to this application is shown. The data caching method includes the following steps:
[0082] Step 201: Obtain batch of data to be cached.
[0083] In this embodiment, the batch of data to be cached includes user click data from various promotional platforms. Specifically, the user click data is characterized by high instantaneous concurrency. If all user click data is directly added to the cache space, it will lead to excessive instantaneous storage pressure and easily cause server crashes. The data caching method described in this application can reduce instantaneous caching pressure.
[0084] Step 202: Identify the timestamp field in the batch of data to be cached according to the preset identification rules.
[0085] In this embodiment, the step of identifying the timestamp field in the batch of data to be cached according to the preset identification rules specifically includes: identifying the timestamp field contained in the batch of data to be cached by means of time characterization keyword identification, wherein the time characterization keywords include year, month, day, hour, minute, and second, and / or identifying the timestamp field contained in the batch of data to be cached by means of time field display format, wherein the time field display format includes yyyy-MM-dd HH:mm:ss.
[0086] Specifically, the time representation keywords also include the English keywords corresponding to the Chinese character keywords, and the time field display format also includes a user-defined time display format.
[0087] By identifying the timestamp field in the batch of data to be cached, the batch of time data can be converted and processed, reducing the caching pressure on the server.
[0088] Step 203: The timestamp field is converted into binary code using a preset conversion strategy.
[0089] In this embodiment, before performing the step of converting the timestamp field into binary encoding using a preset conversion strategy, the method further includes: extracting time information from the timestamp field and converting the extracted time information into a numeric string in yyyyMMddHHmmss format.
[0090] By extracting the time information from the timestamp field and converting it to pure numerical value, it is easier to perform subsequent binary conversion.
[0091] Continue to refer to Figure 3 , Figure 3 yes Figure 2 A flowchart of a specific embodiment of step 203 shown includes:
[0092] Step 301: Obtain the last two digits of the year field as the first number to be converted;
[0093] Step 302: Obtain the month field number as the second number to be converted;
[0094] Step 303: Obtain the date field number as the third number to be converted;
[0095] Step 304: Obtain the hour field number as the fourth number to be converted;
[0096] Step 305: Obtain the minute field number as the fifth number to be converted;
[0097] Step 306: Obtain the second field number as the sixth number to be converted;
[0098] Step 307: Convert the first number to be converted, the second number to be converted, the third number to be converted, the fourth number to be converted, the fifth number to be converted, and the sixth number to be converted into binary characters respectively;
[0099] Step 308: The binary characters corresponding to the first number to be converted, the second number to be converted, the third number to be converted, the fourth number to be converted, the fifth number to be converted, and the sixth number to be converted are padded.
[0100] Continue to refer to Figure 4 , Figure 4 yes Figure 3 A flowchart of a specific embodiment of step 308 shown includes:
[0101] Step 401: Determine whether the binary character corresponding to the first number to be converted is 8 bits or more;
[0102] Since the first number to be converted, i.e. the last two digits of the year, is between 00 and 99, 8-bit binary characters are sufficient to meet the conversion requirements.
[0103] Step 402: Determine whether the binary character corresponding to the second number to be converted is 4 bits or more;
[0104] Since the second number to be converted, i.e. the month information, contains positive integers from 1 to 12, only 4 binary characters are needed to meet the conversion requirements.
[0105] Step 403: Determine whether the binary characters corresponding to the third and fourth numbers to be converted are 5 bits or more.
[0106] Since the third number to be converted, i.e. the date information, contains positive integers from 1 to 31, and the fourth number to be converted, i.e. the hour information, contains positive integers from 0 to 23, the conversion requirements can be met using 5 binary characters.
[0107] Step 404: Determine whether the binary characters corresponding to the fifth and sixth numbers to be converted are 6 bits or more.
[0108] Since the fifth and sixth numbers to be converted, namely the minutes and seconds information, contain positive integers from 0 to 59, the conversion requirements can be met using 6 binary characters.
[0109] Step 405: If any binary character in the binary characters corresponding to the first number to be converted, the second number to be converted, the third number to be converted, the fourth number to be converted, the fifth number to be converted, and the sixth number to be converted does not meet the corresponding target number of bits, then fill the corresponding binary character with 0 characters to complete the number of bits.
[0110] In this embodiment, if any binary character in the binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted does not meet the target number of bits, then the corresponding binary character is padded with 0 characters to complete the number of bits. For example, if the binary character corresponding to the first number to be converted is less than 8 bits, it is padded with 0 characters to make it 8 bits. The purpose is to ensure that the number of bits corresponding to the binary characters of the first, second, third, fourth, fifth, and sixth numbers to be converted is clear before the binary code is padded to N bits, which is convenient for time restoration later.
[0111] Of course, if the binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted all meet the corresponding target number of bits, then step 309 is executed.
[0112] In practice, since the second number to be converted, i.e. the month information, contains positive integers from 1 to 12, the third number to be converted, i.e. the date information, contains positive integers from 1 to 31, the fourth number to be converted, i.e. the hour information, contains positive integers from 0 to 23, and the fifth and sixth numbers to be converted, i.e. the minute and second information, contain positive integers from 0 to 59, there is a very high probability that the situation described in step 405 will occur, requiring padding. Only in a very small probability will padding not be performed.
[0113] Step 309: Obtain the full-position binary characters corresponding to the first number to be converted, the second number to be converted, the third number to be converted, the fourth number to be converted, the fifth number to be converted, and the sixth number to be converted, respectively;
[0114] Step 310: Sequentially concatenate the full-position binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted to obtain the binary code.
[0115] In this embodiment, the provided binary encoding conversion steps are for time information that includes the complete year, month, day, hour, minute, and second. However, it is not excluded if the time information only contains one or a combination of these elements. In this case, it is only necessary to obtain the target number to be converted based on the corresponding time information and perform the corresponding binary character conversion. By extracting the time information from the timestamp field, performing a pure numerical conversion, and then a binary conversion, it is easier to cache the time information using the binary encoding format. Compared to storing time data in String type, this greatly saves storage consumption and alleviates storage space pressure.
[0116] Step 204: 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 N modulo 8.
[0117] Continue to refer to Figure 5 , Figure 5 yes Figure 2 A flowchart of a specific embodiment of step 204 shown includes:
[0118] Step 501: Sum the number of bits for the full-bit binary characters corresponding to the first number to be converted, the second number to be converted, the third number to be converted, the fourth number to be converted, the fifth number to be converted, and the sixth number to be converted, to obtain the sum of the number of bits.
[0119] Step 502, using a preset algorithm formula:
[0120] ,
[0121] Determine whether the sum of the number of digits is divisible by 8, where M represents the sum of the number of digits. If the sum of the digits is 0, then 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 number of bits and the value are divisible by 8, then send an error message to the preset monitoring terminal.
[0123] Step 504: If the number of bits and the value are not divisible by 8, then pad the binary code with y zero characters to obtain an N-bit binary code. , .
[0124] Specifically, in this implementation, if the time information is complete in terms of year, month, day, hour, minute, and second, then if the number of digits and the value are divisible by 8, an error message is sent to the preset monitoring terminal. Of course, it is possible that the time information is not complete in terms of year, month, day, hour, minute, and second, for example, if it only contains the year, or only contains the date, hour, and minute information. In this case, if the number of digits and the value are divisible by 8, then there is no need to send an error message, and step 205 is executed directly. The specific decision depends on the actual time information extraction situation.
[0125] Step 205: The N-bit binary code is segmented into a Byte type array.
[0126] In this embodiment, the step of segmenting the N-bit binary code into Byte type arrays specifically includes: segmenting the N-bit binary code into Byte type arrays according to a preset segmentation length, wherein the preset segmentation length is 8 bits, and each Byte type array stores 8 bits of binary code.
[0127] Given the complete year, month, day, hour, minute, and second time information provided above, it is clear that the value of M is 8+4+5+5+6+6=34, the value of x is 2, the value of y is 6, and the value of N is 40. This means that the 40-bit binary code is divided into 8-bit segments, resulting in 5 Byte arrays. These are 5 8-bit binary codes consisting of 0s and 1s. Each Byte array corresponds to one byte in storage. Therefore, after binary encoding, padding, and segmentation of the timestamp field, the time information can be stored in 5 bytes. Compared to storing time information in String type data, this saves a significant amount of storage space and reduces storage pressure.
[0128] In actual use, step 205 can be executed first, followed by step 204. The difference is that if step 205 is executed first, the binary code obtained in step 203 is not padded beforehand. Instead, the binary code obtained in step 203 is directly segmented into a Byte type array. In this case, the segmentation follows the principle of segmenting from the end of the binary code. Then, the code segments with less than 8 bits at the beginning of the binary code are 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, before performing the step of replacing the timestamp field with the Byte type array to obtain the replaced cached data, the method further includes: serializing and organizing all Byte type arrays according to the order in which the 8-bit binary code stored in each Byte type array is in the N-bit binary code, to obtain a serialized Byte type array;
[0131] By serializing and organizing all the Byte type arrays obtained after the segmentation process, it is easier to serialize and store them later. This allows for quick restoration of time information when called again, 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 facilitates subsequent serialization and storage, so that time information can be quickly restored when called again, avoiding the inability to restore the timestamp field.
[0134] Step 207: Cache the replaced data to be cached in the target storage space.
[0135] By extracting time information from the timestamp field, converting it to pure numerical value, and then to binary, the binary encoding is segmented, serialized, and the original timestamp field is replaced. This facilitates subsequent caching of the time information in binary encoding form, significantly reducing storage consumption and alleviating storage space pressure compared to storing time data in String type. Applying this data caching method to time-limited cumulative click activities on various financial platforms enables lightweight caching of recorded time information, avoiding excessive instantaneous caching pressure on the server.
[0136] This application extracts the timestamp field from the instantaneous high-concurrency cached data, performs binary conversion, segments and serializes the binary encoding, and replaces the original timestamp field. This facilitates subsequent caching of the time information in binary encoding form, significantly reducing storage consumption and alleviating storage space pressure compared to storing time data in String type. Applying this data caching method to time-limited cumulative click activities on various financial platforms enables lightweight caching of batches of time information, avoiding excessive instantaneous caching pressure on the server.
[0137] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0138] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0139] In this embodiment, the timestamp field is extracted from the instantaneous high-concurrency cached data, then converted to binary, and the binary encoding is segmented, serialized, and replaced with the original timestamp field. This facilitates subsequent caching of the time information in binary encoding form, significantly reducing storage consumption and alleviating storage space pressure compared to storing time data in String type. Applying this data caching method to time-limited cumulative click activities on various financial platforms enables lightweight caching of batches of time information, avoiding excessive instantaneous caching pressure on the server.
[0140] Further reference Figure 6 As a response to the above Figure 2 To implement the method shown, this application provides an embodiment of a data caching device, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0141] like Figure 6As shown, the data caching device 600 described in this embodiment includes: a data to be cached acquisition module 601, a timestamp field recognition module 602, a binary encoding conversion module 603, a binary encoding padding module 604, a binary encoding segmentation module 605, a data to be cached replacement module 606, and a cache execution module 607. Wherein:
[0142] The cached data acquisition module 601 is used to acquire batches of cached data.
[0143] The timestamp field recognition module 602 is used to recognize the timestamp field in the batch of data to be cached according to a preset recognition rule;
[0144] The binary encoding conversion module 603 is used to convert the timestamp field into binary encoding using a preset conversion strategy;
[0145] The 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 N modulo 8.
[0146] The binary encoding segmentation module 605 is used to segment the N-bit binary encoding into a Byte type array;
[0147] The cached data replacement module 606 is used to replace the timestamp field with the Byte type array to obtain the cached data after replacement;
[0148] The cache execution module 607 is used to cache the replaced data to be cached in 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 time information caching scenarios. It extracts the timestamp field from the instantaneous high-concurrency cached data, performs binary conversion, segments and serializes the binary encoding, and replaces the original timestamp field. This facilitates subsequent caching of the time information in binary encoding form. Compared to storing time data in String type, this significantly saves storage consumption and alleviates storage space pressure. Applying this data caching method to time-limited cumulative click activities on various financial platforms enables lightweight caching of batches of time information, avoiding excessive instantaneous cache pressure on the server.
[0150] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These 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 methods described above. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0151] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0152] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. 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 via a system bus. It should be noted that only the computer device 7 with components 7a-7c is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0154] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.
[0155] The memory 7a includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), 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, magnetic disk, optical disk, etc. In some embodiments, the memory 7a may be an internal storage unit of the computer device 7, such as the hard disk or memory of the computer device 7. In other embodiments, the memory 7a may also be an external storage device of the computer device 7, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 7. Of course, the memory 7a may also include both the internal storage unit and its external storage device of the computer device 7. In this embodiment, the memory 7a is typically used to store the operating system and various application software installed on the computer device 7, such as computer-readable instructions for a data caching method. In addition, the memory 7a can also be used to temporarily store various types of data that have been output or will be output.
[0156] In some embodiments, the processor 7b may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 7b is typically used to control the overall operation of the computer device 7. In this embodiment, the processor 7b is used to execute computer-readable instructions stored in the memory 7a or to process data, for example, to execute computer-readable instructions of the data caching method.
[0157] The network interface 7c may include a wireless network interface or a wired network interface, which is typically used to establish communication connections 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 from the instantaneous high-concurrency cached data, performs binary conversion, segments and serializes the binary encoding, and replaces the original timestamp field. This facilitates subsequent caching of the time information in binary encoding form, significantly saving storage consumption and alleviating storage space pressure compared to String type time data storage. Applying this data caching method to time-limited cumulative click activities on various financial platforms enables lightweight caching of batches of time information, avoiding excessive instantaneous cache pressure on the server.
[0159] This application also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by a processor to cause the processor to perform the steps of the data caching method 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 from the instantaneous high-concurrency cached data, performs binary conversion, segments and serializes the binary encoding, and replaces the original timestamp field. This facilitates subsequent caching of the time information in binary encoding form, significantly saving storage consumption and alleviating storage space pressure compared to String type time data storage. Applying this data caching method to time-limited cumulative click activities on various financial platforms enables lightweight caching of batches of time information, avoiding excessive instantaneous caching pressure on the server.
[0161] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0162] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
Claims
1. A data caching method, characterized in that, Includes the following steps: Retrieve batch of data to be cached; According to the preset recognition rules, the timestamp field in the batch of data to be cached is identified; The timestamp field is converted into binary code using a preset conversion strategy; The binary code is padded 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 N modulo 8. The N-bit binary code is segmented into Byte type arrays. Specifically, the N-bit binary code is segmented into Byte type arrays according to a preset segmentation length, wherein the preset segmentation length is 8 bits, and each Byte type array stores 8 bits of binary code. The method further includes replacing the timestamp field with the Byte type array to obtain the replaced data to be cached, wherein, before 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: Serialize all Byte type arrays according to the order in which the 8-bit binary code is stored in each Byte type array within the N-bit binary code, 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: Replace the timestamp field with the serialized Byte type array to obtain the replaced data to be cached; The replaced data 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 preset identification rules specifically includes: The timestamp field contained in the batch of data to be cached is identified using a time-representation keyword identification method. The time-representation keywords include year, month, day, hour, minute, second, and / or... The timestamp field in the batch of data to be cached is identified by the display format of the time field, wherein the display format of the time field includes yyyy-MM-dd HH:mm:ss.
3. The data caching method according to claim 1, characterized in that, Before performing the step of converting the timestamp field to binary encoding using a preset conversion strategy, the method further includes: The timestamp field is used to extract time information, and the extracted time information is converted into a numeric string in yyyyMMddHHmmss format.
4. The data caching method according to claim 1, characterized in that, The step of converting the timestamp field into binary encoding using a preset conversion strategy specifically includes: Extract the last two digits of the year field as the first number to be converted; Get the month field number as the second number to be converted; Retrieve the date field number as the third number to be converted; Retrieve the hour field number as the fourth number to be converted; Retrieve the minute field number as the fifth number to be converted; Retrieve the second field number as the sixth number to be converted; The first, second, third, fourth, fifth, and sixth numbers to be converted are respectively converted into binary characters; The binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted are padded. Obtain the full-position binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted; The binary code is obtained by sequentially concatenating the full-position binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted.
5. The data caching method according to claim 4, characterized in that, The step of padding the binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted specifically includes: Determine whether the binary character corresponding to the first number to be converted is 8 bits or more; Determine whether the binary character corresponding to the second number to be converted is at least 4 bits. Determine whether the binary characters corresponding to the third and fourth numbers to be converted are each 5 bits long; Determine whether the binary characters corresponding to the fifth and sixth numbers to be converted are 6 bits or more. If any binary character in the binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted does not meet the target number of bits, then the corresponding binary character is padded with 0 characters to complete the number of bits.
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: For the full-bit binary characters corresponding to the first, second, third, fourth, fifth, and sixth numbers to be converted, the number of bits is summed to obtain the sum of the number of bits. The preset algorithm formula is used: , Determine whether the sum of the number of digits is divisible by 8, where M represents the sum of the number of digits. If the sum of the digits is 0, then the sum of the digits is divisible by 8; otherwise, the sum of the digits is not divisible by 8. If the number of bits and the value are divisible by 8, an error message is sent to the preset monitoring terminal. If the number of bits and the value are not divisible by 8, then pad the binary code with y zero characters to obtain an N-bit binary code. , .
7. A data caching device, characterized in that, The data caching device implements the steps of the data caching method as described in any one of claims 1 to 6, and the data caching device comprises: The module for retrieving cached data is used to retrieve batches of cached data. The timestamp field recognition module is used to recognize the timestamp field in the batch of data to be cached according to preset recognition rules; A binary encoding conversion module is used to convert the timestamp field into binary encoding using a preset conversion strategy; The binary code padding module 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 N modulo 8. The binary encoding segmentation module is used to segment the N-bit binary encoding into a Byte type array; The cached data replacement module is used to replace the timestamp field with the Byte type array to obtain the replaced cached data; The cache execution module is used to cache the replaced data to the target storage space.
8. A computer device, characterized in that, The system includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor, when executing the computer-readable instructions, implements the steps of the data caching method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the data caching method as described in any one of claims 1 to 6.