Multi-level data storage and reading method and device, equipment and storage medium
By changing the frequency classification of small and micro product package data and building a multi-level cache system, the problem of inefficient data storage and access in the existing technology is solved, and more efficient and secure data processing and access is achieved.
Patent Information
- Application Number
- CN202411769565.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-03-28
AI Technical Summary
The prior art has low efficiency, high latency and slow access speed during the data storage and access of small and micro product packages, which cannot meet the rapid change needs of insurance institutions.
Multi-level data storage and reading methods are adopted to classify product data by obtaining the change frequency, first-level cache and second-level cache are built, and data storage and access processes are optimized.
It improves the efficiency of data storage and reading, reduces the system burden, improves the system response capability and data security, and reduces user waiting time.
Smart Images

Figure CN119719104A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a method for storing and reading multi-level data. Background Art
[0002] With the development and diversification of society, in the insurance field, personalized small and micro product packages based on different small and micro enterprises have emerged; small and micro product packages are composed of multiple layers of nested data levels. Specifically, the small and micro product structure is composed of multiple layers such as product packages, insurance types, liabilities, insurance type attributes and liability attributes, forming a complex data network, in which a package can cover multiple insurance types, each insurance type can be subdivided into multiple liabilities, and insurance types and liabilities correspond to multiple attributes and clause text information respectively;
[0003] In addition, the frequency of changes in small and micro package products is relatively high. In order to meet local needs, various insurance institutions need to frequently add and modify product configurations.
[0004] At present, the storage and access of small and micro package products are completed by directly operating the database. Due to the complex data structure and large data volume of small and micro package products, the existing operation method often leads to low loading efficiency, high latency and slow access speed. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a method, device, equipment and storage medium for storing and reading multi-level data, the main purpose of which is to improve the efficiency of data storage and reading.
[0006] In order to solve the above technical problems, the embodiment of the present application provides a method for storing and reading multi-level data, which adopts the following technical solution:
[0007] Acquire multi-level nested product data, classify the product data according to the change frequency of the product data, and obtain first product data and second product data;
[0008] Pre-building a first-level cache and a second-level cache, storing the first product data in the first-level cache, and storing the second product data in the second-level cache;
[0009] When receiving an access request from a user, determining whether target data of the access request can be read from the first-level cache and the second-level cache according to the access request;
[0010] If yes, reading the target data of the access request from the first-level cache and the second-level cache according to the access request, and feeding back the target data to the user;
[0011] If not, the target data corresponding to the access request is read from a preset database according to the access request, and the target data is fed back to the user.
[0012] Further, the classifying the product data according to the change frequency of the product data to obtain the first product data and the second product data includes:
[0013] Obtaining the historical change count of each type of data to be classified in the product data in the first preset time period;
[0014] Calculating the historical change frequency corresponding to each type of the data to be classified according to the number of historical changes of each type of the data to be classified and the first preset time period;
[0015] The product data is classified according to the historical change frequency of each type of the data to be classified to obtain the first product data and the second product data.
[0016] Furthermore, the classifying the product data according to the change frequency of the product data to obtain the first product data and the second product data also includes:
[0017] According to a predefined change frequency data table, identifying high change frequency data and low change frequency data in the product data;
[0018] classifying the low-change frequency data of the product data as the first product data;
[0019] The high-change-frequency data of the product data is classified as the second product data.
[0020] Further, storing the first product data in the first-level cache includes:
[0021] Encrypting the first product data using a preset encryption algorithm to obtain encrypted data;
[0022] Adding corresponding identification information to the encrypted data to obtain encrypted data with the identification;
[0023] The encrypted data with the identifier is stored in the first-level cache.
[0024] Further, after storing the first product data in the first level cache and storing the second product data in the second level cache, the method further includes:
[0025] Regularly obtain the change frequency corresponding to each data in the first-level cache and the second-level cache;
[0026] The first-level cache and the second-level cache are updated according to the change frequencies corresponding to the respective data to obtain an updated first-level cache and an updated second-level cache.
[0027] Further, reading the target data of the access request from the first-level cache and the second-level cache according to the access request, and feeding back the target data to the user, includes:
[0028] Parsing the access request to obtain a data type corresponding to the access request;
[0029] Determining whether a predefined change frequency data table can identify the change frequency corresponding to the data type;
[0030] When the predefined change frequency data table can identify the change frequency corresponding to the data type, according to the identification result, the target data of the access request is read from the first-level cache and the second-level cache in a cache priority manner, and the target data is fed back to the user;
[0031] When the predefined change frequency data table cannot identify the change frequency corresponding to the data type, the target data of the access request is read from the primary cache and the secondary cache in a simultaneous reading manner, and the target data is fed back to the user.
[0032] Furthermore, after reading the target data corresponding to the access request from a preset database according to the access request, the method further includes:
[0033] After the target data corresponding to the access request is read from the preset database, the target data is stored in the first-level cache or the second-level cache according to a preset cache strategy.
[0034] In order to solve the above technical problems, the embodiment of the present application further provides a multi-level data storage and reading device, which adopts the following technical solution:
[0035] A classification module, used to obtain multi-level nested product data, classify the product data according to the change frequency of the product data, and obtain first product data and second product data;
[0036] A storage module, used to pre-build a first-level cache and a second-level cache, store the first product data in the first-level cache, and store the second product data in the second-level cache;
[0037] A judgment module, configured to judge, when receiving an access request from a user, whether the target data of the access request can be read from the first-level cache and the second-level cache according to the access request;
[0038] A first feedback module, configured to read target data of the access request from the first-level cache and the second-level cache according to the access request, and feed back the target data to the user if possible;
[0039] The second feedback module is configured to read the target data corresponding to the access request from a preset database according to the access request if the access request fails, and feed back the target data to the user.
[0040] In order to solve the above technical problems, an embodiment of the present application also provides a computer device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the multi-level data storage and reading method as described above.
[0041] In order to solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned method for storing and reading multi-level data.
[0042] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0043] Classify the product data according to the change frequency of the data to be classified in the product data to obtain the first product data and the second product data, so as to provide a decision basis for the subsequent storage and reading of the data, improve the efficiency of data processing and reduce the cost of data maintenance;
[0044] By pre-building a first-level cache and a second-level cache, storing the first product data in the first-level cache, and storing the second product data in the second-level cache, using the characteristics of different cache spaces to store corresponding data, the data reading and writing speed and system responsiveness can be improved, while reducing the burden on the system and ensuring data security;
[0045] By extracting the data corresponding to the access request from the cache, the burden on the database is reduced, data access is improved, and the user's waiting time is reduced, thereby improving user satisfaction;
[0046] When the access request cannot read the corresponding target data from the cache, the data is read from the preset database to ensure that the access request made by the user can receive the corresponding data. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0048] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0049] Figure 2 A flowchart of an embodiment of a method for storing and reading multi-level data according to the present application;
[0050] Figure 3 is a schematic structural diagram of an embodiment of a multi-level data storage and reading device according to the present application;
[0051] Figure 4 It is a structural schematic diagram of an embodiment of a device according to the present application. DETAILED DESCRIPTION
[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0053] 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.
[0054] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0055] like Figure 1As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0056] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0057] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0058] The server 103 may be a server that provides various services, such as a background server that provides support for a web page displayed on the terminal device 101 .
[0059] It should be noted that the method for storing and reading multi-level data provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the storage and reading device for multi-level data is generally arranged in the server / terminal device.
[0060] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0061] Continue to refer Figure 2, shows a flowchart of an embodiment of a method for storing and reading multi-level data according to the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted. The method for storing and reading multi-level data provided in the embodiment of the present application can be applied to any scenario that requires storing and reading multi-level data, and the method for storing and reading multi-level data can be applied to products in these scenarios. The method for storing and reading multi-level data includes the following steps:
[0062] Step S201, acquiring multi-level nested product data, classifying the product data according to the change frequency of the product data, and obtaining first product data and second product data;
[0063] In this embodiment, the electronic device (eg Figure 1 The server / terminal device shown in the figure) can receive the access request uploaded by the user through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future. The execution subject of this application may be a multi-level data storage and reading system, or simply referred to as a system.
[0064] In this embodiment, the above-mentioned multi-level nested product data includes but is not limited to primary product data (such as product packages), secondary product data (such as insurance types), tertiary product data (such as liability, insurance type attributes, and insurance type corresponding clause text information), etc., wherein the primary product data includes multiple secondary product data, and each of the secondary product data includes multiple tertiary product data; since the change frequency of each data in the above-mentioned multi-level nested product data is different and the data volume is large, the change frequency is not limited to the frequency of adding, modifying, and personalizing the product data, in order to prevent the problem of multi-level and large data volume of directly multi-level nested product data, resulting in low loading efficiency and high delay when loading the above-mentioned multi-level nested product data, it is also necessary to classify the multi-level nested product data according to the change frequency to obtain the first product data and the second product data.
[0065] In one embodiment, classifying the product data according to the change frequency of the product data to obtain the first product data and the second product data includes:
[0066] Obtaining the historical change count of each type of data to be classified in the product data in the first preset time period;
[0067] Calculating the historical change frequency corresponding to each type of the data to be classified according to the number of historical changes of each type of the data to be classified and the first preset time period;
[0068] The product data is classified according to the historical change frequency of each type of the data to be classified to obtain the first product data and the second product data.
[0069] In this embodiment, the above-mentioned first product data refers to data with a lower change frequency (such as the text information of the insurance terms corresponding to the third-level product data, etc.), and the above-mentioned second product data refers to data with a higher change frequency (such as the insurance type information of the second-level product data, etc.); the historical change times of each type of data to be classified of the product data in the first preset time period are obtained, and based on each type of data to be classified, the historical change frequency corresponding to each type of data to be classified is obtained by calculating the historical change times corresponding to the data to be classified and the length of the first preset time period, and a change frequency threshold is pre-set. When the historical change frequency is less than the change frequency threshold, the product to be classified corresponding to the historical change frequency is classified as the first product data; when the historical change frequency is greater than or equal to the change frequency threshold, the data to be classified corresponding to the historical change frequency is classified as the second product data.
[0070] In this embodiment, by calculating the historical change frequency of each data to be classified in the product data, first product data and second product data are obtained, which can make corresponding decisions for the data to be classified with different change frequencies, thereby improving data processing efficiency and reducing maintenance costs.
[0071] In another embodiment, the classifying the product data according to the change frequency of the product data to obtain the first product data and the second product data further includes:
[0072] According to a predefined change frequency data table, identifying high change frequency data and low change frequency data in the product data;
[0073] classifying the low-change frequency data of the product data as the first product data;
[0074] The high-change-frequency data of the product data is classified as the second product data.
[0075] In this embodiment, a change frequency data table is prepared in advance, and the change frequency data table records high change frequency data and low change frequency data in the product data. The above-mentioned change frequency data table can be a structured document (such as a table form), and each product to be classified in the product data is marked with "high change frequency" or "low change frequency"; the above-mentioned high change frequency data refers to data that may change in the above-mentioned product data, such as the insurance type information of the secondary product data; the above-mentioned low change frequency data refers to data that remains stable in the above-mentioned product data, such as the text information of the corresponding clauses of the insurance type of the tertiary product data, and the above-mentioned low change data means that in most cases it will not change, but it is not completely unchangeable; according to the marking of each type of data to be classified, the data to be classified marked with high change frequency is classified as the second product data; the data to be classified marked with low change frequency is classified as the first product data; wherein, the above-mentioned change frequency data table can be formulated according to the personalized configuration plan of the historical product data.
[0076] In this embodiment, by formulating a change frequency data table and classifying product data according to the mark of each type of data to be classified in the change frequency data table, first product data and second product data are obtained, which can make corresponding decisions for the subsequent data to be classified with different change frequencies, thereby improving data processing efficiency and reducing maintenance costs.
[0077] In this embodiment, product data is classified according to the change frequency of the data to be classified in the product data to obtain first product data and second product data, providing a decision basis for subsequent data storage and reading, improving data processing efficiency and reducing data maintenance costs.
[0078] Step 202: pre-build a first-level cache and a second-level cache, store the first product data in the first-level cache, and store the second product data in the second-level cache.
[0079] In this embodiment, a multi-level cache system is pre-built, and the multi-level cache system includes a first-level cache and a second-level cache. By classifying different levels of cache, data access efficiency and change frequency are optimized to ensure the real-time and availability of data; the first-level cache refers to Caffeine (Caffeine Cache Library), which is a high-performance Java local cache library improved from Guava, can provide fast read and write performance, support high concurrency scenarios, and Caffeine can support encryption to enhance data security and prevent unauthorized access and data leakage; the second-level cache refers to Redis (Remote Dictionary Server), which is an open source, memory-based key-value database that can support data persistence; the first product data classified in step S201 is stored in the first-level cache, and the second product data is stored in the second cache.
[0080] In one embodiment, storing the first product data in the first-level cache includes:
[0081] Encrypting the first product data using a preset encryption algorithm to obtain encrypted data;
[0082] Adding corresponding identification information to the encrypted data to obtain encrypted data with the identification;
[0083] The encrypted data with the identifier is stored in the first-level cache.
[0084] In this embodiment, the above-mentioned preset encryption algorithm includes a symmetric encryption algorithm (such as AES) or an asymmetric encryption algorithm (such as RSA). Taking the symmetric encryption algorithm as an example, the first product data is converted into an encryption format suitable for the symmetric encryption algorithm, and the first product data is encrypted using the symmetric encryption algorithm to obtain encrypted data. Corresponding identification information is added to the encrypted data to obtain encrypted data with identification information. The identification information includes but is not limited to the identification of the encryption algorithm, the version number of the key, etc.; after the encrypted data is generated, an expiration time is also set for the encrypted data. When the expiration time is reached, the encrypted data is updated. The specific updating method includes but is not limited to decrypting the encrypted data, and then re-encrypting the decrypted first product data through the symmetric encryption algorithm; the encrypted data with identification information is stored in the first-level cache.
[0085] In this embodiment, the first product data is encrypted by a preset encryption algorithm to increase the security of the first product data and prevent unauthorized access and data leakage; by adding corresponding identification information to the encrypted data, the correct decryption method and key can be identified during the decryption process, thereby improving the efficiency of extracting the first product data and thus improving the efficiency of data storage and acquisition.
[0086] In one embodiment, after storing the first product data in the first level cache and storing the second product data in the second level cache, the method further includes:
[0087] Regularly obtain the change frequency corresponding to each data in the first-level cache and the second-level cache;
[0088] The first-level cache and the second-level cache are updated according to the change frequencies corresponding to the respective data to obtain an updated first-level cache and an updated second-level cache.
[0089] In this embodiment, the change frequency of each data in the first-level cache and the second-level cache is obtained regularly (for example, every one month). When the data in the first-level cache does not meet the corresponding rules, the data in the first-level cache that does not meet the corresponding rules is extracted, and the extracted data is stored in the second-level cache. Similarly, when the data in the second-level cache does not meet the corresponding rules, the data in the second-level cache that does not meet the corresponding rules is extracted, and the extracted data is stored in the first-level cache to obtain an updated first-level cache and an updated second-level cache; wherein, the rule corresponding to the first-level cache is that the change frequency of the data in the first-level cache must be less than the preset change frequency threshold, and the rule corresponding to the second-level cache is that the change frequency of the data in the second-level cache must be greater than or equal to the preset change frequency threshold.
[0090] In this embodiment, since the data stored in the first-level cache is encrypted data, the encrypted data needs to be decrypted when extracted to obtain the decrypted data, and then the decrypted data is stored in the second-level cache. Similarly, the data extracted from the second-level cache also needs to be encrypted before it can be stored in the first-level cache.
[0091] In this embodiment, by periodically evaluating and adjusting the change frequency of data in the first-level cache and the second-level cache, cache resources can be used more effectively and the subsequent data access efficiency can be improved.
[0092] In this embodiment, by pre-building a first-level cache and a second-level cache, storing the first product data in the first-level cache, and storing the second product data in the second-level cache, the characteristics of different cache spaces are utilized to store corresponding data, which can improve the data reading and writing speed and system responsiveness, while reducing the burden on the system and ensuring data security.
[0093] Step 203: when receiving an access request from a user, determining whether the target data of the access request can be read from the first-level cache and the second-level cache according to the access request;
[0094] In this embodiment, in the existing method, the solution for reading the data corresponding to the user's access request is generally to directly retrieve from the database, obtain the data corresponding to the access request and feed it back to the user, resulting in a slow data reading efficiency;
[0095] Therefore, in this embodiment, when a user's access request is received, it is first determined whether the target data of the access request can be read from the first-level cache and the second-level cache according to the access request, so as to avoid the problem of slow data reading efficiency caused by retrieving from the database.
[0096] Step S204: If possible, read the target data of the access request from the first-level cache and the second-level cache according to the access request, and feed back the target data to the user.
[0097] In this embodiment, according to the data type of the access request, the target data corresponding to the access request is read from the first-level cache and the second-level cache in a cache priority manner or a simultaneous reading manner, and the target data is fed back to the user;
[0098] In one embodiment, reading the target data of the access request from the first-level cache and the second-level cache according to the access request, and feeding back the target data to the user, includes:
[0099] Parsing the access request to obtain a data type corresponding to the access request;
[0100] Determining whether a predefined change frequency data table can identify the change frequency corresponding to the data type;
[0101] When the predefined change frequency data table can identify the change frequency corresponding to the data type, according to the identification result, the target data of the access request is read from the first-level cache and the second-level cache in a cache priority manner, and the target data is fed back to the user;
[0102] When the predefined change frequency data table cannot identify the change frequency corresponding to the data type, the target data of the access request is read from the primary cache and the secondary cache in a simultaneous reading manner, and the target data is fed back to the user.
[0103] In this embodiment, the access request is parsed to obtain the data type corresponding to the access request, and it is determined whether the change frequency data table mentioned in step S201 can identify the change frequency corresponding to the data type. The specific determination method is to query whether there is a predefined mark for the data type. If so, it is determined that it can be identified, and if not, it is determined that it cannot be identified.
[0104] When the predefined change frequency data table can identify the change frequency corresponding to the data type, the data type is identified as high change frequency data or low change frequency data according to the judgment result, and the data corresponding to the access request is read in a cache priority manner; specifically, when the data type is low change frequency data, a structured query statement (such as an SQL query statement) is constructed according to the access request, and the structured query statement is used to preferentially read from the first-level cache. If the target data corresponding to the access request is read in the first-level cache, the target data is fed back to the user. If the target data corresponding to the access request cannot be read in the first-level cache, the target data corresponding to the access request is read from the second-level cache, and the access data is fed back to the user; when the data type is high change frequency data, a structured query statement (such as an SQL query statement) is constructed according to the access request, and the structured query statement is used to preferentially read from the second-level cache. If the target data corresponding to the access request is read in the second-level cache, the target data is fed back to the user. If the target data corresponding to the access request cannot be read in the second-level cache, the target data corresponding to the access request is read from the first-level cache, and the access data is fed back to the user.
[0105] When the predefined change frequency data table cannot identify the change frequency corresponding to the data type, a simultaneous reading method is used to read the data corresponding to the access request; specifically, a structured query statement (such as an SQL query statement) is constructed according to the access request, and according to the structured query statement, the target data corresponding to the access request is read from the first-level cache and the second-level cache at the same time, and the target data is fed back to the user.
[0106] In this embodiment, corresponding data is extracted from the corresponding cache to avoid directly extracting data from the database, thereby reducing access delays and improving data access efficiency. According to the data type of the access request, the corresponding extraction method is used for extraction, which can effectively utilize cache resources, maximize cache utilization efficiency, and improve data extraction efficiency corresponding to the access request.
[0107] In this embodiment, by extracting data corresponding to the access request from the cache, the burden on the database is reduced, data access efficiency is improved, and thus user waiting time is reduced, thereby improving user satisfaction.
[0108] Step 204: If not, read the target data corresponding to the access request from a preset database according to the access request, and feed back the target data to the user.
[0109] In this embodiment, when the target data corresponding to the access request cannot be read from the first-level cache and the second-level cache according to the access request, it indicates that the target data does not exist in both the first-level cache and the second-level cache. At this time, in order to ensure that the user can still obtain the target information corresponding to the access request when the cache cannot find the data, the target data corresponding to the access request is read from the preset database according to the structured query statement (such as an SQL query statement) constructed in step S203, and the target data is fed back to the user, wherein the above-mentioned preset database refers to a database pre-configured by the system for storing all data.
[0110] In one embodiment, after reading the target data corresponding to the access request from a preset database according to the access request, the method further includes:
[0111] After the target data corresponding to the access request is read from the preset database, the target data is stored in the first-level cache or the second-level cache according to a preset cache strategy.
[0112] In this embodiment, after the target data corresponding to the access request is read from the preset database, the target data is stored in the first-level cache or the second-level cache according to the preset cache strategy. Specifically, it is determined whether the pre-defined change frequency data table can identify the change frequency corresponding to the target data. If so, it is stored in the corresponding first-level cache or second-level cache according to the identification result. If the change frequency corresponding to the target data cannot be identified by the pre-defined change frequency data table, the target data is determined to be low change frequency data, and the target data is stored in the first-level cache.
[0113] In this embodiment, the target data read from the preset database is stored in the cache data to avoid the next access request to read from the preset database, resulting in a slower reading speed. The target data is stored in the first-level cache or the second-level cache through the preset cache strategy, which ensures that the access request can hit the cache and improves data reading efficiency.
[0114] In this embodiment, when the access request cannot read the corresponding target data from the cache, data is read from the preset database to ensure that the access request proposed by the user can receive the corresponding data.
[0115] It should be emphasized that in order to further ensure the privacy and security of the storage and reading results of the above-mentioned multi-level data, the storage and reading results of the above-mentioned multi-level data can also be stored in a node of a blockchain.
[0116] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block 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.
[0117] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0118] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0119] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0120] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0121] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a multi-level data storage and reading device, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the apparatus can be specifically applied to various computer devices.
[0122] like Figure 3 As shown, the multi-level data storage and reading device 300 described in this embodiment includes: a classification module 301, a storage module 302, a judgment module 303, a first feedback module 304, and a second feedback module 305. Among them:
[0123] A classification module 301 is used to obtain multi-level nested product data, classify the product data according to the change frequency of the product data, and obtain first product data and second product data;
[0124] In one embodiment, the classification module 301 includes:
[0125] A quantity acquisition submodule, used to acquire the number of historical changes of each type of data to be classified in the product data in the first preset time period;
[0126] A calculation submodule, configured to calculate a historical change frequency corresponding to each type of the data to be classified according to the number of historical changes of each type of the data to be classified and the first preset time period;
[0127] The first classification submodule is used to classify the product data according to the historical change frequency of each type of data to be classified to obtain the first product data and the second product data.
[0128] In one embodiment, the classification module 301 includes:
[0129] an identification submodule, for identifying high-change frequency data and low-change frequency data in the product data according to a predefined change frequency data table;
[0130] A second classification submodule, configured to classify the low-change frequency data of the product data as the first product data;
[0131] The third classification submodule is used to classify the high-change frequency data of the product data as the second product data.
[0132] The storage module 302 is used to pre-build a first-level cache and a second-level cache, store the first product data in the first-level cache, and store the second product data in the second-level cache;
[0133] In one embodiment, the storage module 302 includes:
[0134] An encryption submodule, used to encrypt the first product data using a preset encryption algorithm to obtain encrypted data;
[0135] An adding submodule, used for adding corresponding identification information to the encrypted data to obtain encrypted data with the identification;
[0136] The storage submodule is used to store the encrypted data with the identifier in the first-level cache.
[0137] In one embodiment, the storage module 302 further includes:
[0138] A frequency acquisition submodule, used for periodically acquiring the change frequency corresponding to each data in the first-level cache and the second-level cache;
[0139] The updating submodule is used to update the first-level cache and the second-level cache according to the change frequency corresponding to each data to obtain an updated first-level cache and an updated second-level cache.
[0140] The judgment module 303 is used to judge whether the target data of the access request can be read from the first-level cache and the second-level cache according to the access request when receiving the access request of the user.
[0141] A first feedback module 304 is configured to read target data of the access request from the first-level cache and the second-level cache according to the access request, and feed back the target data to the user if possible;
[0142] In one embodiment, the first feedback module 304 includes:
[0143] A parsing submodule, used to parse the access request to obtain a data type corresponding to the access request;
[0144] A determination submodule, used to determine whether a predefined change frequency data table can identify the change frequency corresponding to the data type;
[0145] A first feedback submodule is configured to, when the predefined change frequency data table can identify the change frequency corresponding to the data type, read the target data of the access request from the first-level cache and the second-level cache in a cache priority manner according to the identification result, and feed back the target data to the user;
[0146] The second feedback submodule is used to read the target data of the access request from the first-level cache and the second-level cache in a simultaneous reading manner when the pre-defined change frequency data table cannot identify the change frequency corresponding to the data type, and feed back the target data to the user.
[0147] The second feedback module 305 is configured to, if not possible, read the target data corresponding to the access request from a preset database according to the access request, and feed back the target data to the user.
[0148] In one embodiment, the apparatus further comprises:
[0149] The cache module is used to store the target data corresponding to the access request in the first-level cache or the second-level cache according to a preset cache strategy after reading the target data corresponding to the access request from the preset database.
[0150] In order to solve the above technical problems, the present application embodiment also provides a device (computer device). Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0151] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 4 with a memory 41, a processor 42, and a network interface 43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0152] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0153] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions for storage and reading methods of multi-level data. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.
[0154] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the multi-level data storage and reading method.
[0155] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
[0156] During the implementation of the electronic device of the present application, the product data is classified according to the change frequency of the data to be classified in the product data, and the first product data and the second product data are obtained, which provides a decision basis for the storage and reading of subsequent data, improves the efficiency of data processing and reduces the cost of data maintenance;
[0157] By pre-building a first-level cache and a second-level cache, storing the first product data in the first-level cache, and storing the second product data in the second-level cache, using the characteristics of different cache spaces to store corresponding data, the data reading and writing speed and system responsiveness can be improved, while reducing the burden on the system and ensuring data security;
[0158] By extracting the data corresponding to the access request from the cache, the burden on the database is reduced, data access is improved, and the user's waiting time is reduced, thereby improving user satisfaction;
[0159] When the access request cannot read the corresponding target data from the cache, the data is read from the preset database to ensure that the access request made by the user can receive the corresponding data.
[0160] The present application also provides another embodiment, namely, providing a storage medium (computer-readable storage medium), wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the multi-level data storage and reading method as described above.
[0161] During the implementation of the computer-readable storage medium of the present application, the product data is classified according to the change frequency of the data to be classified in the product data, and the first product data and the second product data are obtained, so as to provide a decision basis for the storage and reading of subsequent data, improve the efficiency of data processing and reduce the cost of data maintenance;
[0162] By pre-building a first-level cache and a second-level cache, storing the first product data in the first-level cache, and storing the second product data in the second-level cache, using the characteristics of different cache spaces to store corresponding data, the data reading and writing speed and system responsiveness can be improved, while reducing the burden on the system and ensuring data security;
[0163] By extracting the data corresponding to the access request from the cache, the burden on the database is reduced, data access is improved, and the user's waiting time is reduced, thereby improving user satisfaction;
[0164] When the access request cannot read the corresponding target data from the cache, the data is read from the preset database to ensure that the access request made by the user can receive the corresponding data.
[0165] The non-Company software tools or components appearing in the embodiments of this application are merely examples and do not represent actual use.
[0166] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0167] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A method for storing and reading multi-level data, characterized in that: The steps include: Acquire multi-level nested product data, classify the product data according to the change frequency of the product data, and obtain first product data and second product data; Pre-building a first-level cache and a second-level cache, storing the first product data in the first-level cache, and storing the second product data in the second-level cache; When receiving an access request from a user, determining whether target data of the access request can be read from the first-level cache and the second-level cache according to the access request; If yes, reading the target data of the access request from the first-level cache and the second-level cache according to the access request, and feeding back the target data to the user; If not, the target data corresponding to the access request is read from a preset database according to the access request, and the target data is fed back to the user.
2. The method for storing and reading multi-level data according to claim 1, characterized in that: The classifying the product data according to the change frequency of the product data to obtain the first product data and the second product data includes: Obtaining the historical change count of each type of data to be classified in the product data in the first preset time period; Calculating the historical change frequency corresponding to each type of the data to be classified according to the number of historical changes of each type of the data to be classified and the first preset time period; The product data is classified according to the historical change frequency of each type of the data to be classified to obtain the first product data and the second product data.
3. The method for storing and reading multi-level data according to claim 1, characterized in that: The classifying the product data according to the change frequency of the product data to obtain the first product data and the second product data includes: According to a predefined change frequency data table, identifying high change frequency data and low change frequency data in the product data; classifying the low-change frequency data of the product data as the first product data; The high-change-frequency data of the product data is classified as the second product data.
4. The method for storing and reading multi-level data according to claim 1, wherein: The storing the first product data in the first-level cache includes: Encrypting the first product data using a preset encryption algorithm to obtain encrypted data; Adding corresponding identification information to the encrypted data to obtain encrypted data with the identification; The encrypted data with the identifier is stored in the first-level cache.
5. The method for storing and reading multi-level data according to claim 1, characterized in that: After storing the first product data in the first level cache and storing the second product data in the second level cache, the method further includes: Regularly obtain the change frequency corresponding to each data in the first-level cache and the second-level cache; The first-level cache and the second-level cache are updated according to the change frequencies corresponding to the respective data to obtain an updated first-level cache and an updated second-level cache.
6. The method for storing and reading multi-level data according to claim 1, wherein: The step of reading target data of the access request from the first-level cache and the second-level cache according to the access request, and feeding back the target data to the user includes: Parsing the access request to obtain a data type corresponding to the access request; Determining whether a predefined change frequency data table can identify the change frequency corresponding to the data type; When the predefined change frequency data table can identify the change frequency corresponding to the data type, according to the identification result, the target data of the access request is read from the first-level cache and the second-level cache in a cache priority manner, and the target data is fed back to the user; When the predefined change frequency data table cannot identify the change frequency corresponding to the data type, the target data of the access request is read from the primary cache and the secondary cache in a simultaneous reading manner, and the target data is fed back to the user.
7. The method for storing and reading multi-level data according to claim 1, characterized in that: After reading the target data corresponding to the access request from a preset database according to the access request, the method further includes: After the target data corresponding to the access request is read from the preset database, the target data is stored in the first-level cache or the second-level cache according to a preset cache strategy.
8. A multi-level data storage and reading device, characterized in that: The device comprises: A classification module, used to obtain multi-level nested product data, classify the product data according to the change frequency of the product data, and obtain first product data and second product data; A storage module, used to pre-build a first-level cache and a second-level cache, store the first product data in the first-level cache, and store the second product data in the second-level cache; A judgment module, configured to judge, when receiving an access request from a user, whether the target data of the access request can be read from the first-level cache and the second-level cache according to the access request; A first feedback module, configured to read target data of the access request from the first-level cache and the second-level cache according to the access request, and feed back the target data to the user if possible; The second feedback module is used for, if not, reading the target data corresponding to the access request from a preset database according to the access request, and feeding back the target data to the user.
9. A computer device, characterized in that: The computer device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the multi-level data storage and reading method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for storing and reading multi-level data as claimed in any one of claims 1 to 7 is implemented.