Static file access method and device, electronic equipment and program product
By querying static file data on the local terminal and using the back-end node to access the Redis queue or database, the memory consumption and access delay problems of the traditional architecture in high-concurrency scenarios are solved, and efficient static file access and system stability are achieved.
Patent Information
- Application Number
- CN202510854266.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-10-17
AI Technical Summary
In high-concurrency scenarios, traditional backend service architectures that directly access databases or use distributed cache systems (such as Redis) are prone to high CPU usage, large memory consumption, access delays, and system crashes.
By receiving file access requests from the front-end page, the static file data is first queried on the local terminal. If it does not exist, the Redis queue or database is accessed through the back-end node, reducing the number of direct accesses to the database or Redis. The file server is mounted using the reverse proxy network server to achieve asynchronous processing of static file generation, update and deletion.
It significantly reduces memory consumption and access latency, improves the system's concurrent processing capabilities and stability, and ensures system continuity and user experience in high-concurrency scenarios.
Smart Images

Figure CN120804031A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of distributed technology or other related fields, and in particular, relates to an access method and device for static files, an electronic device and a program product. BACKGROUND
[0002] In modern Internet applications and financial institution information systems, efficient access and processing of data are important factors to ensure user experience and system stability. Traditional backend service architecture often relies on direct access to databases or uses distributed cache systems (such as Redis, an open-source, high-performance key-value pair storage system that can run in memory and provide extremely fast read and write speeds) to provide data services, such as interacting with a database management system (DBMS) through an application (such as a web server) to obtain, store, update, and delete data.
[0003] In related technologies, when facing high-concurrency requests and large-scale data, there are significant limitations and defects in providing data services through direct access to databases or using distributed cache systems (such as Redis), such as through Redis access or direct database access. In high-concurrency scenarios, when the system faces a large number of and frequent accesses to databases or Redis, database queries or Redis can increase the load on the server, causing CPU usage to remain high, reducing performance, consuming a large amount of memory, and requiring higher server hardware. At the same time, access delays occur when the system accesses databases or Redis, as databases or Redis require more time to process queries, transactions, or other operations, causing the system to be unable to handle more requests. When users use the system, they may experience slow interface responses, data loading delays, or some functions that cannot respond in a timely manner, which can seriously affect user experience. In addition, if the system database or Redis is down or has slower performance, the system will be directly unavailable, so users will not be able to access the website, conduct transactions, or obtain data. The time content required to repair the down problem, restore data, and bring the system back online, the system is in a paralyzed state.
[0004] To address the above problems, no effective solutions have been proposed so far. SUMMARY
[0005] The embodiments of the present application provide an access method and device for static files, an electronic device and a program product to at least solve the technical problem that a large amount of memory is consumed in a high-concurrency scenario under a backend service access framework in related technologies, and access delays are prone to occur.
[0006] In order to achieve the above object, according to one aspect of the present application, an access method for static file is provided, comprising: receiving a file access request of a front-end page, and parsing the file access request to obtain a file data identifier; querying the file data identifier corresponding static file data on a local terminal; in the case that the query result indicates that the file data identifier corresponds to existing static file data, obtaining the static file data and attachments from a target file server, and returning the static file data and attachments to the front-end page, wherein the target file server is mounted on a reverse proxy network server of deployed front-end code; in the case that the query result indicates that the static file data cannot be queried, outputting a static file exception signal, and accessing a Redis queue through a backend node, indexing the static file data in the file server through the Redis queue, or accessing a target database through the backend node to obtain the static file data.
[0007] Optionally, before receiving the file access request of the front-end page, the method further comprises: receiving a static file storage instruction; in response to the static file storage instruction, caching the static file on the local terminal; obtaining a backend interface calling rule, putting the business data of the static file into a file server, and adding a file data identifier into a Redis queue; and according to a file operation type, performing asynchronous processing on the business data of the static file, wherein the type of the asynchronous processing includes at least one of the following: deleting a file, adding a file, and updating a file.
[0008] Optionally, the method further comprises: identifying the static file storage instruction, creating and initializing a functional static queue object according to the identification result; according to the business data of the static file and parameters required for generating the static file, performing attribute assignment on the functional static queue object; adding the functional static queue object into the Redis queue, and setting an expiration time interval of the functional static queue object; pulling an update task from the Redis queue according to a predetermined periodic time interval, and converting the business data corresponding to the static file storage instruction into a static file according to the update task.
[0009] Optionally, the access method for static file further comprises: after creating the functional static queue object, matching a corresponding static processing strategy according to the operation object type of the functional static queue object; and initializing the Redis queue through a preset concurrent management thread pool.
[0010] Optionally, in the generating the static file, comprising: executing an initialization script, pulling a queue message containing static task parameters from a Redis queue; performing parameter checking on the pulled queue message, calling an interface service of a server according to a uniform resource locator URL and parameters obtained by the checking, and obtaining dynamically generated static file data; performing JSON format processing on the obtained static file data, generating the static file, naming the static file according to a predefined file naming rule, and saving the static file to a file server.
[0011] Optionally, in the updating the static file, comprising: listening to an update task in the Redis queue, wherein the update task comprises at least one of a URL, parameters, and an operation type; accessing a server interface according to the URL and the parameters in the update task, and obtaining a static file to be updated; performing correctness checking and integrity checking on business data in the obtained static file to be updated; in the case of passing the checking, replacing an existing static file with the static file to be updated, wherein the replaced file is stored according to an original naming rule; in the case of completing the file replacement, confirming that the update operation is successful, and removing a queue message of the update task from the Redis queue.
[0012] Optionally, in the deleting the static file, comprising: obtaining a deletion task in the Redis queue, wherein the deletion task comprises a URL and parameters of a static file to be deleted; locating a storage location of the static file to be deleted on a file server according to the URL and the parameters; performing a file deletion operation, and removing the static file to be deleted; in the case of completing the removal operation, confirming that the file deletion is successful, and removing the deletion task from the Redis queue.
[0013] According to another aspect of the embodiments of the present application, there is also provided an access device for static files, comprising: a file parsing unit configured to receive a file access request of a front-end page and parse the file access request to obtain a file data identifier; a static file querying unit configured to query static file data corresponding to the file data identifier on a local terminal; a static file extracting unit configured to acquire the static file data and attachments from a target file server in a case where the query result indicates that the static file data corresponding to the file data identifier exists, and return the static file data and the attachments to the front-end page, wherein the target file server is mounted on a reverse proxy web server on which front-end code has been deployed; and a back-end node accessing unit configured to output a static file exception signal in a case where the query result indicates that the static file data cannot be queried, and access a Redis queue through a back-end node to index the static file data in the file server through the Redis queue or obtain the static file data by accessing a target database through the back-end node.
[0014] Optionally, the access device for static files further comprises: an update instruction receiving unit configured to receive a static file storage instruction before receiving the file access request of the front-end page; an instruction responding unit configured to respond to the static file storage instruction, cache the static file on the local terminal, acquire a back-end interface calling rule, store business data of the static file in a file server, and add a file data identifier to a Redis queue; and a data asynchronous processing unit configured to perform asynchronous processing on the business data of the static file according to a file operation type, wherein the asynchronous processing type comprises at least one of the following: deleting a file, adding a file, and updating a file.
[0015] Optionally, the access device for static files further comprises: an instruction identifying module configured to identify the static file storage instruction, and create and initialize a functional static queue object according to an identification result; an object assigning module configured to assign attributes to the functional static queue object according to the business data of the static file and parameters required for generating the static file; a queue adding module configured to add the functional static queue object to the Redis queue and set an expiration time interval of the functional static queue object; and a file updating module configured to pull an update task from the Redis queue according to a predetermined periodic time interval, and convert business data corresponding to the static file storage instruction into a static file according to the update task.
[0016] Optionally, the access device for static file further comprises: an object type matching module, configured to match a corresponding static processing strategy according to an operation object type of the functional static queue object after the functional static queue object is created; and a queue initialization module, configured to initialize the Redis queue through a preset concurrent management thread pool.
[0017] Optionally, when the static file is generated, the access device for static file comprises: a script execution unit, configured to execute an initialization script, and pull a queue message containing a static task parameter from the Redis queue; a parameter checking unit, configured to perform parameter checking on the pulled queue message, and call an interface service of a server according to a uniform resource locator (URL) and a parameter obtained through the checking, to obtain dynamically generated static file data; and a format processing unit, configured to perform JSON format processing on the obtained static file data, to generate the static file, name the static file according to a predefined file naming rule, and save the static file to a file server.
[0018] Optionally, when the static file is updated, the access device for static file comprises: an update task listening unit, configured to listen to an update task in the Redis queue, wherein the update task comprises at least one of a URL, a parameter and an operation type; access a server interface according to the URL and the parameter in the update task, to obtain a static file to be updated; a data checking unit, configured to perform correctness checking and integrity checking on business data in the obtained static file to be updated; a file replacing unit, configured to replace an existing static file with the static file to be updated in a case where the checking passes, wherein the replaced file is stored according to an original naming rule; and a first task removing unit, configured to remove a queue message of the update task from the Redis queue in a case where the file replacing is completed and the update operation is successful.
[0019] Optionally, when the static file is deleted, the access device for static file comprises: a deletion task obtaining unit, configured to obtain a deletion task in the Redis queue, wherein the deletion task comprises a URL and a parameter of a static file to be deleted; a file positioning unit, configured to position a storage location of the static file to be deleted on a file server according to the URL and the parameter; a file deleting unit, configured to perform a file deleting operation, and remove the static file to be deleted; and a second task removing unit, configured to remove the deletion task from the Redis queue in a case where the removing operation is completed and the file deletion is successful.
[0020] According to another aspect of the embodiments of the present application, a computer readable storage medium is also provided, including a stored computer program, wherein the computer readable storage medium controls the device where the computer readable storage medium is located to execute the access method for staticizing files of any one of the above when the computer program is running.
[0021] According to another aspect of the embodiments of the present application, an electronic device is also provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein the one or more programs make the one or more processors implement the access method for staticizing files of any one of the above when the one or more programs are executed by the one or more processors.
[0022] According to another aspect of the embodiments of the present application, a computer program product is also provided, including a computer program, the computer program implementing the steps of the access method for staticizing files of any one of the above when the computer program is executed by a processor.
[0023] In the present disclosure, a file access request of a front-end page is received, and the file access request is parsed to obtain a file data identifier; the local terminal queries static file data corresponding to the file data identifier; in the case that the query result indicates that the static file data corresponding to the file data identifier exists, the static file data and attachments are obtained from a target file server, and the static file data and the attachments are returned to the front-end page, wherein the target file server is mounted on a reverse proxy network server where the front-end code has been deployed; in the case that the query result indicates that the static file data cannot be queried, a static file exception signal is output, and a Redis queue is accessed through a backend node, the static file data in the file server is indexed through the Redis queue, or the static file data is obtained through a target database accessed by the backend node.
[0024] According to the above disclosure, when a user front-end access data request is received, the static file data and the attachments can be obtained from the local file server, instead of directly accessing the database or the Redis queue, so that the memory consumption can be greatly reduced. Once the static file exception is found, the system triggers an exception processing procedure, directly accesses the database or the Redis through a background node interface to obtain the data, greatly reduces the access delay, and thus solves the technical problem in the related art that a large amount of memory is consumed in a high-concurrency scenario under the access framework of the backend service, and the access delay is prone to occurring. BRIEF DESCRIPTION OF DRAWINGS
[0025] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and serve to explain the principles of the application. In the drawings:
[0026] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing an access method for static files is shown;
[0027] Figure 2 is a flow chart of an optional access method for static files according to an embodiment of the present application;
[0028] Figure 3 is a schematic diagram of an optional generation and access method for static files with acceleration and fault tolerance according to an embodiment of the present application;
[0029] Figure 4 is an operation schematic diagram of an optional user-triggered static file according to an embodiment of the present application;
[0030] Figure 5 is an operation schematic diagram of an optional generation, update or deletion of static files according to an embodiment of the present application;
[0031] Figure 6 is a schematic diagram of an optional access device for static files according to an embodiment of the present application;
[0032] Figure 7 is a structure block diagram of an electronic device for executing an access method for static files according to an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to make the personnel in the technical field better understand the present application scheme, the technical scheme in the embodiment of the present application will be described clearly and completely below in combination with the drawings in the embodiment of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by the person skilled in the art without creative labor should belong to the scope of protection of the present application.
[0034] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0035] To facilitate the understanding of the present application by those skilled in the art, the following explanations are made for some terms or names involved in the embodiments of the present application:
[0036] The Content Delivery Network, abbreviated as CDN, is a distributed network service used to distribute static content to multiple nodes around the world, thereby shortening user access delay and improving data transmission speed. In the present application, CDN is used to accelerate access to static files, especially in cross-regional or high-concurrency scenarios, to improve user experience.
[0037] StaticDataQueueVO is a value object used to encapsulate key information of a static task, such as Universal Resource Locator (URL), parameters, method type (GET / POST), data type (list / view), and operation type (add / update / delete). In the present application, this object plays a bridge role in the communication between batch nodes and the background management system and the Redis queue, ensuring the correct transmission and processing of static tasks.
[0038] It should be noted that the access method for static files and the device thereof in the present disclosure can be used in the field of distributed technology for accelerating and fault-tolerant static file access, and can also be used in any field other than the field of distributed technology for accelerating and fault-tolerant static file access. The application field of the access method for static files and the device thereof in the present disclosure is not limited.
[0039] It should be noted that the information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) collected in the present disclosure are information and data authorized by the user or authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure, and application of related data comply with relevant laws, regulations, and standards in relevant regions, necessary security measures are taken, do not violate public order and good customs, and provide corresponding operation portals for users to choose authorization or refusal. For example, an interface is provided between the system and related users or agencies. Before obtaining the relevant information, the interface needs to send a request to the aforementioned user or agency, and after receiving the consent information feedback from the aforementioned user or agency, the relevant information is obtained.
[0040] It should be noted that in the present disclosure, customer information is collected, customer information is analyzed, and corresponding operation portals are provided for users to choose to agree or refuse automatic decision results; if the user chooses to refuse, the expert decision-making process is entered.
[0041] The following embodiments of the present invention can be applied to various systems / applications / devices for accessing static files. The present invention can be applied to high-concurrency scenarios / systems involving the reading and display of large amounts of data, such as Web application systems, content management systems (CMS), financial transaction systems, etc. For example, in high-traffic Web applications, by using the static file access strategy for acceleration and fault tolerance provided by the present invention, the frequency of dynamic data access can be significantly reduced, and the data can be converted into static files and stored in advance, thereby accelerating page loading and data response speed, and improving user experience. For financial systems that require high reliability, the present invention can ensure that when an anomaly occurs in the database or Redis, the system can still provide services through static files to maintain the continuity and stability of the system.
[0042] The present invention can reduce direct access to back-end databases and in-memory databases, utilize the rapid response capabilities of static files, significantly reduce system latency, and improve concurrent processing capabilities. By pre-generating static files, the hardware resource consumption for dynamic data access and processing, including central processing unit (CPU), memory and network resources, is reduced, thereby reducing operating costs.
[0043] The present invention will be described in detail below with reference to various embodiments.
[0044] Example 1
[0045] According to an embodiment of the present invention, an embodiment of a method for accessing static files is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0046] The method embodiment for accessing static files provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for accessing static files. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more ( Figure 1The computer terminal 10 can include a processor 102 (which can include, but is not limited to, a microcontroller unit (MCU) or a field programmable gate array (FPGA) or other processing device), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, the computer terminal 10 can include a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the BUS), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that Figure 1 The structure shown is merely illustrative and does not limit the structure of the electronic device described above. For example, the computer terminal 10 can include more or fewer components than those shown in the figure, or have a different configuration than that shown in the figure. Figure 1 Figure 1
[0047] It should be noted that the one or more processors 102 and / or other data processing circuits described above can be referred to herein generally as "data processing circuits". The data processing circuits can be embodied in whole or in part as software, hardware, firmware, or any combination thereof. In addition, the data processing circuits can be a single independent processing module, or any one of the other elements incorporated into the computer terminal 10 (or mobile device) in whole or in part. As referred to in the embodiments of the present application, the data processing circuits serve as a processor to control, for example, the selection of the variable resistance terminal path connected to the interface.
[0048] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage means corresponding to the access method for static files in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, i.e., implements the access method for static files described above. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 can further include a memory remotely located with respect to the processor 102, which can be connected to the computer terminal 10 through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0049] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network interface controller (NIC) that can be connected to other network devices through a base station to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module configured to communicate with the Internet wirelessly.
[0050] The display can be a touch screen liquid crystal display (LCD) that enables a user to interact with the user interface of the computer terminal 10 (or mobile device).
[0051] In the above operating environment, the present application provides an access method for static files as shown in Figure 2 Figure 2 is a flow chart of an optional access method for static files according to an embodiment of the present application, as shown in Figure 2 The method includes the following steps:
[0052] In the embodiment of the present application, the static files in the local file server are pre-constructed and updated to ensure the real-time and accuracy of the static files, reduce the dependence on dynamic data sources (such as databases or Redis), and improve the overall performance and stability of the system.
[0053] Optionally, before receiving the file access request of the front-end page, the method further includes: receiving a static file storage instruction; in response to the static file storage instruction, storing the static files in the local terminal, obtaining the back-end interface calling rule, putting the business data of the static files into the file server, and adding the file data identifier to the Redis queue; and performing asynchronous processing on the business data of the static files according to the file operation type, wherein the type of the asynchronous processing includes at least one of the following: deleting a file, adding a file, and updating a file.
[0054] The embodiment of the present application sets up a mechanism for receiving static file storage instructions from a background management system or batch node. These instructions can contain modification requirements for static files, such as deleting no longer needed files, adding or updating file content to reflect changes in backend data. In response to the static file storage instructions, the embodiment obtains the backend interface calling rules related to the static file to be updated, for example, the backend interface calling rules define how to obtain the necessary business data from the backend service (such as a database or Redis) in order to update the static file. Then the business data of the static file is encapsulated into a StaticDataQueueVO object and pushed into the Redis queue. The StaticDataQueueVO object contains key information such as URL, parameters, method type, data type and operation type, ensuring the accuracy and integrity of the static file storage instructions.
[0055] According to the file operation type, the embodiment asynchronously processes the business data of the static file, processes the StaticDataQueueVO objects in the queue through the ThreadPoolExecutor thread pool, and performs file deletion, addition or update operations. The asynchronous processing mechanism can avoid blocking the main application thread and ensure the high responsiveness and concurrent processing capability of the system.
[0056] Optionally, it also includes: identifying the static file storage instructions, creating and initializing the functional static queue object according to the identification result; attribute assignment is performed on the functional static queue object according to the business data of the static file and the parameters required for generating the static file; the functional static queue object is added to the Redis queue, and the expiration time interval of the functional static queue object is set; the update task is pulled from the Redis queue according to the predetermined periodic time interval, and the business data corresponding to the static file storage instructions is converted into a static file according to the update task.
[0057] After receiving the static file storage instructions, the embodiment parses the instruction content, creates and initializes the functional static queue object (which can be defined as StaticDataQueueVO in the embodiment), which is designed to store complete information related to the update of a specific static file, ensuring the correct execution of the update task. Attribute assignment is performed on the functional static queue object to ensure the accuracy of specific information such as URL, parameters, method type, data type and operation type. These information is directly related to the generation rule and data access strategy of the static file, and is the core basis for the static file update operation.
[0058] The attribute assigned functional static queue object is added to the Redis queue, and an expiration time interval is set to prevent queue backlog and invalid task occupation. It should be noted that the expiration time can be set based on the update frequency of the static file and the business requirement, to ensure that the tasks in the queue are recent and valid. According to the predetermined period interval, the embodiment pulls the update task from the Redis queue, and according to the content of the update task, the business data corresponding to the static file storage instruction is converted into a static file. Specifically, it can include data acquisition, formatting into JSON or TXT format, and storage in a local file server to ensure the real-time and accuracy of the static file.
[0059] Step S201, receiving a file access request of a front-end page, and parsing the file access request to obtain a file data identifier.
[0060] In this embodiment, the first step is to receive the file access request of the front-end page, which can contain information such as the file name or file identifier of the static file that the user wants to access. Then, the request is further parsed to extract the file data identifier, which is the key information for uniquely determining the static file data. It can be the relative path, name, version number of the file or other metadata that can be used to locate the file. Through the parsed file data identifier, the specific static file requested by the user can be accurately located.
[0061] Step S202, querying the static file data corresponding to the file data identifier in the local terminal.
[0062] After parsing the request, the embodiment will try to query the static file data corresponding to the file data identifier in the local terminal. The local terminal can be part of the application server, which is used to cache recently accessed file data to quickly respond to user requests. If the static file data exists in the local cache, it can be directly read from the cache, avoiding the delay and network overhead of remote access to the file server or database.
[0063] Step S203, in the case where the query result indicates that the static file data corresponding to the file data identifier exists, the static file data and the attachment are obtained from the target file server, and the static file data and the attachment are returned to the front-end page, wherein the target file server is mounted on the reverse proxy web server on which the front-end code has been deployed.
[0064] In the case where the query result indicates that the static file data corresponding to the file data identifier does exist locally or in the file server, the embodiment will perform the operation of obtaining the static file data and the attachments from the target file server. The target file server is used to store and manage the static file, which is mounted on the reverse proxy network server (such as NGINX server) where the front-end code has been deployed. The reverse proxy server can directly access the static file in the target file server to reduce network hops and improve access speed. After successfully obtaining the static file data and the attachments, these data will be packaged and returned to the front-end page for the user to directly access and use.
[0065] Through the mechanism of mounting the file server by the reverse proxy network server, the embodiment ensures efficient data transmission between the front-end and the back-end, maintains a relatively low response time even in a high-concurrency scenario, and reduces the number of accesses to the back-end resources.
[0066] In the case where the query result indicates that the static file data cannot be queried, the static file exception signal is output, and the back-end node accesses the Redis queue to index the static file data in the file server through the Redis queue, or the back-end node accesses the target database to obtain the static file data.
[0067] If the static file data cannot be queried locally or in the file server, it is confirmed that the local static file is unavailable. In this case, the embodiment can automatically switch to a dynamic data access mode, that is, data is obtained by calling a database or Redis interface to ensure the continuity of the service. Once the fault is recovered, the static file will be regenerated to restore the priority access mechanism.
[0068] In the case where the dynamic data access mode is automatically switched, the embodiment outputs the static file exception signal. One solution is to access the Redis queue through the back-end node and use the information in the Redis queue to index the static file data in the file server. The Redis queue stores file update tasks to be processed, including generation, update, and deletion instructions of the static file, and thus can indirectly reflect the static data state on the file server. Another solution is to directly access the target database through the back-end node to obtain the information required by the static file data. The target database is the source of the original data, and when the static file data is missing or expired, directly obtaining data from the database is the most direct method.
[0069] Through the dynamic data access mode, even if the static file data is abnormal, the data can still be obtained through the fallback mechanism, thereby ensuring the continuity of the service and the availability of the data. Through the Redis queue index or the database access, the embodiment solves the problem of missing static file data without sacrificing the user experience.
[0070] Through the above steps, the file access request of the front-end page can be received, and the file access request can be parsed to obtain the file data identifier. The local terminal queries the static file data corresponding to the file data identifier. In the case that the query result indicates that the static file data corresponding to the file data identifier exists, the static file data and the attachment are obtained from the target file server, and the static file data and the attachment are returned to the front-end page, wherein the target file server is mounted on the reverse proxy network server on which the front-end code has been deployed. In the case that the query result indicates that the static file data cannot be queried, a static file exception signal is output, and the Redis queue is accessed through the backend node to index the static file data in the file server through the Redis queue, or the static file data is obtained by accessing the target database through the backend node. In the embodiment, when receiving the user front-end access data request, the static file data and the attachment can be obtained from the local file server, instead of directly accessing the database or the Redis queue, thereby greatly reducing the memory consumption. Once the static file is found to be abnormal, the system triggers an exception handling process, directly accesses the database or the Redis to obtain data through the background node interface, greatly reduces the access delay, and thereby solves the technical problem that a large amount of memory is consumed in a high-concurrency scenario under the backend service access framework in the related art, and the access delay is prone to occur.
[0071] Optionally, the access method for the static file further includes: after the functional static queue object is created, a corresponding static processing strategy is matched according to the operation object type of the functional static queue object; and the Redis queue is initialized through a preset concurrent management thread pool.
[0072] When receiving the static file storage instruction, the embodiment can create a functional static queue object StaticDataQueueVO, which encapsulates the key information of the static file to be updated, including the URL, the parameter, the method type (for example, GET / POST), the data type (list / view), and the operation type (add / delete / update).
[0073] After the functional static queue object is created, the embodiment matches the corresponding static processing strategy according to the operation object type defined in the object. Different types of business operations may require different processing logic, for example, the add or update type of operation may involve obtaining the latest data, and the delete type of operation needs to clean up the corresponding files on the file server. By predefining a series of static processing strategies, the processing flow can be dynamically adjusted according to actual business changes, improving the adaptability and flexibility of the system.
[0074] Meanwhile, the embodiment uses a preset concurrent management thread pool (such as ThreadPoolExecutor) to initialize the Redis queue. The concurrent management thread pool can handle a large number of concurrent tasks, avoiding the performance overhead and resource waste caused by directly creating threads, and ensuring the management and task processing efficiency of the Redis queue.
[0075] In the embodiment, the created functional static queue object is placed in the Redis queue and initialized through the concurrent management thread pool. By using the concurrent management thread pool to initialize the Redis queue, the embodiment not only improves the processing speed of the static file update task, but also enhances the concurrent processing capability of the system, which can better cope with high-concurrency scenarios. In addition, the size of the thread pool, timeout time and other parameters can be adjusted according to specific business requirements and system load conditions to achieve the best performance balance point.
[0076] Optionally, when generating the static file, the following steps are included: executing an initialization script to pull a queue message containing static task parameters from the Redis queue; performing parameter checking on the pulled queue message, calling the interface service of the server according to the uniform resource locator URL and parameters obtained by the checking, and obtaining dynamically generated static file data; performing JSON formatting processing on the obtained static file data to generate a static file, naming the static file according to a pre-defined file naming rule, and saving it to a file server.
[0077] When generating the static file, the embodiment first executes an initialization script, which is responsible for pulling a queue message containing static task parameters from the Redis queue. It should be noted that the queue message in the embodiment contains key information, such as uniform resource locator URL, parameters, method type, etc., which guides the subsequent file generation operation. Then, the pulled queue message is subjected to parameter checking to ensure the correctness and integrity of the URL and parameters. According to the checking result, the interface service of the server is called to obtain dynamically generated static file data.
[0078] After obtaining the static file data, the embodiment performs JSON formatting processing on the static file data to meet the structural requirements of the static file. Subsequently, a generated static file is named according to a predefined file naming rule, which generally includes information such as a context root of the file, a data type, and parameters, to ensure the uniqueness and recognizability of the file name. Finally, the generated static file is saved to a file server, waiting for subsequent access and use.
[0079] Optionally, when updating the static file, the following operations are included: listening to an update task in a Redis queue, wherein the update task includes at least one of a URL, parameters, and an operation type; accessing a server interface according to the URL and the parameters in the update task to obtain a static file to be updated; performing correctness verification and integrity verification on business data in the obtained static file to be updated; in the case that the verification is passed, replacing an existing static file with the static file to be updated, wherein the replaced file is stored according to an original naming rule; and in the case that the file replacement is completed, confirming that the update operation is successful, and removing a queue message of the update task from the Redis queue.
[0080] In order to update the static file, the embodiment continuously listens to an update task in a Redis queue, and the update task includes at least a URL, parameters, and an operation type. These information are used to locate the static file to be updated and guide the update operation. According to the URL and the parameters in the update task, a server interface is accessed to obtain a static file to be updated. Then, correctness verification and integrity verification are performed on business data in the obtained static file to be updated. In the case that the verification is passed, an existing static file is replaced with the static file to be updated, and the replaced file is stored according to an original naming rule, thereby ensuring the continuity and consistency of the file naming. After the file replacement is completed, the embodiment confirms that the update operation is successful, and removes a queue message of the update task from the Redis queue, thereby releasing the queue space and improving the processing efficiency of the queue.
[0081] Optionally, when deleting the static file, the following operations are included: obtaining a deletion task in a Redis queue, wherein the deletion task includes a URL and parameters of a static file to be deleted; locating a storage location of the static file to be deleted on a file server according to the URL and the parameters; performing a file deletion operation to remove the static file to be deleted; and after the removal operation is completed, confirming that the file deletion is successful, and removing the deletion task from the Redis queue.
[0082] When deleting the static file, the embodiment first obtains a deletion task from a Redis queue, and the task includes a URL and parameters of a static file to be deleted. Therefore, according to the URL and the parameters, the embodiment locates a storage location of the static file to be deleted on a file server, and performs a file deletion operation, thereby ensuring that the data on the file server is consistent with the business requirements.
[0083] After the file deletion operation is completed, the embodiment confirms the successful deletion of the file and removes the deletion task from the Redis queue to reflect the change in the file status and maintain the health status of the queue, avoiding the accumulation of invalid tasks.
[0084] Through the above embodiment, the pre-generation and update of static files can significantly reduce the number of real-time accesses to the database and Redis, especially in high-concurrency scenarios, greatly relieving the performance pressure of dynamic data sources and improving data access speed and response time. The use of static files means that less data is transmitted between the network layer and the application layer, reducing the memory cache requirement and the CPU computation burden, optimizing the allocation and utilization of server resources. Static files are located on the file server and can be accessed directly through the front-end code without going through complex dynamic data query and processing procedures, thereby significantly reducing access delay and providing a smoother user experience.
[0085] At the same time, even in the case of exceptions in the database or Redis, the file server mounted on the reverse proxy server can still provide static file data, enhancing the fault tolerance of the system and the availability of data. Once the database or Redis recovers, the static file can be quickly updated to ensure the timeliness and accuracy of the data.
[0086] Due to the direct access characteristics of static files, the application can provide nearly instantaneous response speed, ensuring good user experience even during peak access periods, reducing user waiting time and improving user satisfaction.
[0087] The following will be described in detail in conjunction with another alternative specific embodiment.
[0088] Figure 3 is a schematic diagram of an alternative method for generating and accessing static files for acceleration and fault tolerance according to an embodiment of the application, as Figure 3 shown, the nodes of interaction include: storage nodes, application nodes, network nodes and user terminals, wherein the user terminals correspond to front-end nodes / front-end pages / front pages and can initiate file update and manage file operations, the network nodes can obtain static files and business attachments of the content distribution network (CDN) according to the front-end and back-end interface calling rules, then locally cache the static files, after that, the CDN node caches the static files, in this process, it is not necessary to query the database or Redis queue every time the interface is called, and the NGINX server deployed by the network node can deploy the front-end code and mount the file server.
[0089] Application nodes include backend nodes, static nodes, and batch nodes. When a frontend call to a static file is confirmed to be abnormal, the backend node triggers an interface, returning the result through the database and Redis queue. Static nodes can also perform asynchronous processing based on the type of operation, including deleting, generating, and updating static file data and attachments. When updating static files, batch nodes can periodically update static interface files according to appropriate rules. Backend nodes can trigger interfaces and, based on frontend and backend call rules, retrieve the business data required to generate static files and place it in the Redis queue.
[0090] Storage nodes include file servers, Redis servers, and database clusters. The file servers can store static interface files and attachments according to the front-end and back-end interface call rules, while the Redis servers can record and update the information of the Redis queue and wait for the static data list.
[0091] The following combination Figure 3 A system and method are described that can alleviate system performance pressure, improve access rate, and increase data middleware fault tolerance.
[0092] Part 1: Users access the page through front-end code combined with static files, attachments, etc.
[0093] 1. The user accesses the interface or attachment from the front-end page, and the front-end obtains static files and attachments based on the front-end and back-end interface call rules.
[0094] 2. Obtain static file data and attachments to local cache and CDN cache nodes to speed up access.
[0095] 3. If there is static file data, it is obtained from the system's NGINX server, and the NGINX server mounts the file server that stores the static file data and attachments.
[0096] If there is no static file data, an exception is reported for accessing the static file, and the database is accessed through the background node interface to obtain the data.
[0097] Part 2: The administrator updates static files and attachments through the backend management system.
[0098] 1. The administrator obtains the business data of the static files that need to be generated in the background node, calls the database, and puts it into the Redis queue for asynchronous processing based on the operation type, deleting, generating, or updating the static data and attachments.
[0099] 2. Batch node calls background node to update static interface file according to appropriate rules, and needs to generate business data of static file. After calling database, it is put into redis queue for asynchronous processing according to operation type, so as to prevent static file from being damaged or lost.
[0100] 3. Static node carries out asynchronous processing according to operation type: delete or generate or update static data and attachments.
[0101] Figure 4 An optional user-triggered static file operation schematic diagram according to an embodiment of the present application is shown in FIG. 1. Figure 4 As shown in FIG. 1, in the batch or user operation triggered static operation process, the following steps are included.
[0102] 2.1 When calling interface to update static data and other operations, the batch node and background management system add static queue, which includes calling of various business operation interfaces.
[0103] 2.2 For each type of business operation interface, create StaticDataQueueVO object, and assign values to StaticDataQueueVO object attributes in combination with specific business parameters and parameters required for generating static file, as follows.
[0104] 1. url: context root of relative path, such as: interface large category A / interface small category B / interface small category C, interface path, and file server storage relative path matching.
[0105] 2. param: parameter, in combination with business parameters, such as: get: "?pageIndex=1&pageSize=10"; post: {"ID": 80876, "Name": "rzb"}.
[0106] 3. method: get or post.
[0107] 4. dataType: data type list or view. If it is list, the following two parameters must be included: pageIndex, pageSize, list / view.
[0108] 5. enumOpType: operation type enumeration: add, delete, update.
[0109] Create StaticDataQueue object, add elements to redis queue and set expiration time (key value: StaticDataQueue), and the expiration time is 24 hours. lpush--add queue expire--set expiration time.
[0110] 2.3 The SetStaticData method of the IStaticPageUrlService interface of the static data information IStaticPageUrlService, the input parameter is StaticDataQueueVO, and different static methods are processed according to the operation object type.
[0111] 2.4 Push to the general redis static queue: initialization is performed through a ThreadPoolExecutor thread pool.
[0112] 2.5 The static node consumes StaticDataQueue data in redis, and produces static files according to the StaticDataQueueVO object parameter.
[0113] The third part: the static node consumes the data in the redis queue to generate, update or delete static files.
[0114] Figure 5 According to an embodiment of the application, an optional operation schematic diagram for generating, updating or deleting static files is shown in FIG. 3, which includes: Figure 5
[0115] 3.1 The start_ssr.sh executes the main method of the class APP_MAIN_CLASS, the start script can be executed with parameters to perform full, incremental and other static new DataCache objects, the parameterless construction of the object is called to assign values to the attributes, and the run() method is started.
[0116] 3.2 The queue message is pulled RedisUtil.rpop("StaticDataQueue").
[0117] 3.3 The redis queue is obtained to be empty waitLogFlag = false (default is true) and the last step is returned.
[0118] 3.4 The check method checks static parameters (non-empty, json format, url parameter, get / post verification).
[0119] The staticData(staticQuestStr) is started, and the data parameter is spliced (get, post request parameter coding--JSON) through a (while (true)) loop.
[0120] 3.5 The execution logic is judged according to the operation type parameter opType.
[0121] If it is a Delete, Reject, Freeze class request to delete static files - deleteFile(getFileName(url, params)).
[0122] If it is an Add, Update, Batch class, call the server according to get / post, get its response parameters,
[0123] Static data and json format processing are saved as static files: save2File(file, getFileName(url, params)) Static file name format: context root (interface large class A / interface small class B / interface small class C) + / data_+ parameters + ".json / txt".
[0124] Through the above embodiment, the system performance pressure can be relieved. When facing a large number of and frequent accesses, compared with calling a database or Redis, direct access to files can occupy less memory, because there is no need to cache data or metadata in the application node memory. And through the configuration of the network side CDN and the local cache, the system performance pressure can be greatly relieved.
[0125] Through the above embodiment, the access rate can also be improved. Direct access to files is usually faster than through code database or Redis. Direct access to files is usually performed on the server disk, and I / O operations can be directly performed through hardware. While calling a database or Redis through an interface requires connection establishment and data processing, which increases additional delay. Through static file access, this process is omitted, and the processed result is directly obtained. Only when the background is modified, the update of the static file will be triggered.
[0126] In addition, when the database or Redis is abnormal, the database or redis data is converted into a static file in advance, so that these static files can still be directly accessed through the NGINX server to provide services. When the file server or static file is abnormal, the database or Redis can be accessed through the borrowed interface to provide services, thereby ensuring the basic availability of the system.
[0127] The following will be described in detail in conjunction with another embodiment.
[0128] Embodiment Two
[0129] The access device for static files provided in this embodiment comprises a plurality of implementation units, each implementation unit corresponding to each implementation step in the above embodiment one. The specific implementation manner and beneficial effects can be referred to the foregoing method embodiment, which will not be described herein again.
[0130] Figure 6is a schematic diagram of an optional access device for static file according to an embodiment of the application, as shown in the figure, the access device for static file can include: file parsing unit 61, static file query unit 62, static file extraction unit 63, backend node access unit 64. Figure 6
[0131] Wherein, the file parsing unit 61, for receiving the file access request of the front-end page, and parsing the file access request, get the file data identifier;
[0132] Static file query unit 62, for querying the file data identifier corresponding static file data in local terminal;
[0133] Static file extraction unit 63, for in the case of query result indicates that the file data identifier corresponding static file data exists, from the target file server to obtain static file data and attachments, and return the static file data and attachments to the front-end page, wherein, the target file server is mounted on the reverse proxy web server of the deployed front-end code;
[0134] Backend node access unit 64, for in the case of query result indicates that the static file data cannot be queried, output static file exception signal, and access Redis queue through the backend node, index static file data in the file server through the Redis queue, or get static file data through the target database by accessing the backend node.
[0135] The access device for static file can receive a file access request of a front-end page through the file parsing unit 61, analyze the file access request, obtain a file data identifier, query static file data corresponding to the file data identifier in a local terminal through the static file query unit 62, obtain the static file data and attachments from a target file server in a case where the query result indicates that the static file data corresponding to the file data identifier exists, and return the static file data and the attachments to the front-end page. The target file server is mounted on a reverse proxy network server on which the front-end code has been deployed. In a case where the query result indicates that the static file data cannot be queried, the static file exception signal is output through the backend node access unit 64, and the static file data in the file server is indexed through the Redis queue or the static file data is obtained through the backend node accessing the target database. In this embodiment, when receiving a user front-end access data request, the static file data and the attachments can be obtained from the local file server, instead of directly accessing the database or the Redis queue, so that the memory consumption can be greatly reduced. Once the static file exception is found, the system triggers an exception processing procedure, directly accesses the database or the Redis to obtain the data through the background node interface, and greatly reduces the access delay, thereby solving the technical problem that a large amount of memory is consumed in a high-concurrency scenario under a backend service access framework in the related art, and the access delay is prone to occurring.
[0136] Optionally, the access device for static file further includes an update instruction receiving unit configured to receive a static file storage instruction before receiving the file access request of the front-end page; an instruction response unit configured to respond to the static file storage instruction, obtain a backend interface calling rule, put the business data of the static file into the file server, and add the file data identifier into the Redis queue; and a data asynchronous processing unit configured to perform asynchronous processing on the business data of the static file according to a file operation type, where the type of the asynchronous processing includes at least one of the following: deleting a file, adding a file, and updating a file.
[0137] Optionally, the access device for static file further comprises: an instruction recognition module, configured to recognize a static file storage instruction, and create and initialize a functional static queue object according to a recognition result; an object assignment module, configured to assign attributes to the functional static queue object according to business data of the static file and parameters required for generating the static file; a queue adding module, configured to add the functional static queue object to a Redis queue, and set an expiration time interval of the functional static queue object; and a file updating module, configured to pull an update task from the Redis queue according to a predetermined periodic time interval, and convert business data corresponding to the static file storage instruction into the static file according to the update task.
[0138] Optionally, the access device for static file further comprises: an object type matching module, configured to match a corresponding static processing strategy according to an operation object type of the functional static queue object after the functional static queue object is created; and a queue initialization module, configured to initialize the Redis queue through a preset concurrent management thread pool.
[0139] Optionally, when the static file is generated, the access device for static file comprises: a script execution unit, configured to execute an initialization script, and pull a queue message containing a static task parameter from the Redis queue; a parameter checking unit, configured to perform parameter checking on the pulled queue message, and call an interface service of a server according to a uniform resource locator (URL) and a parameter obtained through the checking, to obtain static file data generated dynamically; and a format processing unit, configured to perform JSON format processing on the obtained static file data, to generate a static file, name the static file according to a predefined file naming rule, and save the static file to a file server.
[0140] Optionally, when the static file is updated, the access device for static file comprises: an update task listening unit, configured to listen to an update task in the Redis queue, wherein the update task comprises at least one of a URL, a parameter and an operation type; an access unit, configured to access a server interface according to the URL and the parameter in the update task, to obtain a static file to be updated; a data checking unit, configured to perform correctness checking and integrity checking on business data in the obtained static file to be updated; a file replacing unit, configured to replace an existing static file with the static file to be updated in a case where the checking passes, wherein the replaced file is stored according to an original naming rule; and a first task removing unit, configured to remove a queue message of the update task from the Redis queue in a case where the file replacement is completed, to confirm that the update operation is successful.
[0141] Optionally, when deleting static files, the access device for static files includes: a deletion task acquisition unit, used to obtain the deletion task in the Redis queue, wherein the deletion task includes: the URL and parameters of the static file to be deleted; a file positioning unit, used to locate the storage location of the static file to be deleted on the file server according to the URL and parameters; a file deletion unit, which executes the file deletion operation to remove the static file to be deleted; and a second task removal unit, which is used to confirm that the file deletion is successful after the removal operation is completed and remove the deletion task from the Redis queue.
[0142] The above-mentioned access device for static files can also include a processor and a memory. The above-mentioned file parsing unit 61, static file query unit 62, static file extraction unit 63, back-end node access unit 64, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.
[0143] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and high-concurrency access to static files can be achieved by adjusting kernel parameters.
[0144] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0145] Example 3
[0146] An embodiment of the present application may provide an electronic device, Figure 7 FIG is a structural block diagram of an electronic device that executes a method for accessing static files according to an embodiment of the present application. Figure 7 As shown, the electronic device may include: one or more ( Figure 7 Only one is shown) processor 702, memory 704, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0147] The memory can be configured to store software programs and modules, such as program instructions / modules corresponding to the access method and device for static files in the embodiments of the present application. The processor executes various functions and data processing by running the software programs and modules stored in the memory, that is, implements the access method for static files described above. The memory can include a high-speed random access memory, and can further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory can further include a memory remotely disposed relative to the processor, which can be connected to the terminal through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0148] The processor can call information and applications stored in the memory through the transmission device to perform the following steps: receiving a file access request of a front-end page, and parsing the file access request to obtain a file data identifier; querying the file data identifier corresponding static file data on the local terminal; in the case that the query result indicates that the file data identifier corresponds to existing static file data, obtaining the static file data and attachments from a target file server, and returning the static file data and attachments to the front-end page, wherein the target file server is mounted on a reverse proxy network server on which the front-end code has been deployed; in the case that the query result indicates that the static file data cannot be queried, outputting a static file exception signal, and accessing a Redis queue through a backend node, indexing the static file data in the file server through the Redis queue, or accessing a target database through the backend node to obtain the static file data.
[0149] Those skilled in the art can understand that, Figure 7 The structure shown is only schematic, and the electronic device can also be a terminal device such as a smart phone, a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, etc. Figure 7 It does not limit the structure of the electronic device described above. For example, the electronic device can include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 7 For example, the electronic device can include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 7 For example, the electronic device can include more or less components (such as a network interface, a display device, etc.) than those shown in the figure, or have a different configuration from that shown in the figure.
[0150] Those skilled in the art can understand that all or part of the steps of the above-mentioned various access methods for static files in the embodiments can be completed by instructing the hardware related to the terminal device by a program, and the program can be stored in a computer readable storage medium, which can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0151] Embodiment Four
[0152] The embodiments of the present application further provide a storage medium. Optionally, in the embodiments, the storage medium can be used to store the program code executed by the access method for static files provided in the first embodiment.
[0153] According to another aspect of the embodiments of the present application, a computer readable storage medium is further provided, which includes a stored computer program, wherein the computer program controls the device where the computer readable storage medium is located to execute the access method for static files in any one of the first embodiment when the computer program is running.
[0154] Optionally, in the embodiments, the storage medium can be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group.
[0155] The present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the access method for static files in the embodiments of the present application.
[0156] The present application further provides a computer program product, including a non-volatile computer readable storage medium, which stores a computer program, and the computer program, when executed by a processor, implements the steps of the access method for static files in the embodiments of the present application.
[0157] The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.
[0158] In the above-mentioned embodiments of the present application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0159] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0160] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0161] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0162] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.
[0163] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A method for accessing static files, characterized in that: include: Receive a file access request from a front-end page, and parse the file access request to obtain a file data identifier; Querying the static file data corresponding to the file data identifier at the local terminal; If the query result indicates that the file data identifier corresponds to static file data, the static file data and attachments are obtained from a target file server, and the static file data and attachments are returned to the front-end page, wherein the target file server is mounted on a reverse proxy network server on which the front-end code has been deployed; When the query result indicates that the static file data cannot be queried, a static file exception signal is output, and the Redis queue is accessed through the back-end node, and the static file data in the file server is indexed through the Redis queue, or the static file data is obtained by accessing the target database through the back-end node.
2. The method for accessing static files according to claim 1, wherein: Before receiving the file access request of the front-end page, it also includes: Receive static file storage instructions; In response to the static file storage instruction, cache the static file in the local terminal; Obtain the backend interface call rules, put the business data of the static file into the file server, and add the file data identifier to the Redis queue; According to the file operation type, asynchronous processing is performed on the business data of the static file, wherein the type of the asynchronous processing includes at least one of the following: deleting a file, adding a file, and updating a file.
3. The method for accessing static files according to claim 2, wherein: Also includes: Identify the static file storage instruction, and create and initialize a functional static queue object according to the identification result; Assigning attributes to the functional static queue object according to the business data of the static file and the parameters required to generate the static file; Add the functional static queue object to the Redis queue and set the expiration time interval of the functional static queue object; Pull the update task from the Redis queue at a predetermined periodic time interval, and convert the business data corresponding to the static file storage instruction into a static file according to the update task.
4. The method for accessing static files according to claim 3, wherein: Also includes: After creating a functional static queue object, matching a corresponding static processing strategy according to the operation object type of the functional static queue object; Initialize the Redis queue by presetting the concurrent management thread pool.
5. The method for accessing static files according to claim 1, wherein: When generating the static file, it includes: Execute the initialization script to pull queue messages containing static task parameters from the Redis queue; Perform parameter check on the pulled queue message, call the server's interface service according to the uniform resource locator URL and parameters obtained from the check, and obtain dynamically generated static file data; The obtained static file data is formatted in JSON to generate the static file, and the static file is named according to a predefined file naming rule and saved in a file server.
6. The method for accessing static files according to claim 5, characterized in that: When updating the static file, it includes: Monitor the update task in the Redis queue, wherein the update task includes at least one of the following: URL, parameters, and operation type; Access the server interface according to the URL and parameters in the update task to obtain the static file to be updated; Performing correctness and integrity checks on the business data in the acquired static file to be updated; If the verification passes, the existing static file is replaced with the static file to be updated, wherein the replaced file is stored according to the original naming rule; When the file is replaced, the update operation is confirmed to be successful, and the queue message of the update task is removed from the Redis queue.
7. The method for accessing static files according to claim 5, wherein: When deleting the static file, it includes: Obtain a deletion task in the Redis queue, wherein the deletion task includes: the URL and parameters of the static file to be deleted; Locate the storage location of the static file to be deleted on the file server according to the URL and parameters; Execute the file deletion operation to remove the static file to be deleted; After the removal operation is completed, the file is confirmed to be deleted successfully and the deletion task is removed from the Redis queue.
8. A device for accessing static files, characterized in that: include: A file parsing unit, configured to receive a file access request from a front-end page, and parse the file access request to obtain a file data identifier; A static file query unit, configured to query the static file data corresponding to the file data identifier on a local terminal; a static file extraction unit, configured to, when the query result indicates that static file data exists corresponding to the file data identifier, obtain the static file data and attachments from a target file server, and return the static file data and attachments to the front-end page, wherein the target file server is mounted on a reverse proxy network server on which the front-end code has been deployed; The back-end node access unit is used to output a static file exception signal when the query result indicates that the static file data cannot be queried, and access the Redis queue through the back-end node to index the static file data in the file server through the Redis queue, or access the target database through the back-end node to obtain the static file data.
9. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the access method for static files described in any one of claims 1 to 7.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method for accessing static files according to any one of claims 1 to 7 are implemented.