Data storage method, device, computer equipment and storage medium

By processing and storing the values ​​to be stored, the challenge of storing large amounts of data under limited data capacity is solved, reducing the amount of storage and saving memory, thereby improving device stability.

CN114594910BActive Publication Date: 2025-02-18CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210209294.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-03
Publication Date
2025-02-18
Estimated Expiration
2042-03-03

AI Technical Summary

Technical Problem

With limited data capacity, how to effectively store a large amount of data interaction and improve the stability of the device.

Method used

By receiving a data storage request for the value to be stored, search for the numerical storage rules. If it is not found, the value to be stored is processed as the target value based on the maximum number of numerical digits of the target memory and the maximum number of numerical digits and the number of numerical digits to be stored, and the target is obtained by processing the value to be stored as the target value. Identification of the value and store it in the target memory.

Benefits of technology

Reduce the number of stored values ​​and save the memory occupied by storage, which is conducive to improving the stability of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114594910B_ABST
    Figure CN114594910B_ABST
Patent Text Reader

Abstract

The present application relates to the field of data processing technology, and provides a data storage method, device, computer equipment and storage medium, wherein the method comprises: receiving data storage requests for at least two values ​​to be stored, the data storage request comprising the data identification of the values ​​to be stored; based on the data identification of the values ​​to be stored, searching for the numerical storage rules of the values ​​to be stored; if the numerical storage rules of the values ​​to be stored are not found, based on the maximum number of numerical digits of the target memory, and the maximum number of numerical digits and the number of the values ​​to be stored, processing the values ​​to be stored as target values, the number of the target values ​​being less than the number of the values ​​to be stored; obtaining the identification of the target values; based on the identification of the target values, storing the target values ​​in the target memory. The use of the present application can reduce the number of stored values, save the memory occupied by storage, and help improve the stability of the device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and mainly to a data storage method, device, computer equipment and storage medium. Background Art

[0002] With the development of Internet technology, the normal operation of applications is increasingly dependent on the interaction between data. However, the amount of data interaction in applications is huge every day, and the data stored in the memory is limited. Therefore, how to store data under limited data capacity has always been a technical problem to be solved by those skilled in the art. Summary of the invention

[0003] The embodiments of the present application provide a data storage method, apparatus, computer equipment and storage medium, which can reduce the number of stored values, save memory occupied by storage, and help improve the stability of the device.

[0004] In a first aspect, an embodiment of the present application provides a data storage method, wherein:

[0005] Receiving a data storage request for at least two values ​​to be stored, the data storage request including data identifiers of the values ​​to be stored;

[0006] Based on the data identifier of the value to be stored, searching for a value storage rule of the value to be stored;

[0007] If no numerical storage rule for the value to be stored is found, based on the maximum number of numerical digits of the target memory and the maximum number of numerical digits and the number of the values ​​to be stored, the value to be stored is processed as a target value, the number of the target values ​​being less than the number of the values ​​to be stored;

[0008] Obtaining an identifier of the target value;

[0009] Based on the identification of the target value, the target value is stored in the target memory.

[0010] In a second aspect, an embodiment of the present application provides a data storage device, wherein:

[0011] A receiving unit, configured to receive a data storage request for at least two values ​​to be stored, wherein the data storage request includes a data identifier of the values ​​to be stored;

[0012] A searching unit, configured to search for a numerical value storage rule of the numerical value to be stored based on a data identifier of the numerical value to be stored;

[0013] A processing unit, configured to process the at least two values ​​to be stored as target values ​​based on the maximum number of digits of the target memory and the maximum number of digits and the number of the values ​​to be stored if the value storage rule for the values ​​to be stored is not found; and obtain an identifier of the target value;

[0014] A storage unit is used to store the target value in the target memory based on the identifier of the target value.

[0015] In a third aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, a communication interface, and a computer program, wherein the computer program is stored in the memory, the computer program is configured to be executed by the processor, and the computer program includes instructions for some or all of the steps described in the first aspect.

[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program enables a computer to execute to implement some or all of the steps described in the first aspect.

[0017] Implementing the embodiments of the present application will have the following beneficial effects:

[0018] After adopting the above-mentioned data storage method, device, computer equipment and storage medium, if a data storage request for at least two values ​​to be stored is received, the numerical storage rule of the values ​​to be stored is searched based on the data identifier of the values ​​to be stored. If the numerical storage rule is not found, the values ​​to be stored are processed as target values ​​based on the maximum number of digits of the target memory and the maximum number of digits and number of the values ​​to be stored. Then, the target values ​​are stored in the target memory based on the identifier of the target values. Among them, the number of target values ​​is less than the number of values ​​to be stored. In this way, the number of stored values ​​can be reduced, the memory occupied by storage can be saved, and it is beneficial to improve the stability of the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0020] in:

[0021] Figure 1 A schematic diagram of a data storage method provided in an embodiment of the present application;

[0022] Figure 2 A schematic diagram of the structure of a data storage device provided in an embodiment of the present application;

[0023] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] 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 drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. According to the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0025] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0026] 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.

[0027] The network architecture used in the embodiment of the present application includes a server and an electronic device. The embodiment of the present application does not limit the number of electronic devices and servers, and the server can provide services for multiple electronic devices at the same time. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The server may be implemented by a server cluster consisting of multiple servers.

[0028] The electronic device may be a personal computer (PC), a laptop or a smart phone, or an all-in-one machine, a handheld computer, a tablet computer (pad), a smart TV player terminal, a vehicle-mounted terminal or a portable device. The operating system of the electronic device on the PC side, such as an all-in-one machine, may include but is not limited to Linux system, Unix system, Windows series system (such as Windows XP, Windows 7, etc.), Mac OS X system (Apple computer operating system) and other operating systems. The operating system of the electronic device on the mobile side, such as a smart phone, may include but is not limited to Android system, IOS (Apple mobile phone operating system), Window system and other operating systems.

[0029] The electronic device can install and run the application, and the server can be a server corresponding to the application installed in the electronic device, providing application services for the application. The application can be a separately integrated application software, or a small program embedded in other applications, or a system on a web page, etc., which is not limited here.

[0030] The embodiment of the present application provides a data storage method, which can be performed by a data storage device. The device can be implemented by software and / or hardware, and can generally be integrated in an electronic device or a server, which can reduce the number of stored values, save memory occupied by storage, and help improve the stability of the device.

[0031] Please refer to Figure 1 , Figure 1 This is a flow chart of a data storage method provided by the present application. Taking the application of the method in a server as an example, the method includes the following steps S101 to S105, wherein:

[0032] S101. Receive a data storage request for at least two values ​​to be stored, wherein the data storage request includes data identifiers of the values ​​to be stored.

[0033] The present application does not limit the data type of the value to be stored, which can be data of any business, or intermediate data processed by the server, or new data that has not been processed by the server, etc. In an embodiment of the present application, the data storage request includes a data identifier corresponding to the value to be stored, which is used to request the storage of the value to be stored. Among them, the data identifier corresponding to the value to be stored can be the name of the data corresponding to the value to be stored, such as the full name or abbreviation, or can be a combination of the name and user identifier of the data corresponding to the value to be stored, or the business identifier of the target business corresponding to the value to be stored, etc., which is not limited here.

[0034] S102: searching for a numerical value storage rule of the numerical value to be stored based on the data identifier of the numerical value to be stored.

[0035] In the embodiment of the present application, various numerical storage rules for data may be pre-stored. Thus, after finding the numerical storage rules for data corresponding to the numerical value to be stored, the numerical value to be stored may be stored based on the numerical storage rules. The numerical storage rules may include encoding and storing the numerical value, or splitting the numerical value into multiple sub-numerical values ​​for storage, or concatenating multiple numerical values ​​into one numerical value for storage, etc., which are not limited here.

[0036] S103: If no numerical storage rule for the value to be stored is found, based on the maximum number of numerical digits of the target memory and the maximum number of numerical digits and the number of the value to be stored, the value to be stored is processed into a target value.

[0037] In an embodiment of the present application, if the numerical storage rule of the value to be stored is not found, the value can be processed first, or the numerical storage rule of the value to be stored can be determined first, and then the data is stored. In a possible example, step S103 may include: if the numerical storage rule of the value to be stored is not found, then based on the maximum number of numerical digits of the target memory and the maximum number of numerical digits and the number of the value to be stored, the numerical storage rule of the value to be stored is obtained; based on the numerical storage rule of the value to be stored, at least two values ​​to be stored are processed as target values, and the numerical storage rule of the value to be stored is stored.

[0038] The present application does not limit the target memory, which may be a pre-set memory, or a memory with a larger remaining memory, or a memory corresponding to the target business corresponding to the value to be stored, etc. In a possible example, before processing the at least two values ​​to be stored as target values ​​based on the maximum number of value bits of the target memory and the maximum number of value bits and the number of values ​​to be stored, the method further includes the following steps A1 to A3, wherein:

[0039] A1. Get the storage attribute of the memory.

[0040] In the embodiment of the present application, the memory may be a local memory, or may be a wirelessly connected memory, for example, a cloud memory, a database of an application server, etc. The storage attributes of the memory may include storage rate, storage space, remaining storage space, purpose, security, etc., and may also include data attributes of stored data and data to be stored, etc., which are not limited here. Among them, the data attributes may include numerical value size, required storage space, required security value, affiliated business, associated data, authorized users, time information, account identification (or user identification), etc., which are not limited here.

[0041] A2. Obtain the data attribute of the value to be stored.

[0042] The data attributes of the value to be stored can refer to the description of step A1, which will not be repeated here. The storage attributes of the memory and the data attributes of the value to be stored can be obtained from pre-stored information; or the service status of the memory can be analyzed on the basis of the acquired attribute information of the memory to obtain the storage attributes of the memory, and the value to be stored can be analyzed on the basis of the acquired data attributes of the value to be stored to obtain the data attributes of the value to be stored, etc. The method for obtaining the data attributes of the value to be stored and the storage attributes of the memory is not limited here.

[0043] It should be noted that step A1 may be executed before step A2, step A1 may be executed after step A2, or step A1 may be executed simultaneously with step A2, which is not limited here.

[0044] A3. Select the target memory from the memory based on the data attribute and the storage attribute.

[0045] The present application does not limit the method for selecting the target memory. The matching value of the memory storing the value to be stored can be determined based on the storage attribute of the memory and the data attribute of the value to be stored; and the target memory is selected based on the size of the matching value. If there are multiple memories corresponding to the largest matching value, any of the memories can be selected as the target memory, or the most idle memory can be selected as the target memory, or the memory that has stored the data corresponding to the value to be stored can be selected as the target memory, etc.

[0046] The matching value may be obtained by weighting various information, for example, the ratio between the value of the value to be stored and the remaining space of the memory, the matching value between the security value required by the value to be stored and the security value corresponding to the security of the memory, the association value between the business associated with the value to be stored and the business stored in the memory, etc.

[0047] It can be understood that in steps A1 to A3, a target memory is selected from the memory based on the storage attribute of the memory and the data attribute of the value to be stored. In this way, the accuracy of selecting the target memory can be improved, which is conducive to improving the storage efficiency and stability of the value to be stored.

[0048] In the embodiment of the present application, the maximum number of digits of the target storage refers to the number of digits of the maximum value that can be stored in the target storage. For example, the target storage is Redis, because Redis supports the storage of 64-bit signed long data, and the maximum value is 9223372036854775807, that is, the maximum number of digits of Redis can be 19 digits.

[0049] The maximum number of digits of the value to be stored refers to the maximum number of digits of the data corresponding to the value to be stored. For example, the value to be stored is the number of page visits. If the number of page visits is about 1000 per second, the maximum value of the number of page visits can be 1000, and the maximum number of digits of the number of page visits can be 4.

[0050] It should be noted that the maximum number of digits of the value to be stored may refer to the maximum number of digits of the value to be stored itself, or may refer to the maximum number of digits of the encoded value of the value to be stored. The present application does not limit whether the value to be stored is encoded. If the data is character data, it can be encoded to obtain the corresponding encoded value. If the data is private data, it can be encoded to protect the security of the business. If the value of the data is a decimal, it can be taken as an integer, or processed into the numerical format required by the memory to meet the data storage requirements.

[0051] In the embodiment of the present application, the number of values ​​to be stored refers to the number of values ​​to be stored corresponding to the data storage request in step S101, that is, the number of at least two values ​​to be stored. The present application does not limit the number of values ​​to be stored, and a timestamp can be pre-set, for example, the values ​​to be stored obtained per second, the values ​​to be stored obtained per minute, or the values ​​to be stored obtained every 3 seconds, etc.

[0052] It should be noted that the number of values ​​to be stored is greater than or equal to 2, the number of target values ​​can be 1 or more, and the number of target values ​​should be smaller than the number of values ​​to be stored. In this way, the number of values ​​to be stored can be saved.

[0053] In a possible example, step S103 may include the following steps B1 to B5, wherein:

[0054] B1. If the numerical storage rule of the value to be stored is not found, the ratio between the maximum number of numerical digits of the target memory and the maximum number of numerical digits of the value to be stored is obtained.

[0055] B2. Round down the ratio to obtain a target value.

[0056] The target value is the ratio of the maximum number of digits of the target memory and the maximum number of digits of the value to be stored, and the value is rounded down. For example, if the maximum number of digits of the target memory is 19 and the maximum number of digits of the value to be stored is 4, 19 / 4 can be used and rounded down to get 4, that is, the target value is 4.

[0057] B3. Determine whether the number of the values ​​to be stored is less than or equal to the target value.

[0058] If the number of the values ​​to be stored is less than or equal to the target value, step B4 is executed to process the values ​​to be stored as the target values.

[0059] If the number of values ​​to be stored is greater than the target value, execute step B5, divide the at least two values ​​to be stored according to the target value to obtain at least two arrays to be stored, and the number of values ​​to be stored in each array to be stored is less than or equal to the target value; process the values ​​to be stored in the array to be stored as the target values.

[0060] It can be understood that storing multiple data as one value can save storage space. Therefore, in steps B1 to B5, each target value contains a maximum of target value data. If the number of values ​​to be stored is greater than the target value, the values ​​to be stored can be divided into at least two arrays to be stored, and then the values ​​to be stored in the arrays to be stored are processed into one target value. Exemplarily, if the target value is 4 and the number of values ​​to be stored is 7, the first 4 values ​​to be stored can be processed into one target value, and the last 3 values ​​to be stored can be processed into one target value, and then stored.

[0061] If the number of values ​​to be stored is less than or equal to the target value, the values ​​to be stored can be processed as one target value and stored. For example, if the target value is 4 and the number of values ​​to be stored is 2, the two values ​​to be stored can be processed as one target value and stored.

[0062] The present application does not limit the method for processing the to-be-stored value into the target value. In a possible example, the following steps C1 to C4 may be included, wherein:

[0063] C1. Determine whether the target service corresponding to the value to be stored is a preset service.

[0064] If the target service is a preset service, step C2 may be executed to obtain the cumulative expression corresponding to the maximum number of digits of the value to be stored. If the target service is not a preset service, the values ​​to be stored may be stored separately. Alternatively, an encryption algorithm corresponding to the target service may be determined to encode the value to be stored, and the encoded value may be used as the target value, etc., which is not limited here.

[0065] The present application does not limit the preset business, and the preset business can be a business of intermediate data that the server does not need to process or processes less. It can be understood that the business of intermediate data that the server does not need to process means that the current server does not process the data of the business, or rarely processes the data. In this way, through the data storage method proposed in the present application that stores multiple values ​​as one value, the storage amount and the code workload of the database operation layer can be reduced, which is conducive to improving the stability of the database.

[0066] Preset services or services that can be processed by the server and are not affected by security, etc. It can be understood that services where data processed by the server is not affected by security can increase the data processing rate while ensuring security.

[0067] In a possible example, step C2 may include the following steps C21 to C23, wherein:

[0068] C21. Determine the data type involved in the target business corresponding to the value to be stored.

[0069] In an embodiment of the present application, the data type involved in the target business corresponding to the value to be stored specifically includes the data type involved in the target business. The data type can be determined based on the business type of the target business, and / or the input data, intermediate data and output data of the target business, etc., and is not limited here. It can be understood that the input data and output data of the target business are related to the data involved in the target business, and the data involved in the target business is also related to the business type of the target business. Based on this, the data type involved in the target business is determined based on the business type of the target business and the input data and output data of the target business, which can improve the accuracy of determining the data type.

[0070] C22. Determine the risk value and processing complexity of the target business based on the data type.

[0071] In an embodiment of the present application, the risk value of the target business is used to describe the size of the risk caused by data leakage in the target business. The risk value can be determined based on whether each data type is a privacy type, or the probability that the data corresponding to the data type is used in other businesses. It can be understood that if the business data of the target business is a privacy type, the risk of data leakage is high. The greater the probability that the data is used by other businesses, the greater the impact of the data leakage. In this way, the accuracy of determining the risk value of the target business can be improved.

[0072] The processing complexity of the target business refers to the complexity of the processing logic of the data in the target business. The processing complexity can be determined based on the association relationship between the data corresponding to each data type, and the association relationship between the input data and the output data. It can be understood that based on the association relationship between the data corresponding to each data type, the data processing logic between the data can be determined. Based on the association relationship between the data corresponding to each data type and the input data and the output data, the data processing logic of each data in the target business can be determined. In this way, the accuracy of determining the processing complexity of the target business can be improved.

[0073] C23. If the risk value is less than the first threshold, or the processing complexity is greater than the second threshold, the target business is determined to be a preset business.

[0074] The present application does not limit the first threshold and the second threshold, which can be determined based on the number of values ​​to be stored, the number of target businesses involved in the values ​​to be stored, the number of data associated with the values ​​to be stored, etc. It can be understood that in steps C21 to C23, the risk value and processing complexity of the target business are determined based on the data type involved in the target business corresponding to the values ​​to be stored. In this way, it is determined whether the target business is a preset business based on the size of the risk value of the target business and the size of the processing complexity. If so, the values ​​to be stored can be processed according to the method after step C2 to reduce the storage quantity of the memory.

[0075] The cumulative expression corresponding to the maximum number of digits of the value to be stored can be obtained by substituting the maximum number of digits of the value to be stored into a preset cumulative expression to obtain the cumulative expression of the value to be stored. The value to be stored can be represented in the form of an index value according to its arrangement sequence. For example, every 4 values ​​to be stored in the target memory are stored as a target value, that is, the values ​​to be stored can be value1, value2, value3 and value4. The cumulative expression can be shown as the following formula (1):

[0076] value+=value index *math.pow(10,n*(index-1)) (1)

[0077] Where n refers to the maximum number of digits of the value to be stored. index refers to the index value of the value to be stored, which can be the sequence number of the value to be stored. value indexRefers to the value to be stored, math.pow(A, B) is an exponential function, which is used to return the base A raised to the power of exponent B, that is, math.pow(A, B) = AB. In this way, the initial value of value1 can be set to 0, index can be set to 1, and the variable of value1 can be determined using formula (1), and then added to 0 to obtain value1. Then, index can be set to 2, and the variable between value2 and value1 can be determined using formula (1), and then added to value1 to obtain value2, and so on.

[0078] C3. Determine the sequence number of the values ​​to be stored based on the time sequence of the values ​​to be stored.

[0079] The earlier the time of the value to be stored is, the smaller the sequence number of the value to be stored is. Alternatively, the earlier the time of the value to be stored is, the larger the sequence number of the value to be stored is, which is not limited here.

[0080] C4. Based on the cumulative expression, the values ​​to be stored are calculated in sequence according to the arrangement sequence numbers of the values ​​to be stored to obtain a target value.

[0081] The target value can be obtained by sequentially calculating the values ​​to be stored using the IncrBy operation and formula (1). It can be understood that in steps C1 to C4, if it is determined that the target business corresponding to the value to be stored is a preset business, then based on the cumulative expression corresponding to the maximum number of digits of the value to be stored, the value to be stored is sequentially calculated according to the arrangement sequence of the value to be stored to obtain the target value. In this way, the target value includes a combination of multiple values ​​to be stored, and the target value can be split according to the maximum number of digits of the value to be stored to obtain the value to be stored, thereby improving the efficiency of searching for the value to be stored.

[0082] In a possible example, a get command may be used to search for a target value stored in a target memory, and then the target value may be inversely solved by formula (2) to obtain a value to be stored, where:

[0083] value index =math.floor(value / math.floor(10,index-1))%math.pow(10,n)(2)

[0084] Among them, n, index, value indexThe description of math.pow(A, B) and math.floor(C, D) can refer to formula (1), which will not be repeated here. math.floor(C, D) is a floor function, which is used to return the largest integer less than or equal to a given number, that is, to return the largest integer between C and D. In this way, after obtaining the target value using the get command, the value to be stored can be calculated based on the use of formula (2) and the arrangement number (index) of the value to be stored to be found. Exemplarily, the maximum number of digits of the value to be stored is 4, and the arrangement number of the value to be stored is 2, then the index is set to 2, and value2 is calculated using formula (2).

[0085] S104: Obtain an identifier of the target value.

[0086] In the embodiment of the present application, the identification of the target value can be determined based on the data identification and arrangement sequence number of the value to be stored, which is not limited here. In a possible example, step S104 can include the following two cases, where:

[0087] The first one is, if the number of the values ​​to be stored is less than or equal to the target value, obtaining the identifier of the target value based on the data attribute of the values ​​to be stored.

[0088] The second word, if the number of the to-be-stored values ​​is greater than the target value, obtains the identifier of the target value based on the arrangement sequence number of the to-be-stored array and the data attribute of the to-be-stored values.

[0089] Among them, the data attributes of the value to be stored can refer to the above, including the value size, the required storage space, the required security value, the business to which it belongs, the associated data, the authorized user, the time information, the account identifier (or user identifier), etc. It should be noted that the data attribute used to obtain the identification of the target value can be at least one or more of the above data attributes. It can be understood that identifying the target value with time information is conducive to improving the efficiency of data search. Identifying the target value with an account identifier is conducive to improving the efficiency of finding data for a certain user or a certain type of user.

[0090] It can be understood that when the number of values ​​to be stored is less than or equal to the target value, the identification of the target value is obtained based on the data attribute of the value to be stored, which can improve the efficiency of searching for the value to be stored. When the number of values ​​to be stored is greater than the target value, in addition to the data attribute of the value to be stored, the identification of the target value is also obtained based on the arrangement sequence number of the array to be stored, so that the target value corresponding to the array to be stored to which the value to be stored belongs can be found, rather than the target values ​​corresponding to other values ​​to be stored, which is conducive to improving the efficiency and accuracy of searching for the target value.

[0091] For example, when the number of values ​​to be stored is greater than the target value, the identifier of the target value is described in the form of {id}_{i}_{timestamp}, where id is the account identifier, i is the sequence number of the array to be stored, and timestamp is the value corresponding to the time information of the value to be stored.

[0092] S105. Based on the identifier of the target value, store the target value in the target memory.

[0093] exist Figure 1 In the method shown, if a data storage request for at least two values ​​to be stored is received, the value storage rule of the values ​​to be stored is searched based on the data identifier of the values ​​to be stored. If the value storage rule is not found, the values ​​to be stored are processed as target values ​​based on the maximum number of digits of the target memory and the maximum number of digits and number of the values ​​to be stored. Then, the target values ​​are stored in the target memory based on the identifier of the target values. The number of target values ​​is less than the number of values ​​to be stored. In this way, the number of stored values ​​can be reduced, the memory occupied by the storage can be saved, and the stability of the device can be improved.

[0094] The method of the embodiment of the present application is described in detail above, and the device of the embodiment of the present application is provided below.

[0095] and Figure 1 The embodiment shown is consistent with that shown in FIG. Figure 2 , Figure 2 Schematic diagram of a data storage device proposed in this application. Figure 2 As shown, the data storage device 200 comprises:

[0096] The receiving unit 201 is used to receive a data storage request for at least two values ​​to be stored, wherein the data storage request includes a data identifier of the values ​​to be stored;

[0097] The search unit 202 is used to search for a value storage rule of the value to be stored based on the data identifier of the value to be stored;

[0098] The processing unit 203 is used for, if the value storage rule of the value to be stored is not found, processing the at least two values ​​to be stored as target values ​​based on the maximum number of digits of the target memory and the maximum number of digits and the number of the values ​​to be stored; and obtaining the identifier of the target value;

[0099] The storage unit 204 is used to store the target value in the target memory based on the identifier of the target value.

[0100] In a possible example, the processing unit 203 is specifically used to obtain the ratio between the maximum number of numerical digits of the target memory and the maximum number of numerical digits of the values ​​to be stored; round down the ratio to obtain a target value; if the number of values ​​to be stored is less than or equal to the target value, the values ​​to be stored are processed as target values.

[0101] Alternatively, in a possible example, the processing unit 203 is specifically used to divide the at least two values ​​to be stored according to the target value to obtain at least two arrays to be stored if the number of values ​​to be stored is greater than the target value, and the number of values ​​to be stored in each array to be stored is less than or equal to the target value; and process the values ​​to be stored in the arrays to be stored as target values.

[0102] In a possible example, the processing unit 203 is specifically used to determine whether the target business corresponding to the value to be stored is a preset business; if the target business is the preset business, obtain the cumulative expression corresponding to the maximum number of digits of the value to be stored; determine the arrangement sequence number of the value to be stored based on the time sequence of the value to be stored; based on the cumulative expression, calculate the value to be stored in sequence according to the arrangement sequence number of the value to be stored to obtain the target value.

[0103] In a possible example, the processing unit 203 is specifically used to determine the data type involved in the target business corresponding to the value to be stored; determine the risk value and processing complexity of the target business based on the data type; if the risk value is less than a first threshold, or the processing complexity is greater than a second threshold, determine that the target business is a preset business.

[0104] In a possible example, the processing unit 203 is specifically configured to obtain an identifier of the target value based on a data attribute of the value to be stored if the number of the value to be stored is less than or equal to the target value.

[0105] Alternatively, in a possible example, the processing unit 203 is specifically configured to obtain an identifier of the target value based on an arrangement sequence number of the array to be stored and a data attribute of the value to be stored if the number of the value to be stored is greater than the target value.

[0106] In a possible example, the data attribute of the value to be stored includes at least one item: an account identifier corresponding to the value to be stored, and time information of the value to be stored.

[0107] In a possible example, the processing unit 203 is further used to obtain storage attributes of a memory; obtain data attributes of the value to be stored; and select the target memory from the memory based on the data attributes and the storage attributes.

[0108] The detailed process of each unit in the data storage device 200 can refer to the execution steps in the aforementioned method embodiment, which will not be repeated here.

[0109] and Figure 1 For details, please refer to Figure 3 , Figure 3 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 3 As shown, the computer device 300 includes a processor 310, a memory 320 and a communication interface 330. The processor 310, the memory 320 and the communication interface 330 are connected to each other via a bus 350. Figure 2 The related functions implemented by the receiving unit 201 shown can be implemented through the communication interface 330. Figure 2 The related functions implemented by the search unit 202 and the processing unit 203 shown can be implemented by the processor 310 . Figure 2 The related functions implemented by the storage unit 204 shown can be implemented by the memory 320 .

[0110] The memory 320 stores a computer program 340, which is configured to be executed by the processor 310. The computer program 340 includes instructions for executing the following steps:

[0111] Receiving a data storage request for at least two values ​​to be stored, the data storage request including data identifiers of the values ​​to be stored;

[0112] Based on the data identifier of the value to be stored, searching for a value storage rule of the value to be stored;

[0113] If no numerical storage rule for the value to be stored is found, based on the maximum number of numerical digits of the target memory and the maximum number of numerical digits and the number of the values ​​to be stored, the value to be stored is processed as a target value, the number of the target values ​​being less than the number of the values ​​to be stored;

[0114] Obtaining an identifier of the target value;

[0115] Based on the identification of the target value, the target value is stored in the target memory.

[0116] In a possible example, in processing the at least two to-be-stored values ​​as target values ​​based on the maximum number of value bits of the target memory and the maximum number of value bits and the number of the to-be-stored values, the computer program 340 specifically includes instructions for executing the following steps:

[0117] Obtaining a ratio between a maximum number of digits of a numerical value of the target memory and a maximum number of digits of a numerical value to be stored;

[0118] Rounding down the ratio to obtain a target value;

[0119] If the number of the values ​​to be stored is less than or equal to the target value, the values ​​to be stored are processed as the target value;

[0120] Alternatively, if the number of values ​​to be stored is greater than the target value, the at least two values ​​to be stored are divided according to the target value to obtain at least two arrays to be stored, and the number of values ​​to be stored in each array to be stored is less than or equal to the target value; the values ​​to be stored in the arrays to be stored are processed as target values.

[0121] In a possible example, in processing the to-be-stored value into a target value, the computer program 340 specifically includes instructions for executing the following steps:

[0122] Determining whether the target service corresponding to the value to be stored is a preset service;

[0123] If the target service is the preset service, obtaining a cumulative expression corresponding to the maximum number of digits of the value to be stored;

[0124] Determining the sequence number of the values ​​to be stored based on the time sequence of the values ​​to be stored;

[0125] Based on the cumulative expression, the values ​​to be stored are calculated in sequence according to the arrangement sequence numbers of the values ​​to be stored to obtain the target value.

[0126] In a possible example, in determining whether the target service corresponding to the value to be stored is a preset service, the computer program 340 specifically includes instructions for executing the following steps:

[0127] Determine the data type involved in the target business corresponding to the value to be stored;

[0128] Determine the risk value and processing complexity of the target business based on the data type;

[0129] If the risk value is less than a first threshold, or the processing complexity is greater than a second threshold, the target business is determined to be a preset business.

[0130] In a possible example, in the aspect of obtaining the identifier of the target value, the computer program 340 specifically includes instructions for executing the following steps:

[0131] If the number of the values ​​to be stored is less than or equal to the target value, obtaining an identifier of the target value based on the data attribute of the values ​​to be stored;

[0132] Alternatively, if the number of the values ​​to be stored is greater than the target value, the identifier of the target value is obtained based on the arrangement sequence number of the array to be stored and the data attribute of the values ​​to be stored.

[0133] In a possible example, the data attribute of the value to be stored includes at least one item: an account identifier corresponding to the value to be stored, and time information of the value to be stored.

[0134] In a possible example, before processing the at least two to-be-stored values ​​into target values ​​based on the maximum number of value bits of the target memory and the maximum number of value bits and the number of the to-be-stored values, the computer program 340 further includes instructions for performing the following steps:

[0135] Get the storage properties of the memory;

[0136] Obtaining data attributes of the value to be stored;

[0137] The target storage is selected from the storage based on the data attribute and the storage attribute.

[0138] An embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, which enables a computer to execute part or all of the steps of any method recorded in the method embodiment, and the computer includes an electronic device or a server.

[0139] The present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute to implement some or all steps of any method described in the method embodiment. The computer program product can be a software installation package, and the computer includes an electronic device or a server.

[0140] In the above embodiment, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of blockchain nodes, etc. For example, the blockchain may store data identifiers of values ​​to be stored, value storage rules, first thresholds, and second thresholds, etc., which are not limited here.

[0141] The blockchain referred to in the embodiments of the present application is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods, each of which contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0142] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modes involved are not necessarily required by the present application.

[0143] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0144] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as at least one unit or component can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0145] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on at least one network unit. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0146] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software program mode.

[0147] If the integrated unit is implemented in the form of a software program model and sold or used as an independent product, it can be stored in a computer-readable memory. According to this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, magnetic disk or optical disk, etc., and other media that can store program codes.

[0148] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A data storage method, characterized in that: include: Receiving a data storage request for at least two values ​​to be stored, the data storage request including data identifiers of the values ​​to be stored; Based on the data identifier of the value to be stored, searching for a value storage rule of the value to be stored; If the numerical storage rule of the value to be stored is not found, then obtaining the ratio between the maximum number of numerical digits of the target memory and the maximum number of numerical digits of the value to be stored; Rounding down the ratio to obtain a target value; If the number of the to-be-stored values ​​is less than or equal to the target value, the to-be-stored values ​​are processed as the target values; or If the number of the values ​​to be stored is greater than the target value, the at least two values ​​to be stored are divided according to the target value to obtain at least two arrays to be stored, and the number of the values ​​to be stored in each array to be stored is less than or equal to the target value; Processing the to-be-stored values ​​in the to-be-stored array into target values; The number of the target values ​​is less than the number of the values ​​to be stored; The processing of the to-be-stored value into a target value comprises: Determining whether the target service corresponding to the value to be stored is a preset service; If the target service is the preset service, the cumulative expression corresponding to the maximum number of digits of the value to be stored is obtained, and the cumulative expression is shown in the following formula: value +=value index * math.pow(10, n * (index - 1)) (1) Among them, n refers to the maximum number of digits of the value to be stored, index refers to the index value of the value to be stored, and value index Refers to the value to be stored, math.pow(A, B) is an exponential function, which is used to return the base A to the power of exponent B; Determining the sequence number of the values ​​to be stored based on the time sequence of the values ​​to be stored; Based on the cumulative expression, the values ​​to be stored are calculated in sequence according to the arrangement sequence numbers of the values ​​to be stored to obtain a target value; Obtaining an identifier of the target value; Based on the identification of the target value, the target value is stored in the target memory.

2. The method according to claim 1, characterized in that: The determining whether the target service corresponding to the value to be stored is a preset service includes: Determine the data type involved in the target business corresponding to the value to be stored; Determine the risk value and processing complexity of the target business based on the data type; If the risk value is less than a first threshold, or the processing complexity is greater than a second threshold, the target business is determined to be a preset business.

3. The method according to claim 1, characterized in that The step of obtaining the identifier of the target value includes: If the number of the values ​​to be stored is less than or equal to the target value, obtaining an identifier of the target value based on the data attributes of the values ​​to be stored; or If the number of the to-be-stored values ​​is greater than the target value, an identifier of the target value is obtained based on the arrangement sequence number of the to-be-stored array and the data attribute of the to-be-stored values.

4. The method according to claim 3, characterized in that: The data attribute of the value to be stored includes at least one item: an account identifier corresponding to the value to be stored and time information of the value to be stored.

5. The method according to any one of claims 1 to 4, characterized in that Before obtaining the ratio between the maximum number of digits of the target memory and the maximum number of digits of the value to be stored, the method further includes: Get the storage properties of the memory; Obtaining data attributes of the value to be stored; The target storage is selected from the storage based on the data attribute and the storage attribute.

6. A data storage device, characterized in that: The data storage device is used to execute the data storage method according to any one of claims 1 to 5, and the device comprises: A receiving unit, configured to receive a data storage request for at least two values ​​to be stored, wherein the data storage request includes a data identifier of the values ​​to be stored; A searching unit, configured to search for a numerical value storage rule of the numerical value to be stored based on a data identifier of the numerical value to be stored; A processing unit, configured to process the at least two values ​​to be stored as target values ​​based on the maximum number of digits of the target memory and the maximum number of digits and the number of the values ​​to be stored if the value storage rule for the values ​​to be stored is not found; and obtain an identifier of the target value; A storage unit is used to store the target value in the target memory based on the identifier of the target value.

7. A computer device, characterized in that: The method comprises a processor, a memory and a communication interface, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the steps in any one of the methods of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which enables a computer to execute to implement the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data storage and reading method and device

    CN108572787A

  • Numerical value processing method and device, processing equipment and computer readable storage medium

    CN112099759A