A cache file update method based on quantum secure communication network
By using Redis database to manage cache files in quantum confidential communication networks, combining quantum key encryption and weight value calculation, the problem of single cache file update method is solved, and efficient and secure cache file management is achieved.
Patent Information
- Application Number
- CN202211184423.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-27
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2042-09-27
AI Technical Summary
In the prior art, the cached file update method is single, resulting in low efficiency and low security for users to find files, failing to effectively utilize the access frequency and time characteristics of cached files, and lacking encryption processing.
The cache file update method based on the quantum confidential communication network is adopted, cache files are managed through the Redis database, the files are encrypted using the quantum key, and the weight value of the file is calculated based on the number of accesses and time, and the end cache files are eliminated to improve search efficiency and security.
Improve the search speed and accuracy of cached files, reduce resource usage, enhance the security of cached files, and improve the security of file reading through quantum key encryption.
Smart Images

Figure CN117235081B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum secure communication networks, and in particular to a cache file updating method based on quantum secure communication networks. Background Art
[0002] Quantum networks and quantum communications are the future direction of industrial applications and technological development. Cache is a temporary storage device located between the CPU and main memory. It has a smaller capacity than main memory but a faster exchange rate. Cache stores frequently used or soon-to-be-used files or data. When users access these files or data through a client, they can retrieve them from the cache, which is faster than accessing from main memory or a hard drive. When the CPU accesses large amounts of files or data, it can bypass main memory and access them directly from the cache, speeding up data access.
[0003] In the existing technical solutions, cached files are generally the files with the most browsing times. Files that have been accessed by users once are not cached, which limits the file types in the cache. When the cached files need to be updated, the method adopted is to determine whether the file expiration time has exceeded and delete the expired files. However, this cache file processing method is too simple, resulting in low reading efficiency when users search for files in the cache, and the files are not encrypted, making the cached files less secure.
[0004] Therefore, the deficiencies in the prior art need to be improved. Summary of the Invention
[0005] The purpose of the present invention is to overcome the defects of the existing technology and to solve the problem of updating cache files. A cache file updating method based on a quantum secure communication network is proposed.
[0006] The method of the present invention is achieved through the following technical solutions:
[0007] A cache file update method based on a quantum secure communication network, the method comprises the following steps:
[0008] Step 1: Create a Redis database and configure parameters;
[0009] The parameters include at least a maximum cache capacity;
[0010] Step 2: The client accesses the target file through the Redis database;
[0011] If the target file does not exist in the Redis database, jump to step 3;
[0012] If the target file exists in the Redis database, jump to step 8;
[0013] Step 3: The file processing module encrypts the target file using a quantum key;
[0014] Step 4: The file processing module records the current access count and access timestamp of the target file and stores the access count and access time in the ordered set click_zse and the ordered set time_zset respectively;
[0015] Step 5: The weight calculation module obtains the sorting number of the target file in the ordered set click_zse and the ordered set time_zset respectively, calculates the weight value of the target file and stores it in the weight array W[].
[0016] Step 6: The sorting module sorts the weight array W[] obtained in step 5 in descending order;
[0017] Step 7: The judgment module determines whether the number of cached files in the Redis database has reached the maximum cache capacity;
[0018] If the maximum cache capacity is reached, the cache file at the end of the weight array W[] is deleted by the deletion module, and the file processing module sends the target file to the Redis database;
[0019] If the maximum cache size is not reached, the file processing module sends the target file to the Redis database;
[0020] Step 8: The client obtains the quantum key of the target file through the Redis database, and decrypts the target file according to the quantum key to obtain the file information.
[0021] Furthermore, the parameters also include at least a monitoring IP, a port, and a connection password.
[0022] Furthermore, the steps of step 3 are as follows:
[0023] Step 3-1: The quantum key distribution device QKD generates a first quantum key and a second quantum key and distributes them to the file processing module in the background management center;
[0024] Step 3-2: The file processing module encrypts the target file according to the first quantum key; and stores the second quantum key in the Redis database.
[0025] Furthermore, the steps for calculating the weight value by the weight calculation module in step 5 are as follows:
[0026] Step 5-1: The weight calculation module obtains the sorting number c of the target file in the ordered set click_zset and the sorting number t of the ordered set time_zset respectively;
[0027] Step 5-2: Obtain the access timestamp of the target file based on the sort number t of the ordered set time_zset, and calculate the difference Δh between the access timestamp of the target file and the current system time T. Calculate the time coefficient Δt based on the value of Δh;
[0028] Step 5-3: Calculate the weight value W of the target file and store it in the weight array W[];
[0029] The weight value W is calculated as follows:
[0030]
[0031] Among them, c is the sorting number of the ordered set click_zse, t is the sorting number of the ordered set time_zset, and Δt is the time coefficient.
[0032] Furthermore, the rule for obtaining the time coefficient Δt in step 5-2 is:
[0033] When Δh≤72h, the time coefficient Δt=0.3; when 72h<Δh≤120h, the time coefficient Δt=0.7;
[0034] When 120h<Δh≤168h, the time coefficient Δt=1.
[0035] Furthermore, the method further includes step A of periodically deleting cache files, and step A is as follows:
[0036] Step A-1: Calculate the weight average of the weight array W[] through the file processing module;
[0037] Step A-2: Delete cache files whose weight values are less than the average weight value.
[0038] Furthermore, the time period H of the step A of periodically deleting cache files ranges from 6 to 10 days.
[0039] The beneficial effects of the present invention are:
[0040] The method disclosed in the present invention caches files accessed by users in a Redis database for a long time to improve the speed at which users search and read cached files, calculates the cache weight value of the file by the number of times the cached file is accessed and the time coefficient, and adopts a method of sorting the cache weight values of the files to eliminate the cached files at the end to improve the accuracy of judging hot cache files and the efficiency of users searching for cached files; the method disclosed in the present invention also improves the security of cached file reading by encrypting the cached files with quantum keys. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1This is a system principle block diagram of the present invention;
[0042] Figure 2 Flow chart of the method of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the embodiments, but the scope of protection claimed in the present invention is not limited to the following specific embodiments.
[0044] A cache file update method based on quantum secure communication network. The application of this method is based on a cache file update system based on quantum secure communication network. Therefore, the system is introduced first. Figure 1 As shown, a cache file update system based on a quantum secure communication network includes a client, a background management center, a Redis database, and a quantum key distribution device QKD; specifically, the client, the background management center, and the quantum key distribution device QKD are respectively connected to the Redis database via electrical signals;
[0045] The backend management center includes a file processing module, a weight calculation module, a sorting module, a judgment module and a deletion module;
[0046] The file processing module, weight calculation module, sorting module, judgment module and deletion module are connected in sequence via electrical signals, and the deletion module is also connected to the Redis database via electrical signals;
[0047] The client is used to search the Redis database for the target file;
[0048] The Redis database is used to store cache files;
[0049] The quantum key distribution device QKD is used to generate quantum keys;
[0050] The file processing module is used to obtain, encrypt and send the target file;
[0051] The weight calculation module is used to calculate the weight value of the target file;
[0052] The sorting module is used to sort the weight values of all files in the Redis database;
[0053] The judgment module is used to judge the maximum cache capacity in the Redis database;
[0054] The deletion module is used to delete the cache file with the lowest weight value in the Redis database according to the result fed back by the judgment module.
[0055] Specifically, the specific method scheme of this embodiment is as follows:
[0056] A cache file update method based on quantum secure communication network, such as Figure 2 As shown, the method applies the above-mentioned cache file update system based on quantum secure communication network, and the steps of the method are as follows:
[0057] Step 1: After setting up a Redis database and configuring its parameters, enable the Redis service. The Redis database is a key-value storage system that supports stored value types, including string, list, set, and zset. It is also a network-based, memory-based, and persistent log-type database, and provides APIs in multiple languages.
[0058] Specifically, the parameters include at least the maximum cache capacity listening IP, port and connection password;
[0059] Step 2: The client searches for the target file in the Redis database using the target file name as the key;
[0060] If the target file does not exist in the Redis database, jump to step 3;
[0061] If the target file exists in the Redis database, jump to step 8 to determine whether the target file is updated;
[0062] Step 3: If the target file does not exist in the Redis database, the target file needs to be stored in the Redis database first, and the target file is first encrypted, that is, the quantum key distribution device QKD is enabled to generate the first quantum key and the second quantum key, and the two generated quantum keys are distributed to the file processing module in the background management center;
[0063] Specifically, the steps of step 3 are as follows:
[0064] Step 3-1: A quantum key distribution device (QKD) generates a first quantum key and a second quantum key and distributes them to a file processing module in a backend management center; wherein the first quantum key and the second quantum key are identical;
[0065] Step 3-2: The file processing module encrypts the target file according to the first quantum key; and stores the second quantum key in the Redis database using the target file name as the key. When the file is accessed again, the key can be found by the file name, and then the file can be decrypted and the file information can be obtained.
[0066] Step 4: the file processing module records the number of accesses and the access time of the target file and stores the number of accesses and the access time into the ordered set click_zset and the ordered set time_zset respectively to form the ordered set click_zset and the ordered set time_zset;
[0067] Among them, the ordered set can make the data be sorted according to certain rules each time it is inserted; specifically, the ordered set click_zset is sorted from small to large according to the number of access times, and the ordered set time_zset is sorted according to the order of access timestamps.
[0068] After sorting the access counts and timestamps of all files using an ordered set, the sorting number of each file can be obtained, which is convenient for subsequent weight calculation and comparison.
[0069] Step 5: The weight calculation module obtains the sort number c of the target file in the ordered set click_zse and the sort number t of the ordered set time_zset, calculates the weight value of the target file, and stores it in the weight array W[].
[0070] The steps for calculating the weight value by the weight calculation module in step 5 are as follows:
[0071] Step 5-1: The weight calculation module obtains the sorting number of the target file in the ordered set click_zset and names it c, and the sorting number of the ordered set time_zset and names it t;
[0072] Step 5-2: Obtain the access time of the target file according to the sort number t of the ordered set time_zset, and calculate the difference Δh between the access time of the target file and the current system time, and obtain the time coefficient Δt according to the value of Δh;
[0073] Furthermore, the rule for obtaining the time coefficient Δt is:
[0074] When Δh≤72h, time coefficient Δt=0.3;
[0075] When 72h<Δh≤120h, time coefficient Δt=0.7;
[0076] When 120h<Δh≤168h, time coefficient Δt=1;
[0077] Step 5-3: Calculate the weight values of all cached files in the Redis database and store them in the weight array W[];
[0078] The weight value W is calculated as follows:
[0079]
[0080] Among them, c is the sorting number of the ordered set click_zse, t is the sorting number of the ordered set time_zset, and Δt is the time coefficient.
[0081] Among them, the weight value W calculation formula performs weight calculation on multiple parameters of the target file, which is conducive to improving the accuracy of file weight calculation and providing a more accurate judgment basis for subsequent elimination and update of cache files.
[0082] Step 6: The sorting module sorts the weight array W[] obtained in step 5 in descending order to eliminate the cache files at the end, that is, the cache files with the lowest weight values;
[0083] Step 7: When storing the target file in the Redis database, the judgment module first determines whether the number of cached files in the Redis database has reached the maximum cache capacity;
[0084] If the maximum cache capacity is reached, the deletion module deletes the cache file at the end of the weight array W[], and the file processing module sends the target file to the Redis database;
[0085] If the maximum cache size is not reached, the file processing module sends the target file to the Redis database;
[0086] Step 8: The client obtains the quantum key of the target file through the Redis database, and decrypts the target file according to the quantum key to obtain the file information.
[0087] The method disclosed in the present invention also includes a step A of periodically deleting cache files, wherein the value range of the period H is 6 to 10 days.
[0088] The step A is as follows:
[0089] Step A-1: Calculate the weight average of the weight array W[] through the file processing module;
[0090] Step A-2: Delete cache files whose weight values are less than the average weight value.
[0091] The present invention reduces cache space and reduces system resource occupancy by periodically deleting cache files through a deletion module.
[0092] The present invention also caches all files accessed by users in the Redis database, that is, any files accessed by users will be cached in the cache capacity for a long time to improve the speed at which users search and read cached files; when the number of cached files reaches the maximum capacity of the cache, the cache weight values of the files are calculated and sorted to improve the accuracy of judging hot cache files.
[0093] The method disclosed in the present invention also adopts quantum key encryption for cache files, that is, in a quantum communication network, based on the confidentiality performance of quantum communication, the quantum key generated by the one-time key generation method is used to encrypt and store the cache files, thereby improving the security of the cache files.
[0094] Based on the disclosure and teachings of the above description, those skilled in the art may also make changes and modifications to the above embodiments. Therefore, the present invention is not limited to the specific embodiments disclosed and described above, and any modifications and variations of the invention should also fall within the scope of protection of the claims of the present invention. In addition, although certain specific terms are used in this description, these terms are for convenience of description only and do not constitute any limitation to the invention.
Claims
1. A cache file update method based on quantum secure communication network, characterized in that: The steps of this method are as follows: Step 1: Create a Redis database and configure parameters; The parameters include at least a maximum cache capacity; Step 2: The client accesses the target file through the Redis database; If the target file does not exist in the Redis database, jump to step 3; If the target file exists in the Redis database, jump to step 8; Step 3: The file processing module encrypts the target file using a quantum key; Step 4: The file processing module records the current access count and access timestamp of the target file and stores the access count and access time in the ordered set click_zse and the ordered set time_zset respectively; Step 5: The weight calculation module obtains the sorting number of the target file in the ordered set click_zse and the ordered set time_zset respectively, calculates the weight value of the target file and stores it in the weight array W[]. Step 6: The sorting module sorts the weight array W[] obtained in step 5 in descending order; Step 7: The judgment module determines whether the number of cached files in the Redis database has reached the maximum cache capacity; If the maximum cache capacity is reached, the cache file at the end of the weight array W[] is deleted by the deletion module, and the file processing module sends the target file to the Redis database; If the maximum cache size is not reached, the file processing module sends the target file to the Redis database; Step 8: The client obtains the quantum key of the target file through the Redis database, and decrypts the target file according to the quantum key to obtain the file information.
2. A cache file updating method based on a quantum secure communication network according to claim 1, characterized in that: The parameters also include at least the listening IP, port and connection password.
3. A cache file updating method based on a quantum secure communication network according to claim 1, characterized in that: The steps of step 3 are as follows: Step 3-1: The quantum key distribution device QKD generates a first quantum key and a second quantum key and distributes them to the file processing module in the background management center; Step 3-2: The file processing module encrypts the target file according to the first quantum key; and stores the second quantum key in the Redis database.
4. A cache file updating method based on a quantum secure communication network according to claim 1, characterized in that: The steps for calculating the weight value by the weight calculation module in step 5 are as follows: Step 5-1: The weight calculation module obtains the sorting number c of the target file in the ordered set click_zset and the sorting number t of the ordered set time_zset respectively; Step 5-2: Obtain the access timestamp of the target file based on the sort number t of the ordered set time_zset, and calculate the difference Δh between the access timestamp of the target file and the current system time T. Calculate the time coefficient Δt based on the value of Δh; Step 5-3: Calculate the weight value W of the target file and store it in the weight array W[]; The weight value W is calculated as follows: Among them, c is the sorting number of the ordered set click_zse, t is the sorting number of the ordered set time_zset, and Δt is the time coefficient.
5. A cache file updating method based on a quantum secure communication network according to claim 4, characterized in that: The rule for obtaining the time coefficient Δt in step 5-2 is: When Δh≤72h, the time coefficient Δt=0.3; when 72h<Δh≤120h, the time coefficient Δt=0.7; When 120h<Δh≤168h, the time coefficient Δt=1.
6. A cache file updating method based on a quantum secure communication network according to claim 5, characterized in that: The step A of periodically deleting cache files is also included, and the step A is as follows: Step A-1: Calculate the weight average of the weight array W[] through the file processing module; Step A-2: Delete cache files whose weight values are less than the average weight value.
7. A cache file update method based on a quantum secure communication network according to claim 6, characterized in that: The time period H of the step A of periodically deleting cache files ranges from 6 to 10 days.
Citation Information
Patent Citations
A Redis-based hot spot data caching method and apparatus
CN109101580A
Integrated quantum key encryption method and system suitable for power business, and storage medium
CN111211896A