A method for implementing component analysis based on Redis
By using Redis cache components to analyze data in component analysis method, the frequent database access problems caused by real-time data storage in the prior art are solved, and more efficient data processing and system reliability are achieved.
Patent Information
- Application Number
- CN202310794368.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2043-06-30
AI Technical Summary
In the prior art, real-time data entry into the data of each step obtained by component analysis method will lead to excessive frequent database access and affect the normal access of other users; at the same time, when the amount of data is large, the browser cache may cause crashes, and may exceed the maximum http limit, and require high network broadband.
The component analysis implementation method based on Redis is adopted. By cached the data of each step of the component analysis method into Redis in batches, and extracted the data from the cache according to the component id for batch entry, avoiding frequent access to the database. At the same time, when engineers need to query database data, they query and cache it in Redis at one time through component id to reduce access to the database.
By cached data to Redis in batches, frequent access to the database is reduced, impacted on other users is avoided, network bandwidth needs are reduced, and system reliability and performance are improved.
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial software, and particularly to a method for implementing component analysis based on Redis. Background Art
[0002] When engineers use the component analysis method for product R & D, the steps of the component analysis method are numerous and the data volume is relatively large. The component analysis method disassembles the components of each system, selects the component objects to be analyzed, obtains the corresponding component relationship table, scores the functions of each component in the component relationship table, obtains the component function score list, filters out the harmful components according to the scores in the component function score list, generates the harmful component list, obtains the landing table data and specific solutions according to the harmful function component list, and finally generates the landing table data list and solution list.
[0003] In the prior art, the method of saving the data of each step obtained by the component analysis method has the following disadvantages:
[0004] If the data of each step is stored in the database in real time, it will cause the database to be accessed too frequently, affecting the normal access of other users;
[0005] If the data of each step is cached in the browser, the browser is likely to crash when the data volume is too large. Finally, if all the step data is transmitted to the backend together, it may exceed the http maximum limit and at the same time has high requirements for network bandwidth; Summary of the Invention
[0006] The purpose of the present invention is to solve the deficiencies existing in the prior art, and to propose a method for implementing component analysis based on Redis.
[0007] To achieve the above purpose, the present invention adopts the following technical solutions:
[0008] A method for implementing component analysis based on Redis includes the following steps:
[0009] S1: Cache the data of each step obtained by the component analysis method in batches into Redis;
[0010] It includes the following sub-steps:
[0011] S11: Cache the data in the component list into Redis;
[0012] Engineers disassemble the components of the products and systems under R & D through the component analysis method, and save the obtained components into the component list;
[0013] The component list contains component ids; the component ids are unique;
[0014] It includes the following sub-steps:
[0015] S111: The engineer verifies the data in the component list;
[0016] Check whether the component list is empty, check whether there is empty data in the rows other than the last row in the component list, and check whether there is duplicate data in the component list;
[0017] Verify the data in the component list through the HibernateValidator verification framework. If it is verified that the component list is empty or there is empty data in the rows other than the last row in the component list, a prompt is given and the engineer makes modifications. After the modifications are completed, verification is performed again until the verification passes;
[0018] If it is verified that there is duplicate data in the component list, a modification prompt is given and the engineer makes modifications. After the modifications are completed, verification is performed again until the verification passes;
[0019] S112: Compare the component list with the existing data in Redis;
[0020] The engineer obtains the type of the existing data in Redis according to the key of Redis, retrieves the existing data in Redis through the get component, and compares the existing data in Redis with the components in the component list through the HibernateValidator verification framework. If the existing data in Redis is exactly the same as the components in the component list, no processing is performed; if the existing data in Redis is not exactly the same as the components in the component list, the existing data in Redis is cleared and the component data in the component list is cached in Redis;
[0021] S12: Cache the data in the component relationship table into Redis;
[0022] The engineer obtains the corresponding component relationship according to the component list through the component analysis method to obtain the component relationship table, and the component relationship table includes the component id and the corresponding relationship between components;
[0023] It includes the following sub-steps:
[0024] S121: The engineer verifies the data in the component relationship table;
[0025] Verify whether the component relationship table is empty;
[0026] Verify whether the component relationship table is empty through the HibernateValidator verification framework. If it is verified that the component relationship table is empty, a prompt is given and the engineer makes modifications. After the modifications are completed, verification is performed again until the verification passes;
[0027] If it is not empty, directly proceed to step S122;
[0028] S122: Save the data into Redis;
[0029] Cache the data in the verified component relationship table into Redis;
[0030] S13: Cache the data in the component function score list into Redis;
[0031] Engineers generate a component function score list based on the component relationship table through component analysis;
[0032] The component function score list includes component id, component function description, component function score, performance level, etc.;
[0033] Engineers set each item in the component function score list as a required item and a non-required item according to actual needs;
[0034] It includes the following sub-steps:
[0035] S131: Verify the component function score list;
[0036] Use the HibernateValidator verification framework to verify whether all the required items in the component function score list are filled. If not, give a prompt and let the engineer modify it. After the modification is completed, verify again until the verification passes;
[0037] If it is satisfied, directly proceed to step S132;
[0038] S132: Cache the data into Redis;
[0039] Save the verified component function score list data into Redis;
[0040] S14: Obtain the harmful function component and landing point table data based on the component function score list;
[0041] Engineers obtain beneficial function components and harmful function components based on the scores corresponding to the components;
[0042] Screen out the harmful function components in the component function score list, convert them into landing point table data through component analysis, and save this data;
[0043] S15: Cache the solution list into Redis;
[0044] Obtain the specific solution list based on the landing point table data through component analysis;
[0045] The solution list includes harmful component id, component function description, component function score, specific solution, etc.;
[0046] Engineers set each item in the solution list as a required item and a non-required item according to actual needs;
[0047] Use the HibernateValidator verification framework to verify whether all required items in the solution list are filled. If not, give a prompt and let the engineer make modifications. After the modifications are completed, verify again until the verification passes;
[0048] If the verification is correct, cache the data in the solution list into Redis;
[0049] S2: Save the data in Redis to the database;
[0050] Call the RedisTemplate component to retrieve the data in each list containing the component ID from the cache according to the component ID, and encapsulate the data retrieved from the same list into a List;
[0051] The data in one list is encapsulated into a List;
[0052] Call the saveBatch interface of the mybatisplus tool to implement batch storage of each List into the database;
[0053] The above-mentioned each list includes a component list, a component relationship table, a component function scoring list, and a solution list;
[0054] S3: View the data in the database;
[0055] When an engineer needs to query relevant component information, according to the component ID, all data related to the component ID is retrieved from the database at one time, and the retrieved data is cached into Redis to avoid multiple accesses to the database.
[0056] Compared with the prior art, the beneficial effects of the present invention are:
[0057] The method for implementing component analysis based on Redis proposed by the present invention caches the data of each step of the component analysis method into Redis in batches, retrieves the data in each list containing the component ID from the cache according to the component ID, and performs batch storage into the database; when an engineer needs to query the data in the database, according to the component ID, all list data is retrieved from the database at one time, and the list data is cached into Redis to avoid multiple accesses to the database, solving the problem that accessing the database is too frequent and affecting the normal access of other users, and improving the system reliability;
[0058] By caching the data of each step obtained by the component analysis method into Redis, the network transmission volume is reduced, and the requirement for network bandwidth is lowered. Embodiment
[0059] To further understand the purpose, structure, features and functions of the present invention, the following is a detailed description in conjunction with embodiments.
[0060] A method for implementing component analysis based on Redis includes the following steps:
[0061] S1: Cache the data of each step obtained by the component analysis method in batches into Redis;
[0062] It includes the following sub-steps:
[0063] S11: Cache the data in the component list into Redis;
[0064] Engineers disassemble the components of the developed products and systems through the component analysis method, and save the obtained components into the component list;
[0065] The component list contains component IDs; the component IDs are unique;
[0066] It includes the following sub-steps:
[0067] S111: Engineers verify the data in the component list;
[0068] Check whether the component list is empty, check whether there is empty data in the rows other than the last row in the component list, and check whether there are duplicate data in the component list;
[0069] Define a verification function that meets the verification requirements in the HibernateValidator verification framework, and use this verification function and related annotations to verify the data in the component list. If it is verified that the component list is empty or there is empty data in the rows other than the last row in the component list, a prompt will be given and the engineer will make modifications. After the modifications are completed, verify again until the verification passes;
[0070] If it is verified that there are duplicate data in the component list, a modification prompt will be given and the engineer will make modifications. After the modifications are completed, verify again until the verification passes;
[0071] S112: Compare the component list with the existing data in Redis;
[0072] The engineer obtains the type of existing data in Redis based on the key of Redis, retrieves the existing data in Redis through the get component, and compares the existing data in Redis with the components in the component list through the HibernateValidator verification framework. If the existing data in Redis is exactly the same as the components in the component list, the expiration duration is directly set; if the existing data in Redis is not exactly the same as the components in the component list, the existing data in Redis is cleared, and the component data in the component list is cached in Redis;
[0073] By setting the expiration duration, the data in the Redis cache is automatically cleared when it expires, improving memory utilization and avoiding data accumulation;
[0074] S12: Cache the data in the component relationship table in Redis;
[0075] The engineer obtains the corresponding component relationship according to the component list through the component analysis method to obtain a component relationship table, and the component relationship table includes component IDs and the corresponding relationships between components;
[0076] It includes the following sub-steps:
[0077] S121: The engineer verifies the data in the component relationship table;
[0078] Verify whether the component relationship table is empty;
[0079] By defining a verification function that meets the verification requirements in the HibernateValidator verification framework, use this verification function and related annotations to verify whether the component relationship table is empty. If the component relationship table is verified to be empty, a prompt is given and the engineer makes modifications. After the modifications are completed, verify again until the verification passes;
[0080] If it is not empty, directly proceed to step S122;
[0081] S122: Save the data to Redis;
[0082] Cache the data in the verified component relationship table in Redis and set the expiration duration;
[0083] S13: Cache the data in the component function score list in Redis;
[0084] The engineer generates a component function score list according to the component relationship table through the component analysis method;
[0085] The component function score list includes component IDs, component function descriptions, component function scores, performance levels, etc.;
[0086] Engineers set each item in the component function score list as a required item and a non-required item according to actual requirements;
[0087] It includes the following sub-steps:
[0088] S131: Verify the component function score list;
[0089] Verify the required items in the function score list;
[0090] By defining a verification function that meets the verification requirements in the Hibernate Validator verification framework, use this verification function and the relevant annotation verification framework to verify whether all the required items in the function score list are filled. If not, give a prompt and let the engineer make modifications. After the modification is completed, verify again until the verification passes;
[0091] If it is satisfied, directly proceed to step S132;
[0092] S132: Cache the data into Redis;
[0093] Save the verified component function score list data into Redis and set the expiration duration;
[0094] S14: Obtain the harmful function component and the landing point table data according to the component function score list;
[0095] Engineers obtain the beneficial function components and harmful function components according to the scores corresponding to the components;
[0096] Screen out the harmful function components in the component function score list, convert them into landing point table data through the component analysis method, and save this data;
[0097] S15: Cache the solution list into Redis;
[0098] Obtain the specific solution list according to the landing point table data through the component analysis method;
[0099] The solution list includes harmful component IDs, component function descriptions, component function scores, specific solutions, etc.;
[0100] Engineers set each item in the solution list as a required item and a non-required item according to actual requirements;
[0101] Verify the required items in the solution list;
[0102] The solution list includes required items and non-required items;
[0103] By defining a verification function that meets the verification requirements in the Hibernate Validator verification framework, use this verification function and relevant annotations to verify whether the required items in the verification framework verification scheme list are all filled. If not, give a prompt for the engineer to modify. After the modification is completed, verify again until the verification passes;
[0104] If the verification is correct, cache the data in the scheme list into Redis and set the expiration duration;
[0105] S2: Save the data in Redis to the database;
[0106] Call the RedisTemplate component to retrieve the data in each list containing the component id from the cache according to the component id, and encapsulate the data retrieved from the same list into a List;
[0107] The data in one list is encapsulated into a List;
[0108] Call the saveBatch interface of the mybatisplus tool to implement batch storage of each List;
[0109] The above-mentioned each list includes a component list, a component relationship table, a component function scoring list, and a scheme list;
[0110] S3: View the data in the database;
[0111] When an engineer needs to query relevant component information, according to the component id, query all the data related to the component id in the database at one time, and cache the queried data into Redis to avoid multiple accesses to the database.
[0112] The present invention has been described by the above related embodiments. However, the above embodiments are only examples for implementing the present invention. It must be pointed out that the disclosed embodiments do not limit the scope of the present invention. On the contrary, modifications and refinements made without departing from the spirit and scope of the present invention fall within the scope of patent protection of the present invention.
Claims
1. A method for implementing component analysis based on Redis, characterized in that: It includes the following steps: S1: Cache the data of each step obtained by the component analysis method into Redis in batches; It includes the following sub-steps: S11: Cache the data in the component list into Redis; Engineers disassemble the components of the developed products and systems through the component analysis method, and save the obtained components into the component list; The component list contains component IDs; the component IDs are unique; Engineers verify the data in the component list. After verification, compare the component list with the existing data in Redis. If the existing data in Redis is exactly the same as the components in the component list, no processing is done; if the existing data in Redis is not exactly the same as the components in the component list, clear the existing data in Redis and cache the component data in the component list into Redis; S12: Cache the data in the component relationship table into Redis; Engineers obtain the corresponding component relationships according to the component list through the component analysis method to obtain the component relationship table, and the component relationship table includes component IDs and the corresponding relationships between components; Engineers verify the data in the component relationship table; If the verification fails, modify the data in the component relationship table until the verification passes. After the verification passes, cache the data in the component relationship table into Redis; S13: Cache the data in the component function score list into Redis; Engineers generate a component function score list according to the component relationship table through the component analysis method; The component function score list includes component ID, component function description, component function score value, and performance level; Engineers set each item in the component function score list as a required item and a non-required item according to actual needs; Verify whether all the required items in the component function score list are filled. If not, give a prompt and the engineer makes modifications. After the modifications are completed, verify again until the verification passes; after the verification passes, cache the data in the component relationship table into Redis; S14: Obtain the data of harmful function components and the landing point table according to the component function score list; Engineers obtain beneficial function components and harmful function components according to the scores corresponding to the components; Screen out the harmful function components in the component function score list, convert them into the data of the landing point table through the component analysis method, and save this data; S15: Cache the solution list into Redis; Obtain the specific solution list according to the data of the landing point table through the component analysis method; The solution list includes harmful component ID, component function description, component function score value, and specific solution; Engineers set each item in the solution list as a required item and a non-required item according to actual needs; Verify whether all the required items in the solution list are filled through the HibernateValidator verification framework. If not, give a prompt and the engineer makes modifications. After the modifications are completed, verify again until the verification passes; If the verification is correct, cache the data in the solution list into Redis; Each of the above lists includes a component list, a component relationship table, a component function scoring list, and a solution list; S2: Save the data in Redis to the database; Call the RedisTemplate component to retrieve the data in each list containing the component ID from the cache respectively, and encapsulate the data retrieved from the same list into a List; The data in one list is encapsulated into a List; Call the saveBatch interface of the mybatisplus tool to implement batch storage of each List into the database; Each of the above lists includes a component list, a component relationship table, a component function scoring list, and a solution list; S3: View the data in the database; When an engineer needs to query relevant component information, according to the component ID, all the data related to the component ID is retrieved from the database at one time, and the retrieved data is cached in Redis.
2. A method for implementing component analysis based on Redis as described in claim 1, characterized in that: In step S11, the following sub-steps are included: S111: The engineer verifies the data in the component list; Check whether the component list is empty, check whether there is empty data in the rows other than the last row in the component list, and check whether there is duplicate data in the component list; Verify the data in the component list through the HibernateValidator verification framework. If it is verified that the component list is empty or there is empty data in the rows other than the last row in the component list, a prompt is given and the engineer makes modifications. After the modifications are completed, verification is performed again until the verification passes; If it is verified that there is duplicate data in the component list, a modification prompt is given and the engineer makes modifications. After the modifications are completed, verification is performed again until the verification passes; S112: Compare the component list with the existing data in Redis; The engineer obtains the type of the existing data in Redis according to the key of Redis, retrieves the existing data in Redis through the get component, and compares the existing data in Redis with the components in the component list through the HibernateValidator verification framework. If the existing data in Redis is exactly the same as the components in the component list, no processing is done; if the existing data in Redis is not exactly the same as the components in the component list, the existing data in Redis is cleared, and the component data in the component list is cached in Redis.
3. A method for implementing component analysis based on Redis as described in claim 1, characterized in that: In step S12, the following sub-steps are included: S121: The engineer verifies the data in the component relationship table; Verify whether the component relationship table is empty; Verify whether the component relationship table is empty through the HibernateValidator verification framework. If it is verified that the component relationship table is empty, a prompt is given and the engineer makes modifications. After the modifications are completed, verification is performed again until the verification passes; If it is not empty, directly proceed to step S122; S122: Save the data to Redis; Cache the data in the verified component relationship table into Redis.
4. A method for implementing component analysis based on Redis as described in claim 1, characterized in that: In step S13, it includes the following sub-steps: S131: Verify the component function score list; Verify the required fields in the function score list; Use the HibernateValidator verification framework to verify whether all the required fields in the function score list are filled. If not, give a prompt and let the engineer modify it. After the modification is completed, verify again until the verification passes; If it is satisfied, directly proceed to step S132; S132: Cache the data into Redis; Save the data in the verified component function score list into Redis.
5. A method for implementing component analysis based on Redis as described in claim 1, characterized in that: Furthermore, after caching the data in each list into Redis, set the data expiration duration; the said each list includes the component list, the component relationship table, the component function score list, and the solution list.
Citation Information
Patent Citations
Streaming data real-time processing method and system based on multi-level cache structure
CN106959928A
Sales locking method and system based on caching
CN111752957A