File compression method and device, storage medium and electronic equipment

By configuring resource thread pools to control resource usage, the problem of excessive server resource consumption in the prior art is solved, and efficient resource utilization and processing load reduction are achieved.

CN119719056APending Publication Date: 2025-03-28SHANDONG CVICSE MIDDLEWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411866893.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The existing HTTP protocol-level data compression technology requires the server to invest additional resources during compression, resulting in excessive resource consumption and increased processing load.

Method used

By configuring the resource thread pool, the use of thread resources is controlled to meet the resource requirements during file compression and avoid resource waste.

Benefits of technology

Effectively control resource usage, avoid resource waste, and reduce server resource consumption and processing load.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719056A_ABST
    Figure CN119719056A_ABST
Patent Text Reader

Abstract

The invention provides a file compression method and device, a storage medium and electronic equipment, and is applied to the technical field of file compression, and the file compression method comprises the following steps: when a compression command is received, detecting a command trigger event corresponding to the compression command; acquiring an event parameter corresponding to the command triggering event; determining whether preset compression conditions are met or not by applying the event parameters; when the compression condition is met, determining a target file and a compression algorithm; the compression command is applied to configure a resource thread pool, and threads in the configured resource thread pool are used for calling a compression algorithm to compress the target file. According to the embodiment of the invention, the resource thread pool is configured, the thread resources of the configured resource thread pool meet the resources required during file compression, and the thread resources in the resource thread pool are controlled, so that the thread resources in the resource thread pool meet the thread resource requirements during file compression, and excessive resource waste is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of file compression, and in particular to a file compression method and device, a storage medium and an electronic device. Background Art

[0002] With the rapid development of Internet technology, the transmission efficiency and speed of network data have become one of the key factors affecting user experience. In order to improve data transmission efficiency and reduce network bandwidth usage, browser compression technology has emerged and has been widely used at the HTTP protocol level.

[0003] Although the existing data compression technology at the HTTP protocol level effectively reduces the burden of data transmission by compressing the file size, it requires the server to invest additional resources to perform real-time data compression during compression. The invested resources cannot be controlled, and there is a situation where too many application resources exist, which undoubtedly increases the processing load of the server and increases the server's resource consumption. Summary of the invention

[0004] In view of this, an embodiment of the present application provides a file compression method and device, a storage medium and an electronic device. The present application configures a resource thread pool, and the thread resources of the configured resource thread pool meet the resources required when compressing files. The thread resources in the resource thread pool are controlled so that the thread resources in the resource thread pool meet the thread resource requirements when compressing files, thereby avoiding excessive waste of resources.

[0005] To achieve the above objectives, the present application provides the following technical solutions:

[0006] A file compression method, comprising:

[0007] When a compression command is received, a command triggering event corresponding to the compression command is detected;

[0008] Obtaining event parameters corresponding to the command triggering event;

[0009] Applying the event parameters to determine whether a preset compression condition is met;

[0010] When the compression condition is met, determining the target file and the compression algorithm;

[0011] The compression command is applied to configure a resource thread pool, and threads in the configured resource thread pool are used to call the compression algorithm to compress the target file.

[0012] In the above method, optionally, the applying the event parameter to determine whether a preset compression condition is met includes:

[0013] Determine whether there are any wrong parameters in the event parameters;

[0014] When there is no erroneous parameter in the event parameters, it is determined that the preset compression condition is met.

[0015] In the above method, optionally, the step of determining the target file and the compression algorithm includes:

[0016] Determine a compression algorithm based on the compression algorithm identifier in the event parameter;

[0017] The target file is determined based on the compressed file path and file extension name in the event parameters.

[0018] In the above method, optionally, the applying the compression command to configure the resource thread pool includes:

[0019] Based on the environment information in the compression command, obtaining a configuration file corresponding to the environment information;

[0020] Based on the configuration file, various attributes of the resource thread pool are configured, and threads are created in the configured resource thread pool.

[0021] In the above method, optionally, determining the target file based on the compressed file path and file suffix in the event parameter includes:

[0022] Obtain each file in the compressed file path;

[0023] A file with the same suffix as the file suffix in the event parameter is determined as a target file.

[0024] In the above method, optionally, the compression algorithm is the brotli compression algorithm.

[0025] A file compression device, comprising:

[0026] a detection unit, configured to detect a command triggering event corresponding to the compression command when receiving the compression command;

[0027] An acquisition unit, used for acquiring event parameters corresponding to the command triggering event;

[0028] A first determining unit, configured to apply the event parameter to determine whether a preset compression condition is met;

[0029] A second determining unit, configured to determine a target file and a compression algorithm when the compression condition is met;

[0030] The compression unit is used to apply the compression command to configure the resource thread pool, and use the threads in the configured resource thread pool to call the compression algorithm to compress the target file.

[0031] In the above device, optionally, the determination unit executes a process of applying the event parameter to determine whether a preset compression condition is met, including:

[0032] Determine whether there are any wrong parameters in the event parameters;

[0033] When there is no erroneous parameter in the event parameters, it is determined that the preset compression condition is met.

[0034] In another embodiment provided by the present application, the first determining unit of the device performs a process of applying the event parameter to determine whether a preset compression condition is met, including:

[0035] Determine whether there are any wrong parameters in the event parameters;

[0036] When there is no erroneous parameter in the event parameters, it is determined that the preset compression condition is met.

[0037] In the above device, optionally, the second determining unit executes a process of determining a target file and a compression algorithm, including:

[0038] Determine a compression algorithm based on the compression algorithm identifier in the event parameter;

[0039] The target file is determined based on the compressed file path and file extension name in the event parameters.

[0040] In the above device, optionally, the compression unit executes a process of applying the compression command to configure the resource thread pool, including:

[0041] Based on the environment information in the compression command, obtaining a configuration file corresponding to the environment information;

[0042] Based on the configuration file, various attributes of the resource thread pool are configured, and threads are created in the configured resource thread pool.

[0043] In the above device, optionally, the second determining unit executes a process of determining the target file based on the compressed file path and the file suffix in the event parameter, including:

[0044] Obtain each file in the compressed file path;

[0045] A file with the same suffix as the file suffix in the event parameter is determined as a target file.

[0046] In the above-mentioned device, optionally, the compression algorithm is a brotli compression algorithm.

[0047] A storage medium includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the file compression method as described above.

[0048] An electronic device includes a memory and one or more instructions, wherein the one or more instructions are stored in the memory and are configured to be used by one or more processors to execute the file compression method as described above.

[0049] Compared with the prior art, this application has the following advantages:

[0050] The present application provides a file compression method and device, storage medium and electronic device, including: when receiving a compression command, detecting a command trigger event corresponding to the compression command; obtaining event parameters corresponding to the command trigger event; applying the event parameters to determine whether a preset compression condition is met; when the compression condition is met, determining a target file and a compression algorithm; applying the compression command to configure a resource thread pool, and using the threads in the configured resource thread pool to call a compression algorithm to compress the target file. By configuring the resource thread pool, the thread resources of the configured resource thread pool meet the resources required when compressing files, and the thread resources in the resource thread pool are controlled so that the thread resources in the resource thread pool meet the thread resource requirements when compressing files, avoiding excessive waste of resources. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0052] Figure 1 A flowchart of a file compression method provided in an embodiment of the present application;

[0053] Figure 2 A flowchart of determining a target file and a compression algorithm provided in an embodiment of the present application;

[0054] Figure 3 A flowchart of configuring a resource thread pool for an application compression command provided in an embodiment of the present application;

[0055] Figure 4 An example diagram of the structure of a compression tool provided in an embodiment of the present application;

[0056] Figure 5 Another flowchart of file compression provided by an embodiment of the present application;

[0057] Figure 6 A schematic diagram of the structure of a file compression device provided in an embodiment of the present application;

[0058] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0060] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0061] Terminology explanation:

[0062] Command trigger: refers to the mechanism by which the compression tool responds or processes after receiving a clear command. This compression tool is triggered by entering a command line through the console.

[0063] Compression tool: refers to a software that compresses the files that need to be compressed after receiving a command.

[0064] As can be seen from the background technology, the existing browser compression method requires the server to invest additional computing resources to perform actual data compression, which consumes a lot of resources. In addition to the problems existing in the background technology, the current compression software used for browser compression does not support the brotli compression algorithm, which does not meet the trend that more and more browsers support brotli compression algorithm access. In addition, the configuration process of the current compression software is cumbersome and troublesome to use, and some compression software has simple configuration items and is difficult to meet some specific compression requirements.

[0065] In order to solve the above problems, the present application provides a file compression solution, in which, when a compression command is received, a command trigger event corresponding to the compression command is detected; event parameters corresponding to the command trigger event are obtained; event parameters are applied to determine whether preset compression conditions are met; when the compression conditions are met, the target file and the compression algorithm are determined; the compression command is applied to configure the resource thread pool, and the threads in the configured resource thread pool are used to call the compression algorithm to compress the target file. By configuring the resource thread pool, the thread resources of the configured resource thread pool meet the resources required when compressing files, and the thread resources in the resource thread pool are controlled so that the thread resources in the resource thread pool meet the thread resource requirements when compressing files, avoiding excessive waste of resources.

[0066] The present application can be used in many general or special computing device environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multi-processor devices, distributed computing environments including any of the above devices or equipment, etc.

[0067] Reference Figure 1 , is a flowchart of a file compression method provided in an embodiment of the present application, and the specific description is as follows:

[0068] S101. When a compression command is received, a command triggering event corresponding to the compression command is detected.

[0069] When a compression command is received, a command trigger event corresponding to the compression command is detected. In other words, whether there is a compression command is detected in real time. When the compression command is detected, the command trigger event is detected.

[0070] The compression command is a command provided when the user has a compression requirement. The compression command contains information such as various parameters required for compressing files.

[0071] S102: Acquire event parameters corresponding to the command triggering event.

[0072] Event parameters include but are not limited to the compressed file path, compression algorithm, and file extension name to be compressed.

[0073] When obtaining the event parameters corresponding to the command triggering event, the compression command is parsed to obtain the event parameters such as the compressed file path, compression algorithm identifier, file extension name to be compressed, etc. The compression algorithm here can be understood as the compression algorithm used.

[0074] S103: Apply event parameters to determine whether preset compression conditions are met.

[0075] When using event parameters to determine whether the preset compression conditions are met, determine whether there are erroneous parameters in the event parameters; when there are no erroneous parameters in the event parameters, determine that the preset compression conditions are met, and when there are erroneous parameters in the event parameters, stop executing subsequent steps.

[0076] Further, when judging whether there are erroneous parameters in the event parameters, it is possible to judge whether the compressed file path in the event parameters is correct, whether there is a compression algorithm corresponding to the compression algorithm identifier in the event parameters in the preset algorithm library, and whether the suffix name of the file to be compressed exists in the preset file suffix name list; when the file compression path in the event parameters is correct, the compression algorithm corresponding to the compression algorithm identifier in the event parameters exists in the preset algorithm library, and the suffix name of the file to be compressed exists in the preset file suffix name list, it is determined that there are no erroneous parameters in the event parameters; otherwise, it is determined that there are erroneous parameters in the event parameters, and further, it is determined that the compression conditions are not met.

[0077] When it is determined that there are erroneous parameters in the event parameters, subsequent processes are not executed, thereby avoiding waste of system resources.

[0078] Furthermore, the algorithm library stores various supported compression algorithms, such as the gzip compression algorithm, the brotli compression algorithm, etc.; among them, the gzip compression algorithm is a widely used compression algorithm that provides multiple compression levels. The gzip compression algorithm has relatively low compression efficiency, but its compatibility is very good. Almost all browsers and servers support Gzip compression; the brotli compression algorithm has higher compression efficiency than the gzip compression algorithm, is widely supported in modern browsers, supports multiple compression levels, and allows users to trade off between compression speed and compression rate.

[0079] The file extension list stores various file extensions that can be compressed. In other words, the file extension list contains files of various formats that can be compressed.

[0080] S104: When the compression condition is met, determine the target file and the compression algorithm.

[0081] Reference Figure 2 , which is a flowchart of determining the target file and the compression algorithm provided in the embodiment of the present application, is specifically described as follows:

[0082] S201. Determine a compression algorithm based on a compression algorithm identifier in an event parameter.

[0083] The compression algorithm identifier in the event parameter is traversed through various compression algorithms in the preset algorithm library to determine the compression algorithm corresponding to the compression algorithm identifier, and the compression algorithm corresponding to the compression algorithm identifier is the determined compression algorithm. The compression algorithms stored in the algorithm library can be dynamically expanded according to actual needs, and the expansion content may include increasing the size of the compression dictionary corresponding to the compression algorithm, thereby improving compression efficiency.

[0084] Furthermore, the compression algorithm identifier may be a unique identification identifier of the compression algorithm, for example, the compression algorithm identification identifier may be the name of the compression algorithm.

[0085] S202: Determine the target file based on the compressed file path and file extension in the event parameters.

[0086] Use the compressed file path and file suffix in the event parameters to determine the target file; illustratively, the compressed file path in the event parameters can be used to determine the specific location of the file to be compressed, for example, the file to be compressed is located in a folder, or in a compressed package, which can be a war package or a jar package; when the file to be compressed is located in a compressed package, decompress the compressed package to the current directory to obtain a decompressed folder corresponding to the compressed package, and then traverse all the files in the decompressed folder, and all the files in the decompressed folder that have the same file suffix as the file in the event parameters are determined as target files, for example, when the file suffix in the event parameters is .txt, each file in the decompressed folder with the suffix .txt is determined as a target file; when the file to be compressed is located in a folder, directly traverse all the files in the folder, and determine each file in the folder that has the same file suffix as the file in the event parameters as the target file.

[0087] The determined target file is the file to be compressed. Preferably, the file to be compressed may be a folder.

[0088] S105: Apply the compression command to configure the resource thread pool, and use the threads in the configured resource thread pool to call the compression algorithm to compress the target file.

[0089] Reference Figure 3 , which is a flowchart of configuring a resource thread pool for an application compression command provided in an embodiment of the present application, and is specifically described as follows:

[0090] S301. Based on the environment information in the compression command, obtain a configuration file corresponding to the environment information.

[0091] The compression command is parsed to obtain the environment information in the compression command. The environment information may be the relevant information of the application environment when the user requests compression, such as application scenario, compression tool to be called, and other information.

[0092] After the environment information is obtained, the configuration environment corresponding to the environment information is obtained, for example, the configuration file in the root directory of the pre-compression tool to be called is obtained.

[0093] The configuration file contains information about the resource thread pool.

[0094] S302: Based on the configuration file, configure various attributes of the resource thread pool, and create threads in the configured resource thread pool.

[0095] The various properties of the resource thread pool include but are not limited to the number of threads in the resource thread pool, the maximum number of threads of the resource thread value, and the minimum number of threads in the resource thread pool; the maximum number of threads and the minimum number of threads in the resource thread pool are mainly to adapt to the usage scenarios corresponding to the compression tool, to avoid waste of resources caused by too many threads called by the resource thread pool, and to affect the usage of other applications in the usage scenario.

[0096] The minimum number of threads and the maximum number of threads in the resource thread pool can be used to limit the number of threads created in the resource thread pool. The maximum number of threads cannot exceed the maximum number of threads, and the minimum number of threads cannot be less than the minimum number of threads.

[0097] When creating threads in the configured resource pool, the threads may be created according to the number of target files, and the computing resources required to compress the target files are determined based on the number of target files, and then the threads are created.

[0098] In the method provided in the embodiment of the present application, after the resource thread pool is configured, the configured resource thread pool contains the created threads, and the configured resource thread pool uses the created threads to call the compression algorithm in the compression tool to compress each target file; preferably, the compression algorithm here can be the brotli compression algorithm.

[0099] Preferably, after detecting a command triggering event, log information recording technology can be used to record the compression process corresponding to the command triggering event. When an error occurs in the compression program, it is convenient for users to query and diagnose. By recording detailed log information, it has the functions of problem diagnosis, performance analysis, error and exception tracking, etc., and a custom log tool can be used to implement the log information recording function.

[0100] When there are multiple files that need to be compressed, multiple threads can be called to compress each file that needs to be compressed, which can improve the compression processing efficiency compared to the single-threaded processing method. The files compressed by this application can be part of the files in the compressed file path, and it is not necessary to compress all the files in the compressed file path, making the compression process more selective, thereby effectively reducing invalid compression work, improving compression work efficiency, and avoiding waste of computing resources.

[0101] In the method provided in the embodiment of the present application, when a compression command is received, a command trigger event corresponding to the compression command is detected; event parameters corresponding to the command trigger event are obtained; event parameters are applied to determine whether preset compression conditions are met; when the compression conditions are met, the target file and the compression algorithm are determined; the compression command is applied to configure the resource thread pool, and the threads in the configured resource thread pool are used to call the compression algorithm to compress the target file. By configuring the resource thread pool, the thread resources of the configured resource thread pool meet the resources required when compressing files, and the thread resources in the resource thread pool are controlled so that the thread resources in the resource thread pool meet the thread resource requirements when compressing files, avoiding excessive waste of resources.

[0102] The solution provided in this application can be applied to a compression tool, which includes an event detection module, a thread pool scheduling module, and a compression algorithm module. Further, referring to Figure 4 , is a structural example diagram of a compression tool provided in an embodiment of the present application, and related descriptions are as follows:

[0103] The compression tool includes: an event detection module, a thread pool scheduling module and a compression algorithm module.

[0104] Event detection module: responsible for detecting event status and triggering the thread pool scheduling module when a command triggering event is detected.

[0105] Thread pool scheduling module: collects parameters from command trigger events, reads parameters (equivalent to the event parameters above), and calls different compression algorithms to compress files that need to be compressed. Preferably, this module is implemented by thread pool scheduling compression technology. When there are many files to be compressed or the files to be compressed are a folder, the maximum number of thread pool threads, the minimum number of thread pool threads, etc. can be configured through the configuration file, and the thread pool scheduling compression algorithm is used for compression to improve compression performance.

[0106] Compression algorithm module: A module that compresses the required compressed files using the corresponding compression algorithm according to the scheduling of the thread pool scheduling module. Furthermore, the compression algorithm module adopts a factory design method to support the expansion of more compression algorithms. The compression algorithm module supports multiple algorithms, such as the gzip compression algorithm and the brotli compression algorithm.

[0107] Reference Figure 5 , is another flowchart of file compression provided by an embodiment of the present application, and is specifically described as follows:

[0108] As shown in the figure, after obtaining the input parameters (equivalent to the event parameters above), first verify whether the input parameters are correct, such as whether the compressed file path is correct, whether the compression algorithm type parameter is correct, whether the file under the compressed file path is a folder, jar package or war package, etc. If the parameters are wrong, the error reason is given and the pre-compression program is exited.

[0109] If the input parameters are correct, it is determined whether the compressed file path is a war package, a jar package, or a folder. If it is a war package or a jar package, the war package or the jar package is decompressed to the current directory, that is, decompressed to a temporary folder, and then the decompressed folder is traversed; if it is a folder, the folder is traversed directly; after traversing the folder, the files in the folder are filtered to obtain a compressed file list, and at least one file that needs to be compressed is protected in the compressed file list.

[0110] Process the resource thread pool, for example, configure the resource thread pool. After the configuration is completed, the threads in the resource thread pool call the compression algorithm to traverse and compress the files in the compressed file list one by one. After the compression is successful, a compressed file with the corresponding file name plus the compression algorithm suffix is ​​generated, such as .br, .gz; if a compression error is reported, a log is generated to record the error information, delete the generated compressed file, skip this compression, and continue to traverse the folder for compression until the traversal and compression are completed; if it is a compressed file list obtained by decompressing the compressed package, the decompressed folder is recompressed into a war package or a jar package, and finally the decompressed folder is deleted to complete the file pre-compression. If the compressed file list is obtained by directly traversing the folder, it ends after the files in the compressed file list are traversed and compressed.

[0111] For another example, if the compressed file list is obtained by directly traversing the folder, that is, if the files to be compressed in the compressed file list are in directory format, the folder must be manually backed up first, and then the files in the directory must be traversed. First, determine whether the traversed file has been compressed. If it has not been compressed, compress the traversed file according to the two parameters of the file suffix name to be compressed and the compression algorithm type, and generate a compressed file (.br, .gz) with the corresponding file name plus the compression algorithm suffix. If a compression error is reported, a log is generated to record the error information, delete the generated compressed file, skip this compression, and continue to traverse the folder for compression. After the traversal is completed, file compression feedback information is given.

[0112] In this application, a resource thread pool is used to schedule threads for compression, and multi-threaded compression files are supported. Compared with a single-threaded compression solution, this can effectively improve the efficiency of compressed files, improve response speed, and have better resource utilization; and this application supports multiple compression algorithms, especially the brotli compression algorithm, which provides more compression efficiency and compression speed; this application also provides log recording compression information, which is convenient for users to record file compression information, fault diagnosis, performance analysis, security audit, etc.; the entire compression process does not require cumbersome configuration processes and steps, and compresses the files that need to be compressed, so that the browser does not need to compress in real time when accessing file resources. Reduce resource consumption, reduce bandwidth requirements, and improve response speed.

[0113] Although the present invention depicts operations in a particular order, this should not be understood as requiring that the operations be performed in the particular order shown or in a sequential order.Multitasking and parallel processing may be advantageous under certain circumstances.

[0114] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0115] To support Figure 1 In order to realize the method shown in the figure, the present application also provides a file compression device, which is used to support Figure 1 In a specific implementation of the method shown, the device can be set in a computer terminal.

[0116] Reference Figure 6 , is a schematic diagram of the structure of a file compression device provided in an embodiment of the present application, and is specifically described as follows:

[0117] The detection unit 501 is configured to detect a command triggering event corresponding to the compression command when receiving the compression command;

[0118] An acquisition unit 502 is used to acquire event parameters corresponding to the command triggering event;

[0119] A first determining unit 503, configured to apply the event parameters to determine whether a preset compression condition is met;

[0120] A second determining unit 504 is used to determine a target file and a compression algorithm when the compression condition is met;

[0121] The compression unit 505 is used to apply the compression command to configure the resource thread pool, and use the threads in the configured resource thread pool to call the compression algorithm to compress the target file.

[0122] In the device provided in the embodiment of the present application, when a compression command is received, a command trigger event corresponding to the compression command is detected; event parameters corresponding to the command trigger event are obtained; event parameters are applied to determine whether a preset compression condition is met; when the compression condition is met, a target file and a compression algorithm are determined; a compression command is applied to configure a resource thread pool, and the threads in the configured resource thread pool are used to call a compression algorithm to compress the target file. By configuring the resource thread pool, the thread resources of the configured resource thread pool meet the resources required when compressing files, and the thread resources in the resource thread pool are controlled so that the thread resources in the resource thread pool meet the thread resource requirements when compressing files, thereby avoiding excessive waste of resources.

[0123] In another embodiment provided by the present application, the first determining unit of the device performs a process of applying the event parameter to determine whether a preset compression condition is met, including:

[0124] Determine whether there are any wrong parameters in the event parameters;

[0125] When there is no erroneous parameter in the event parameters, it is determined that the preset compression condition is met.

[0126] In another embodiment provided by the present application, the second determination unit of the device performs a process of determining a target file and a compression algorithm, including:

[0127] Determine a compression algorithm based on the compression algorithm identifier in the event parameter;

[0128] The target file is determined based on the compressed file path and file extension name in the event parameters.

[0129] In another embodiment provided by the present application, the compression unit of the device executes a process of applying the compression command to configure a resource thread pool, including:

[0130] Based on the environment information in the compression command, obtaining a configuration file corresponding to the environment information;

[0131] Based on the configuration file, various attributes of the resource thread pool are configured, and threads are created in the configured resource thread pool.

[0132] In another embodiment provided by the present application, the second determination unit of the device performs a process of determining a target file based on a compressed file path and a file suffix in the event parameter, including:

[0133] Obtain each file in the compressed file path;

[0134] A file with the same suffix as the file suffix in the event parameter is determined as a target file.

[0135] In another embodiment provided in the present application, the compression algorithm of the device is a brotli compression algorithm.

[0136] An embodiment of the present invention further provides a storage medium, which includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the above-mentioned file compression method.

[0137] The embodiment of the present invention further provides an electronic device, the structural diagram of which is shown in FIG. Figure 7 As shown, it specifically includes a memory 601 and one or more instructions 602, wherein the one or more instructions 602 are stored in the memory 601 and are configured to be executed by one or more processors 603 to perform the following operations:

[0138] When a compression command is received, a command triggering event corresponding to the compression command is detected;

[0139] Obtaining event parameters corresponding to the command triggering event;

[0140] Applying the event parameters to determine whether a preset compression condition is met;

[0141] When the compression condition is met, determining the target file and the compression algorithm;

[0142] The compression command is applied to configure a resource thread pool, and threads in the configured resource thread pool are used to call the compression algorithm to compress the target file.

[0143] It should be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards in the relevant regions.

[0144] The specific implementation processes and derivative methods of the above-mentioned embodiments are all within the protection scope of the present invention.

[0145] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

[0146] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0147] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A file compression method, characterized in that: include: When a compression command is received, a command triggering event corresponding to the compression command is detected; Obtaining event parameters corresponding to the command triggering event; Applying the event parameters to determine whether a preset compression condition is met; When the compression condition is met, determining the target file and the compression algorithm; The compression command is applied to configure a resource thread pool, and threads in the configured resource thread pool are used to call the compression algorithm to compress the target file.

2. The method according to claim 1, characterized in that: The applying the event parameter to determine whether a preset compression condition is met includes: Determine whether there are any wrong parameters in the event parameters; When there is no erroneous parameter in the event parameters, it is determined that the preset compression condition is met.

3. The method according to claim 1, characterized in that The determining of the target file and the compression algorithm comprises: Determine a compression algorithm based on the compression algorithm identifier in the event parameter; The target file is determined based on the compressed file path and file extension name in the event parameters.

4. The method according to claim 1, characterized in that The applying the compression command to configure the resource thread pool includes: Based on the environment information in the compression command, obtaining a configuration file corresponding to the environment information; Based on the configuration file, various attributes of the resource thread pool are configured, and threads are created in the configured resource thread pool.

5. The method according to claim 3, characterized in that: The step of determining the target file based on the compressed file path and the file extension name in the event parameter includes: Obtain each file in the compressed file path; A file with the same suffix as the file suffix in the event parameter is determined as a target file.

6. The method according to claim 1, characterized in that The compression algorithm is the brotli compression algorithm.

7. A file compression device, characterized in that: include: a detection unit, configured to detect a command triggering event corresponding to the compression command when receiving the compression command; An acquisition unit, used for acquiring event parameters corresponding to the command triggering event; A first determining unit, configured to apply the event parameter to determine whether a preset compression condition is met; A second determining unit, configured to determine a target file and a compression algorithm when the compression condition is met; The compression unit is used to apply the compression command to configure the resource thread pool, and use the threads in the configured resource thread pool to call the compression algorithm to compress the target file.

8. The device according to claim 7, characterized in that The first determining unit executes a process of applying the event parameter to determine whether a preset compression condition is met, including: Determine whether there are any wrong parameters in the event parameters; When there is no erroneous parameter in the event parameters, it is determined that the preset compression condition is met.

9. A storage medium, characterized in that: The storage medium includes stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the file compression method according to any one of claims 1 to 6.

10. An electronic device, characterized in that: The device comprises a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to perform the file compression method according to any one of claims 1 to 6.