Configuration file obtaining method and device of application program, equipment and medium
By caching the application's configuration files and keywords on the server, judging the condition changes of configuration requests, filtering and returning the latest configuration files, the problem of complex and error-prone traditional configuration management methods is solved, and efficient dynamic configuration and reduced transmission are achieved pressure.
Patent Information
- Application Number
- CN202411512557.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-18
AI Technical Summary
Traditional configuration management methods are complex and error-prone, and it is difficult to meet the needs of agile development and rapid iteration in mobile application development. How to improve the configuration efficiency of applications and achieve efficient and dynamic configuration has become an urgent problem.
Provides a method for obtaining configuration files for an application. By caching the application to identify all the corresponding keywords and latest configuration files on the server, it determines whether the filtering conditions of the latest configuration request are the same as the conditions of the last request. If the same, it will be cached from the cache. The target key-value pairs and configuration files that do not match the local key-value pairs on the user side are filtered out and returned to the user side. If the conditions are different, the candidate configuration files that meet the latest request conditions will be filtered from the preset configuration files stored, and the latest configuration file will be selected to return.
By updating the configuration files in the cache in real time, the efficiency of obtaining application configuration files is improved, efficient and dynamic configuration is achieved, and data transmission and pressure are reduced between the user and server.
Smart Images

Figure CN119473429A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of application configuration, and in particular to a method, device, equipment and medium for obtaining a configuration file of an application. Background Art
[0002] Configuration management is a key task in mobile application development. Different environments (such as development, testing, and production) require different configurations, and the same application needs to quickly switch configuration files at different stages (such as development, testing, and launch). However, traditional configuration management methods are often complex and error-prone, and it is difficult to meet the needs of agile development and rapid iteration.
[0003] Therefore, how to improve the configuration efficiency of applications and achieve efficient dynamic configuration has become an urgent problem to be solved. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, equipment and medium for obtaining configuration files of an application program in order to improve the configuration efficiency of the application program and realize efficient dynamic configuration in response to the above technical problems.
[0005] A method for obtaining a configuration file of an application, applied to a server, the method comprising: Obtaining the latest configuration request sent by the user end, the latest configuration request including the application identifier, the configuration file screening condition of the latest configuration request, the configuration file screening condition of the last configuration request, and the local key-value pair of the user end, the keyword in the key-value pair is used to represent the configuration item of the application, the key value in the key-value pair is used to represent the version of the configuration file, and the configuration file includes the configuration data of the configuration item; Determining whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request; If they are the same, all keywords corresponding to the application identifier are filtered out from the first storage device, the first storage device is used to cache all keywords corresponding to each application identifier received by the server before receiving the latest configuration request, the latest configuration file of the configuration item represented by each keyword, and the key-value pair representing the corresponding relationship between the configuration item and the version of the latest configuration file, and the configuration condition of the latest configuration file is the same as at least one configuration file filtering condition received by the server before receiving the latest configuration request; Filtering out target key-value pairs that do not match the local key-value pairs of the user terminal from the key-value pairs corresponding to all the keywords on the first storage device; The target key-value pair and the configuration file of the version represented by the key value in the target key-value pair are returned to the user end.
[0006] In an embodiment of the present application, the method further includes: If they are not the same, all keywords corresponding to the application identifier are filtered out from the second storage device, where the second storage device is used to store all keywords corresponding to each preset application identifier, all configuration files of the configuration items represented by each keyword, and key-value pairs representing the corresponding relationship between the configuration items and the versions of the configuration files; For each keyword corresponding to the application identifier, filter out candidate configuration files whose configuration conditions are the same as the configuration file screening conditions of the latest configuration request from all configuration files corresponding to the keyword on the second storage device; Filter out a target configuration file with the latest version from the candidate configuration files; Returning the target configuration file and the key-value pair corresponding to the target configuration file to the user terminal; The target configuration file and the key-value pair corresponding to the target configuration file are cached in the first storage device.
[0007] In some embodiments, the method for obtaining a configuration file of an application further includes: After the key-value pair and the configuration file stored in the second storage device are changed on the development side, an application identifier corresponding to the change is obtained as a target application identifier; Updating all configuration files corresponding to the target application identifier in the first storage device to the latest versions of all configuration files corresponding to the target application identifier in the second storage device; The key-value pair corresponding to the target application identifier in the first storage device is updated to the key-value pairs corresponding to all configuration files of the latest version in the second storage device.
[0008] In some embodiments, the determining whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request includes: Obtaining a hash value corresponding to the configuration file screening condition of the latest configuration request and a hash value corresponding to the configuration file screening condition of the previous configuration request; Comparing whether the hash value corresponding to the configuration file screening condition of the latest configuration request is the same as the hash value corresponding to the configuration file screening condition of the previous configuration request; If they are the same, determining that the configuration file screening condition of the previous configuration request is the same as the configuration file screening condition of the latest configuration request; If they are different, it is determined that the configuration file screening condition of the last configuration request is different from the configuration file screening condition of the latest configuration request.
[0009] In some embodiments, after filtering out, for each keyword corresponding to the application identifier, candidate configuration files whose configuration conditions are the same as the configuration file screening conditions of the latest configuration request from all configuration files corresponding to the keyword on the second storage device, the method further includes: Determine whether the candidate configuration file exists; If it does not exist, the backup file in all configuration files corresponding to the keyword is used as the target configuration file; If so, the step of filtering out the target configuration file with the latest version from the candidate configuration files is performed.
[0010] In some embodiments, the configuration file screening condition of the latest configuration request includes at least one of the following: application version, application download channel, device identification of the user terminal, and publishing environment of the configuration file.
[0011] In some embodiments, the latest configuration request sent by the user terminal is sent based on a preset trigger condition, and the preset trigger condition includes at least one of the following: application startup, application switching between foreground and background, user logging in or out of the application.
[0012] A device for obtaining a configuration file of an application program, applied to a server, the method comprising: an acquisition module, configured to acquire the latest configuration request sent by the user terminal, wherein the latest configuration request includes an application identifier, a configuration file screening condition of the latest configuration request, a configuration file screening condition of the last configuration request, and a key-value pair local to the user terminal, wherein the keyword in the key-value pair is used to represent a configuration item of the application, the key value in the key-value pair is used to represent a version of a configuration file, and the configuration file includes configuration data of the configuration item; A determination module, used to determine whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request; a first filtering module, configured to filter out all keywords corresponding to the application identifier from a first storage device if they are the same, the first storage device being configured to cache all keywords corresponding to each application identifier received by the server before receiving the latest configuration request, the latest configuration file of the configuration item represented by each keyword, and a key-value pair representing the corresponding relationship between the configuration item and the version of the latest configuration file, wherein the configuration condition of the latest configuration file is the same as at least one configuration file filtering condition received by the server before receiving the latest configuration request; A second screening module, configured to screen out target key-value pairs that do not match the local key-value pairs of the user terminal from the key-value pairs corresponding to all the keywords on the first storage device; The sending module is used to return the target key-value pair and the configuration file of the version represented by the key value in the target key-value pair to the user end.
[0013] In an embodiment of the present application, the device also includes a third filtering module, which is used to: if they are not the same, filter out all keywords corresponding to the application identifier from the second storage device, the second storage device being used to store all keywords corresponding to each preset application identifier, all configuration files of the configuration items represented by each keyword, and key-value pairs representing the correspondence between the versions of the configuration items and the configuration files; for each keyword corresponding to the application identifier, filter out candidate configuration files whose configuration conditions are the same as the configuration file filtering conditions of the latest configuration request from all configuration files corresponding to the keyword on the second storage device; filter out the target configuration file with the latest version from the candidate configuration files; return the target configuration file and the key-value pair corresponding to the target configuration file to the user end; cache the target configuration file and the key-value pair corresponding to the target configuration file in the first storage device.
[0014] In some embodiments, the device is further used to: After the key-value pair and the configuration file stored in the second storage device are changed on the development side, an application identifier corresponding to the change is obtained as a target application identifier; Updating all configuration files corresponding to the target application identifier in the first storage device to the latest versions of all configuration files corresponding to the target application identifier in the second storage device; The key-value pair corresponding to the target application identifier in the first storage device is updated to the key-value pairs corresponding to all configuration files of the latest version in the second storage device.
[0015] In some embodiments, the determination module is used to: Obtaining a hash value corresponding to the configuration file screening condition of the latest configuration request and a hash value corresponding to the configuration file screening condition of the previous configuration request; Comparing whether the hash value corresponding to the configuration file screening condition of the latest configuration request is the same as the hash value corresponding to the configuration file screening condition of the previous configuration request; If they are the same, determining that the configuration file screening condition of the previous configuration request is the same as the configuration file screening condition of the latest configuration request; If they are different, it is determined that the configuration file screening condition of the last configuration request is different from the configuration file screening condition of the latest configuration request.
[0016] In some embodiments, the third screening module is used to: Determine whether the candidate configuration file exists; If it does not exist, the backup file in all configuration files corresponding to the keyword is used as the target configuration file; If so, the step of filtering out the target configuration file with the latest version from the candidate configuration files is performed.
[0017] In some embodiments, the configuration file screening condition of the latest configuration request includes at least one of the following: application version, application download channel, device identification of the user terminal, and publishing environment of the configuration file.
[0018] In some embodiments, the latest configuration request sent by the user terminal is sent based on a preset trigger condition, and the preset trigger condition includes at least one of the following: application startup, application switching between foreground and background, user logging in or out of the application.
[0019] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for obtaining a configuration file of an application program as described in the above embodiment are implemented.
[0020] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for obtaining a configuration file of an application program as described in the above embodiment.
[0021] In summary, the present application proposes a method, device, equipment and medium for obtaining a configuration file of an application. The present application utilizes a first storage device to cache all keywords corresponding to each application identifier received by the server, the latest configuration conditions of the configuration items identified by each keyword, and the key-value pairs representing the corresponding relationship between the configuration items and the version of the latest configuration file. After receiving the latest configuration request sent by the user end, it is determined whether the conditions referred to when filtering the configuration file for the latest configuration request are the same as the conditions referred to when filtering the configuration file for the last configuration request. If the conditions are the same, it is considered that all keywords corresponding to the application identifier in the latest configuration request are cached in the first storage device, and the key-value pairs containing these keywords are compared with the local key-value pairs of the user end. The key-value pairs that do not match the local key-value pairs of the user end are filtered out as target key-value pairs. The target key-value pairs can be the key-value pairs of the newly added configuration items locally on the user end or the key-value pairs of the configuration items that have not been updated in the configuration file; the target key-value pairs and the configuration file of the version represented by the key values in the target key-value pairs are returned to the user end to update the configuration file of the configuration item on the user end. This application updates the configuration files recorded in the cache in real time, so that the next time the user requests a configuration file with the same filter conditions, the configuration files of the newly added configuration items for the application and the updated configuration files in the cache can be directly returned to the user. In this way, the efficiency of sending configuration files to the application is improved, efficient dynamic configuration is achieved, and the transmission data and transmission pressure of the user and server are reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0023] Figure 1 is a flowchart of a method for obtaining a configuration file of an application program according to an exemplary embodiment of the present application; Figure 2 is a flowchart of a method for obtaining a configuration file of an application program according to an exemplary embodiment of the present application; Figure 3 is a flowchart of a method for obtaining a configuration file of an application program according to another exemplary embodiment of the present application; Figure 4 is a flowchart of a method for obtaining a configuration file of an application program according to another exemplary embodiment of the present application; Figure 5is a flowchart of a method for obtaining a configuration file of an application program according to another exemplary embodiment of the present application; Figure 6 is a schematic block diagram of a device for acquiring a configuration file of an application according to another exemplary embodiment of the present application; Figure 7 It is a schematic block diagram of an electronic device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. The embodiments described by reference to the drawings are exemplary and are intended to be used to explain the present application, and cannot be understood as limiting the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0025] The present invention provides a method for obtaining a configuration file of an application. The method can be applied to a server that provides an application configuration function. The server receives an APP configuration request sent by a user end that has an application (APP) installed, and obtains the configuration file that needs to be returned to the user end from a hierarchical storage device in response to the APP configuration request, and returns these configuration files to the user end. This application uses a storage device at a certain level in the hierarchical storage to uniformly cache the configuration file that has been sent to the user end and the configuration items to which the configuration file belongs, the application to which the configuration item belongs, and other information that has a corresponding relationship with the configuration file; after the configuration file development end changes the configuration file stored in the server end, the configuration file in the cache is updated accordingly, so that the cache always stores the latest version of the configuration file of all configuration items under the APP corresponding to the APP configuration request that the server end has responded to, so that when the APP requests the configuration file again, the server end can quickly search for the configuration file that is missing locally on the user end or the configuration file that is inconsistent with the local version for the APP in the cache, and return these configuration files to the user end for application configuration. Thereby, fast and efficient acquisition of application configuration files is achieved, and the amount of data transmitted between the server end and the user end is reduced.
[0026] Figure 1 FIG. 1 is a flow chart of a method for obtaining a configuration file of an application program according to an exemplary embodiment of the present application. Figure 1 As shown, the method for obtaining the configuration file of the application includes the following steps: S101, obtaining the latest configuration request sent by the user terminal, the latest configuration request including an application identifier, a configuration file screening condition of the latest configuration request, a configuration file screening condition of the previous configuration request, and a key-value pair local to the user terminal, the keyword in the key-value pair being used to represent a configuration item of the application, the key value in the key-value pair being used to represent a version of a configuration file, and the configuration file including configuration data of the configuration item.
[0027] When the user end configures the application installed on the end, it generates a latest configuration request for the APP and sends the generated latest configuration request to the server end, so that the server end responds to the latest configuration request and returns the configuration file required by the user end to the user end.
[0028] The application identifier is used to mark the APP, for example, the application identifier can be the APP package name or the APP ID; About the screening conditions: In the embodiment of the present application, each latest configuration request sent by the user end includes the screening conditions of the configuration plan, so that the server end can refer to the screening conditions and filter out the configuration files that are finally returned to the user end from the configuration files stored by the server end. The screening conditions may include but are not limited to at least one of the following: APP version, APP download channel, APP release environment, user ID, device ID, etc. In order to provide targeted configuration files for the APP. For example, different configuration files are provided for different versions of APP, APP downloaded from different channels, APP in gray environment / pre-release environment / production environment, APP used by different users to log in, and different devices where the APP is installed, and personalized solution configuration is performed to achieve accurate configuration for thousands of people. Each latest configuration request sent by the user end includes two screening conditions, one is the configuration file screening condition A of the latest configuration request, and the other is the configuration file B of the last configuration request; It is not difficult to understand that the configuration file screening condition A of the latest configuration request is used to screen out the configuration files that meet condition A for the latest configuration request and are obtained by the user end through the latest configuration request; or it can be understood as: the conditions for screening configuration files for the latest configuration request. The configuration file screening condition B of the last configuration request is used to screen out the configuration files that meet condition B for the last configuration request and that the user end wants to obtain through the last configuration request; or it can be understood as: the conditions for screening configuration files for the last configuration request. For example, the configuration file screening condition A of the latest configuration request may include that the APP version is 1.0, the APP download channel is the application store download, the APP release environment is the grayscale environment, and the device ID is 00001; the configuration file screening condition B of the last configuration request may include that the APP version is 2.0, the APP download channel is the browser download, the APP release environment is the production environment, and the device ID is 00002.
[0029] Among them, the configuration items can be understood as different fine-grained functions in the application that need to obtain configuration files, for example, page display as a configuration item, image loading as a configuration item, obtaining a certain parameter as a configuration item, and so on.
[0030] S102: Determine whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request.
[0031] Determine whether the conditions for filtering the configuration files for the latest configuration request are the same as the conditions for filtering the configuration files for the previous configuration request. For example, determine whether the parameters set in the two filtering conditions are the same: whether the APP versions are the same, whether the APP download channels are the same, whether the APP release environments are the same, etc. If all the parameters are the same, the two filtering conditions are considered to be the same, and if they are different, the two filtering conditions are considered to be different.
[0032] S103: If they are the same, filter out all keywords corresponding to the application identifier from the first storage device.
[0033] When the configuration file screening conditions of the latest configuration request are the same as those of the last configuration request, it is considered that the configuration file returned by the server to the user in response to the latest configuration request and the configuration file returned to the user in response to the last configuration request are screened according to the same screening conditions. That is, the configuration file returned to the user in response to the latest configuration request and the configuration file returned to the user in response to the last configuration request are applicable to APPs with the same APP version, the same APP download channel, and the same APP release environment.
[0034] In an embodiment of the present application, the first storage device is used to cache all keywords corresponding to each application identifier received by the server, the latest configuration file of each configuration item represented by the keyword, and key-value pairs representing the correspondence between the configuration item and the version of the latest configuration file, and the configuration condition of the latest configuration file is the same as at least one configuration file screening condition received by the server.
[0035] S104: Filter out target key-value pairs that do not match the local key-value pairs of the user terminal from the key-value pairs corresponding to all the keywords on the first storage device.
[0036] Using the application identifier, searching the first storage device for keywords cached by the first storage device for the application represented by the application identifier, and searching for key-value pairs where each keyword is located for these keywords; Compare the found key-value pairs with the local key-value pairs on the user side provided in the configuration request; if a key-value pair only exists in the found key-value pairs, then the key-value pair is the target key-value pair; that is, filter out the key-value pairs that are not in the local key-value pairs on the user side from the found key-value pairs. For example, if a keyword does not exist in the local key-value pairs on the user side or the key value of a keyword is different from the key value of the keyword in the local key-value pairs on the user side, it can be concluded that the key-value pair where the keyword is located does not match the local key-value pair on the user side.
[0037] S105, returning the target key-value pair and the configuration file of the version represented by the key value in the target key-value pair to the user terminal.
[0038] The configuration file returned to the user end may include: a configuration file of a configuration item newly added by the developer for the application represented by the application identifier, and / or a configuration file after a version update of a configuration item under the application represented by the application identifier.
[0039] In summary, the present application proposes a method for obtaining a configuration file of an application. The present application utilizes a first storage device to cache all keywords corresponding to each application identifier received by the server, the latest configuration conditions of the configuration items identified by each keyword, and the key-value pairs representing the corresponding relationship between the configuration items and the versions of the latest configuration files. After receiving the latest configuration request sent by the user end, it is determined whether the conditions referred to when filtering the configuration files for the latest configuration request are the same as the conditions referred to when filtering the configuration files for the last configuration request. If the conditions are the same, it is considered that all keywords corresponding to the application identifier in the latest configuration request are cached in the first storage device, and the key-value pairs containing these keywords are compared with the local key-value pairs of the user end. The key-value pairs that do not match the local key-value pairs of the user end are filtered out as target key-value pairs. The target key-value pairs can be the key-value pairs of the newly added configuration items locally on the user end or the key-value pairs of the configuration items that have not been updated in the configuration file; the target key-value pairs and the configuration files of the versions represented by the key values in the target key-value pairs are returned to the user end to update the configuration files of the configuration items on the user end. This application updates the configuration files recorded in the cache in real time, so that the next time the user requests a configuration file with the same filter conditions, the configuration files of the newly added configuration items for the application and the updated configuration files in the cache can be directly returned to the user. In this way, the efficiency of sending configuration files to the application is improved, efficient dynamic configuration is achieved, and the transmission data and transmission pressure of the user and server are reduced.
[0040] Based on the above embodiments, Figure 2As shown, after step S102 "determining whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request", the configuration file acquisition method of the application proposed in the present application may further include the following steps: S201, if they are not the same, filter out all keywords corresponding to the application identifier from the second storage device, and the second storage device is used to store all keywords corresponding to each preset application identifier, all configuration files of the configuration items represented by each keyword, and key-value pairs representing the correspondence between the versions of the configuration items and the configuration files.
[0041] S202, for each keyword corresponding to the application identifier, filter out candidate configuration files whose configuration conditions are the same as the configuration file screening conditions of the latest configuration request from all configuration files corresponding to the keyword on the second storage device; S203, filtering out a target configuration file with the latest version from the candidate configuration files; S204: Return the target configuration file and the key-value pair corresponding to the target configuration file to the user terminal.
[0042] S205: Cache the target configuration file and the key-value pair corresponding to the target configuration file in the first storage device.
[0043] The second storage device can be a database, which is used to store configuration files of various versions of all configuration items under different applications. When the configuration file screening condition of the latest configuration request sent by the user end is different from the configuration file screening condition of the previous configuration request, it is considered that the configuration request received by the server this time may be that the user end obtains a configuration file for the APP after the APP version is updated, or obtains a configuration file for the APP downloaded again from different channels, etc. In this case, there is no configuration file in the cache with the same configuration conditions as the configuration file screening conditions of the latest configuration request. It is necessary to filter the configuration files with the same configuration file screening conditions as the latest configuration request from the database storing all configuration files. The latest versions of these configuration files are returned to the user end, and the key-value pairs representing the correspondence between the latest version of the configuration file and the configuration items are also returned to the user end, so that the user end records the configuration files of each configuration item obtained from the server for the first time using the configuration file screening conditions of the latest configuration request.
[0044] After returning the configuration file and the key-value pair to the user terminal, if the configuration file and the key-value pair returned to the user terminal are not found in the first storage device, the configuration file and the key-value pair returned to the user terminal are cached in the first storage device.
[0045] In this way, the embodiment of the present application refers to a configuration file filtering condition sent for the first time by the user end, searches for and returns the latest version of the configuration file of all configuration items under the application identifier that meet the configuration file filtering condition for the user end, and returns a key-value pair representing the relationship between the configuration item and the configuration file version. This facilitates the server to extract the changed configuration file from the cache and return it to the user end when the user end requests the configuration file with the same configuration file filtering condition, without having to send the configuration files of all configuration items to the user end, thereby providing a guarantee for the complete configuration of the user end's APP, and at the same time saving data transmission pressure and improving the speed of issuing configuration files during the dynamic configuration of the APP.
[0046] Based on the above embodiments, Figure 3 As shown, the configuration file acquisition of the application provided in the embodiment of the present application also includes the step of updating the configuration file, keywords, and key-value pairs stored in the first storage device in the following manner: S301, after the development end changes the key-value pair and the configuration file stored in the second storage device, obtain the application identifier corresponding to the change as the target application identifier; S302, updating all configuration files corresponding to the target application identifier in the first storage device to the latest versions of all configuration files corresponding to the target application identifier in the second storage device; S303: Update the key-value pair corresponding to the target application identifier in the first storage device to the key-value pairs corresponding to all configuration files of the latest version in the second storage device.
[0047] In practice, developers can modify the configuration files and key-value pairs stored in the second storage device through the development system of the development end. For example, if a configuration item is added to a certain application, a keyword representing the configuration item is created in the second storage device, and a new version number is created for the configuration file set for the configuration item to generate a key-value pair of the configuration item and the configuration file version. Or if a new version of the configuration file is added to a configuration item under a certain application, a key-value pair representing the corresponding relationship between the version of the new version of the configuration file and the configuration item is created in the second storage device.
[0048] In the embodiment of the present application, after the development end completes the change of the configuration file and the key-value pair in the second storage device, the application identifier involved in the change process is obtained, that is, the application identifier corresponding to the change - the target application identifier.
[0049] Search for all configuration files corresponding to the target application identifier in the first storage device, and update all the found configuration files to all the configuration files of the latest version corresponding to the target application identifier in the second storage device. At the same time, the keywords and key-value pairs corresponding to the target application identifier in the first storage device are also updated to the keywords and key-value pairs corresponding to all the configuration files of the above-mentioned latest version in the second storage device.
[0050] In the embodiment of the present application, after the developer adds a new keyword in the database, adds a new version of the configuration file for the new keyword, and adds a new version of the configuration file for the existing keyword, the keyword, configuration file, and key-value pair in the redis cache are updated accordingly, so that the latest version of the configuration file that meets a certain configuration file screening condition is always cached in redis for the application that the server has responded to. This lays the foundation for the efficient implementation of dynamic configuration of APP.
[0051] Based on the above embodiments, Figure 4 As shown, in the above step S102, "determining whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request" includes the following steps: S401, obtaining a hash value corresponding to a configuration file screening condition of the latest configuration request and a hash value corresponding to a configuration file screening condition of the previous configuration request; S402, comparing whether the hash value corresponding to the configuration file screening condition of the latest configuration request is the same as the hash value corresponding to the configuration file screening condition of the previous configuration request; S403, if the two are the same, determining that the configuration file screening condition of the previous configuration request is the same as the configuration file screening condition of the latest configuration request; S404: If they are different, determining that the configuration file screening condition of the previous configuration request is different from the configuration file screening condition of the latest configuration request.
[0052] A hash function is used to calculate the hash value corresponding to the configuration file filter condition of the latest configuration request, and the hash value corresponding to the configuration file filter condition of the previous configuration request, and the hash values corresponding to the two filter conditions are compared to see if they are the same. If they are the same, the two filter conditions are considered to be the same; if they are different, the two filter conditions are considered to be different.
[0053] Hash algorithms are usually designed to be very fast and can complete the calculation of hash values in constant time. Therefore, comparing hash values to determine whether two conditions are the same is much faster than directly comparing the two conditions themselves (especially when the conditions themselves are large or complex, such as large files, complex data structures, etc.). In this way, the embodiment of the present application can quickly determine whether the configuration file screening conditions of the latest configuration request are the same as the configuration file screening conditions of the previous configuration request.
[0054] In some embodiments, the server can calculate a hash value (such as an MD5 value) for any filtering condition received, and assign the calculated hash value to the condition flag in the response message returned to the user end. The user end can store the condition flag. Before sending the latest configuration request next time, if the filtering condition to be set is the same as the filtering condition set for the configuration request last time, the flag can be written in the latest configuration condition; if the filtering condition to be set is different from the filtering condition set for the configuration request last time, the flag can be written in the latest configuration condition or not.
[0055] After the server receives the latest configuration request, it is determined whether the flag bit exists in the latest configuration request. If not, it can be considered that the configuration file screening condition of the latest configuration request is different from the configuration file screening condition of the previous configuration request. If so, the hash value of the configuration file screening condition of the latest configuration request is further calculated, and the hash value of the configuration file screening condition of the latest configuration request is compared with the value of the flag bit to see if they are the same. If they are the same, it is considered that the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request; if they are not the same, it is considered that the configuration file screening condition of the latest configuration request is different from the configuration file screening condition of the previous configuration request.
[0056] Based on the above embodiments, Figure 5 As shown, after the above step S202 of "for each of the keywords corresponding to the application identifier, filtering out candidate configuration files whose configuration conditions are the same as the configuration file screening conditions of the latest configuration request from all configuration files corresponding to the keywords on the second storage device", the following steps are also included: S501, determining whether the candidate configuration file exists; S502, if it does not exist, taking the backup file in all configuration files corresponding to the keyword as the target configuration file; S503: If it exists, the step of filtering out the target configuration file with the latest version from the candidate configuration files is performed.
[0057] In an embodiment of the present application, a fallback solution is stored in the second storage device for each keyword. When searching for a candidate configuration file that meets the configuration file screening condition of the latest configuration request from all configuration files corresponding to the keyword on the second storage device, if no candidate configuration file that meets the configuration file screening condition of the latest configuration request is found, the fallback file under the keyword is used as the target configuration file.
[0058] The backup file can be understood as the initial version configuration file of the configuration item corresponding to the keyword.
[0059] If candidate configuration files satisfying the configuration file screening condition of the latest configuration request are found, a candidate configuration file with the latest version among the candidate configuration files is used as the target configuration file.
[0060] By setting and selecting a fallback file, this application can still provide a fallback configuration that can be used normally to the user end when the configuration file screening conditions that meet the latest configuration request are not stored in the first storage device, thereby ensuring that the APP can start and run normally.
[0061] Based on the above embodiments, the configuration request sent by the user terminal in the embodiments of the present application can be sent based on preset trigger conditions, and the preset trigger conditions can include but are not limited to application startup, application switching between foreground and background, and user logging in or out of the application.
[0062] The configuration file acquisition method of the application proposed in the embodiment of the present application can be applied to the C-end service of the configuration center. The structure of the configuration center can be mainly divided into three layers, namely: configuration center OA-end service, configuration center C-end service and APP-end configuration center SDK. Configuration center OA-end service: mainly used to provide configuration services for APP. Developers can add or modify keywords for APP and add or modify solutions for keywords through the page interface or API interface, which is equivalent to the above-mentioned development end.
[0063] Configuration center C-end service: The main function is to provide a C-end interface and provide services for APP configuration queries. According to the query conditions on the APP side, three-level storage of memory, redis cache, and configuration center DB can be realized, which is equivalent to the above-mentioned server. In this case, the redis cache is used as the above-mentioned first storage device, and the memory and DB database are used as the above-mentioned second storage devices. When it is necessary to find a configuration file from the second storage device, it can be searched in the memory first. If it does not exist in the memory, continue to search in the database. In some embodiments, the database can be used to store all configuration files to reduce local storage pressure.
[0064] Configuration center APP (SDK): At the appropriate time, call the C-end service interface to update the local configuration, which is equivalent to the above-mentioned user end.
[0065] When storing configuration files, the management of APP keywords and keyword schemes can be achieved through the three-level interface structure of application (APP) -> keywords -> keyword schemes. The management of APP components, as well as keywords and keyword schemes under components, can be achieved through the four-level interface structure of application (APP) -> components -> keywords -> keyword schemes. The keyword scheme may include the following: configuration files, configuration conditions of configuration files, version numbers of each configuration file, key-value pairs, etc.
[0066] When adding configuration files for keywords, a fallback file must be added under each keyword. In addition to the fallback file, multiple configuration files can be set based on conditions (APP version, channel, etc.). Each configuration file supports multiple release policies based on user ID or device ID. When the APP requests configuration, the configuration file that matches the filter condition is sent according to the filter condition. If there is no matching configuration file, the fallback file is returned.
[0067] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0068] Figure 6 is a block diagram of a configuration file acquisition device for an application according to an exemplary embodiment of the present application. Figure 6 As shown, the device 600 includes: an acquisition module 601, a judgment module 602, a first screening module 603, a second screening module 604 and a sending module 605.
[0069] The acquisition module 601 is used to acquire the latest configuration request sent by the user end, wherein the latest configuration request includes an application identifier, a configuration file screening condition of the latest configuration request, a configuration file screening condition of the last configuration request, and a key-value pair of the local user end, wherein the keyword in the key-value pair is used to represent a configuration item of the application, the key value in the key-value pair is used to represent a version of a configuration file, and the configuration file includes configuration data of the configuration item; A determination module 602 is used to determine whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request; A first filtering module 603 is used to filter out all keywords corresponding to the application identifier from a first storage device if they are the same, the first storage device is used to cache all keywords corresponding to each application identifier received by the server before receiving the latest configuration request, the latest configuration file of the configuration item represented by each keyword, and the key-value pairs representing the corresponding relationship between the configuration item and the version of the latest configuration file, and the configuration condition of the latest configuration file is the same as at least one configuration file filtering condition received by the server before receiving the latest configuration request; A second screening module 604 is used to screen out target key-value pairs that do not match the local key-value pairs of the user terminal from the key-value pairs corresponding to all the keywords on the first storage device; The sending module 605 is used to return the target key-value pair and the configuration file of the version represented by the key value in the target key-value pair to the user end.
[0070] In an embodiment of the present application, the device also includes a third filtering module, which is used to: if they are not the same, filter out all keywords corresponding to the application identifier from the second storage device, the second storage device being used to store all keywords corresponding to each preset application identifier, all configuration files of the configuration items represented by each keyword, and key-value pairs representing the correspondence between the versions of the configuration items and the configuration files; for each keyword corresponding to the application identifier, filter out candidate configuration files whose configuration conditions are the same as the configuration file filtering conditions of the latest configuration request from all configuration files corresponding to the keyword on the second storage device; filter out the target configuration file with the latest version from the candidate configuration files; return the target configuration file and the key-value pair corresponding to the target configuration file to the user end; cache the target configuration file and the key-value pair corresponding to the target configuration file in the first storage device.
[0071] In some embodiments, the device is further used to: After the key-value pair and the configuration file stored in the second storage device are changed on the development side, an application identifier corresponding to the change is obtained as a target application identifier; Updating all configuration files corresponding to the target application identifier in the first storage device to the latest versions of all configuration files corresponding to the target application identifier in the second storage device; The key-value pair corresponding to the target application identifier in the first storage device is updated to the key-value pairs corresponding to all configuration files of the latest version in the second storage device.
[0072] In some embodiments, the determination module is used to: Obtaining a hash value corresponding to the configuration file screening condition of the latest configuration request and a hash value corresponding to the configuration file screening condition of the previous configuration request; Comparing whether the hash value corresponding to the configuration file screening condition of the latest configuration request is the same as the hash value corresponding to the configuration file screening condition of the previous configuration request; If they are the same, determining that the configuration file screening condition of the previous configuration request is the same as the configuration file screening condition of the latest configuration request; If they are different, it is determined that the configuration file screening condition of the last configuration request is different from the configuration file screening condition of the latest configuration request.
[0073] In some embodiments, the third screening module is used to: Determine whether the candidate configuration file exists; If it does not exist, the backup file in all configuration files corresponding to the keyword is used as the target configuration file; If so, the step of filtering out the target configuration file with the latest version from the candidate configuration files is performed.
[0074] In some embodiments, the configuration file screening condition of the latest configuration request includes at least one of the following: application version, application download channel, device identification of the user terminal, and publishing environment of the configuration file.
[0075] In some embodiments, the latest configuration request sent by the user terminal is sent based on a preset trigger condition, and the preset trigger condition includes at least one of the following: application startup, application switching between foreground and background, user logging in or out of the application.
[0076] In summary, the present application proposes a configuration file acquisition device for an application. The present application utilizes a first storage device to cache all keywords corresponding to each application identifier received by the server, the latest configuration conditions of the configuration items identified by each keyword, and the key-value pairs representing the corresponding relationship between the configuration items and the versions of the latest configuration files. After receiving the latest configuration request sent by the user end, it is determined whether the conditions referred to when filtering the configuration files for the latest configuration request are the same as the conditions referred to when filtering the configuration files for the last configuration request. If the conditions are the same, it is considered that all keywords corresponding to the application identifier in the latest configuration request are cached in the first storage device, and the key-value pairs containing these keywords are compared with the local key-value pairs of the user end. The key-value pairs that do not match the local key-value pairs of the user end are filtered out as target key-value pairs. The target key-value pairs can be the key-value pairs of the newly added configuration items locally on the user end or the key-value pairs of the configuration items that have not been updated in the configuration file; the target key-value pairs and the configuration files of the versions represented by the key values in the target key-value pairs are returned to the user end to update the configuration files of the configuration items on the user end. This application updates the configuration files recorded in the cache in real time, so that the next time the user requests a configuration file with the same filter conditions, the configuration files of the newly added configuration items for the application and the updated configuration files in the cache can be directly returned to the user. In this way, the efficiency of sending configuration files to the application is improved, efficient dynamic configuration is achieved, and the transmission data and transmission pressure of the user and server are reduced.
[0077] To implement the above embodiment, Figure 7 As shown, an embodiment of the present application further proposes an electronic device 700, comprising a memory 701, a processor 702, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method for obtaining a configuration file of the application as described in the above embodiment are implemented.
[0078] To implement the above embodiment, the embodiment of the present application further proposes a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method for obtaining a configuration file of an application program as described in the above embodiment are implemented.
[0079] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0080] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0081] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for obtaining a configuration file of an application, characterized in that: Applied to the server, the method includes: Obtaining the latest configuration request sent by the user end, the latest configuration request including the application identifier, the configuration file screening condition of the latest configuration request, the configuration file screening condition of the last configuration request, and the local key-value pair of the user end, the keyword in the key-value pair is used to represent the configuration item of the application, the key value in the key-value pair is used to represent the version of the configuration file, and the configuration file includes the configuration data of the configuration item; Determining whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request; If they are the same, all keywords corresponding to the application identifier are filtered out from the first storage device, the first storage device is used to cache all keywords corresponding to each application identifier received by the server before receiving the latest configuration request, the latest configuration file of the configuration item represented by each keyword, and the key-value pair representing the corresponding relationship between the configuration item and the version of the latest configuration file, and the configuration condition of the latest configuration file is the same as at least one configuration file filtering condition received by the server before receiving the latest configuration request; Filtering out target key-value pairs that do not match the local key-value pairs of the user terminal from the key-value pairs corresponding to all the keywords on the first storage device; The target key-value pair and the configuration file of the version represented by the key value in the target key-value pair are returned to the user end.
2. The method according to claim 1, characterized in that The method further comprises: If they are not the same, all keywords corresponding to the application identifier are filtered out from the second storage device, where the second storage device is used to store all keywords corresponding to each preset application identifier, all configuration files of the configuration items represented by each keyword, and key-value pairs representing the corresponding relationship between the configuration items and the versions of the configuration files; For each keyword corresponding to the application identifier, filter out candidate configuration files whose configuration conditions are the same as the configuration file screening conditions of the latest configuration request from all configuration files corresponding to the keyword on the second storage device; Filter out a target configuration file with the latest version from the candidate configuration files; Returning the target configuration file and the key-value pair corresponding to the target configuration file to the user terminal; The target configuration file and the key-value pair corresponding to the target configuration file are cached in the first storage device.
3. The method according to claim 2, characterized in that Also includes: After the key-value pair and the configuration file stored in the second storage device are changed on the development side, an application identifier corresponding to the change is obtained as a target application identifier; Updating all configuration files corresponding to the target application identifier in the first storage device to the latest versions of all configuration files corresponding to the target application identifier in the second storage device; The key-value pair corresponding to the target application identifier in the first storage device is updated to the key-value pairs corresponding to all configuration files of the latest version in the second storage device.
4. The method according to claim 1, characterized in that The determining whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request includes: Obtaining a hash value corresponding to the configuration file screening condition of the latest configuration request and a hash value corresponding to the configuration file screening condition of the previous configuration request; Comparing whether the hash value corresponding to the configuration file screening condition of the latest configuration request is the same as the hash value corresponding to the configuration file screening condition of the previous configuration request; If they are the same, determining that the configuration file screening condition of the previous configuration request is the same as the configuration file screening condition of the latest configuration request; If they are different, it is determined that the configuration file screening condition of the last configuration request is different from the configuration file screening condition of the latest configuration request.
5. The method according to claim 2, characterized in that After filtering out, for each keyword corresponding to the application identifier, candidate configuration files whose configuration conditions are the same as the configuration file screening conditions of the latest configuration request from all configuration files corresponding to the keyword on the second storage device, the method further includes: Determine whether the candidate configuration file exists; If it does not exist, the backup file in all configuration files corresponding to the keyword is used as the target configuration file; If so, the step of filtering out the target configuration file with the latest version from the candidate configuration files is performed.
6. The method according to any one of claims 1 to 5, characterized in that: The configuration file screening condition of the latest configuration request includes at least one of the following: application version, application download channel, device identification of the user terminal, and publishing environment of the configuration file.
7. The method according to claims 1 to 5, characterized in that The latest configuration request sent by the user terminal is sent based on a preset trigger condition, and the preset trigger condition includes at least one of the following: application startup, application switching between foreground and background, and user logging in or out of the application.
8. A device for obtaining a configuration file of an application, characterized in that: Applied to the server, including: an acquisition module, configured to acquire the latest configuration request sent by the user terminal, wherein the latest configuration request includes an application identifier, a configuration file screening condition of the latest configuration request, a configuration file screening condition of the last configuration request, and a key-value pair local to the user terminal, wherein the keyword in the key-value pair is used to represent a configuration item of the application, the key value in the key-value pair is used to represent a version of a configuration file, and the configuration file includes configuration data of the configuration item; A determination module, used to determine whether the configuration file screening condition of the latest configuration request is the same as the configuration file screening condition of the previous configuration request; a first filtering module, configured to filter out all keywords corresponding to the application identifier from a first storage device if they are the same, the first storage device being configured to cache all keywords corresponding to each application identifier received by the server before receiving the latest configuration request, the latest configuration file of the configuration item represented by each keyword, and a key-value pair representing the corresponding relationship between the configuration item and the version of the latest configuration file, wherein the configuration condition of the latest configuration file is the same as at least one configuration file filtering condition received by the server before receiving the latest configuration request; A second screening module, configured to screen out target key-value pairs that do not match the local key-value pairs of the user terminal from the key-value pairs corresponding to all the keywords on the first storage device; The sending module is used to return the target key-value pair and the configuration file of the version represented by the key value in the target key-value pair to the user end.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the processor implements the steps of the method for obtaining a configuration file of an application program according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method for obtaining a configuration file of an application program as described in any one of claims 1 to 7 are implemented.