Version control method and device for multiple configuration modes, equipment and medium
By adopting a multi-configuration version control method in the banking system and using key keys and database mapping technology to dynamically switch version control switches and algorithm logic, the language dependency, cumbersome manual operation and maintenance difficulty of the version control method in the existing technology are solved. problems such as more efficient development and maintenance.
Patent Information
- Application Number
- CN202411403854.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-01-24
AI Technical Summary
The existing version control methods have language dependencies, cumbersome manual operations, difficult maintenance and lack of flexibility, resulting in low development efficiency and difficult maintenance. Especially in banking systems, frequent version switching operations increase development and maintenance costs.
Using a multi -configuration version control method, by obtaining the key button of the version control, using the version key mapping method to query whether there is the key key in the database. If the existence is existing Open the version control switch and query the logic of the new version of the algorithm corresponding to the key key.
Improved the flexibility and maintenance of version control, reducing development and maintenance costs, avoiding the problems caused by the messy code and outdated switch, and improving the customer experience and system stability.
Smart Images

Figure CN119356728A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of data processing technology and financial technology, and in particular to a version control method, device, equipment and medium with multiple configuration modes. Background Art
[0002] With the rapid development of the software industry, version control has become an indispensable part of software development. It helps development teams manage the change history of code, promotes multi-person collaborative development, and makes version release and rollback easier and more reliable. Especially in the field of financial technology, the application of version control is crucial, which involves multiple aspects such as iterative development, risk management, compliance, and continuous innovation of financial software. For example, in financial technology companies, the application of DevOps practices and continuous testing is also inseparable from version control. For example, FinTech Co., Ltd. implemented DevOps workflow and tool chain, established a product version management center, and realized centralized management of requirements, test plans, pipelines, etc., which helps to improve R&D efficiency and product quality. In the digital transformation of the core system of banks, version control is crucial for the upgrade and iteration of basic technologies such as distributed core systems and distributed databases. This helps financial institutions achieve agility and rapid iteration while ensuring system stability and security, which are inseparable from software version control.
[0003] Traditional version control methods, such as using configuration files or hard-coding, do have some limitations: Language dependency: Some version control methods may rely on specific programming languages, which limits their application in multi-language projects. Manual operation: When switching or rolling back versions, traditional methods may require manual modification of configuration files or scripts, which is not only time-consuming but also prone to errors. Difficulty in maintenance: As the project expands, manually managing a large number of version switches and configurations will become very complicated, increasing the difficulty of maintenance. Lack of flexibility: Traditional methods may not be flexible enough to adapt to the development model of rapid iteration and frequent releases.
[0004] In banking systems, safe production is of vital importance. Adjustments to system logic are often accompanied by frequent version switch operations to ensure the safety of the production environment. Although this approach ensures the stability of the system, it also leads to numerous and messy version switches. Safe production has always been the bottom line of banking production. Every time the system logic is adjusted, production safety is ensured by adding version switches, etc., which leads to numerous production switches of varying types, which are extremely high-frequency operations.
[0005] The existing switch method is to add a new switch script or a new apollo switch configuration. In this switch processing method, the number of switch scripts or configurations gradually increases, which consumes resources and the development process is cumbersome. When there are a large number of switches, it undoubtedly increases the development time and labor costs, affecting the development timeliness. At the same time, it also causes many troubles for later maintenance, and the phenomenon of messy and difficult to understand codes occurs frequently.
[0006] At the same time, the large number and variety of switches also caused trouble for customers. Many switches are only needed after a version is launched for a period of time, and the newly added switches will always exist. As the number increases, there will be a large number of outdated switches because they cannot be cleaned up in time. Customers will be at a loss for these messy switches and do not know how to use them. The customer experience is very poor, and there is also a great risk of misoperation. Summary of the invention
[0007] The present invention provides a version control method, device, computer equipment and medium with multiple configuration modes to solve the current existing switch mode, which is processed by adding a switch script or adding apollo switch configuration. Under this switch processing mode, the number of switch scripts or configurations gradually increases, resulting in resource consumption and cumbersome development processing. When the number of switches is large, it undoubtedly increases the development time and labor cost, affects the development timeliness, and also causes many troubles for later maintenance. Technical problems such as frequent phenomena such as messy and difficult to understand codes.
[0008] In a first aspect, a multi-configuration version control method is provided, including:
[0009] Get the version control key;
[0010] Querying whether the key exists in the database by version key mapping;
[0011] If yes, continue to turn off the version control switch and execute the old version algorithm logic;
[0012] If not, the version control switch is turned on, the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is executed.
[0013] In a second aspect, a multi-configuration version control device is provided, including:
[0014] Get module, used to get version control key;
[0015] A query module, used for querying whether the key exists in the database through version key mapping;
[0016] A version control switch closing module is used to continue closing the version control switch and execute the old version algorithm logic if the key exists;
[0017] The version control switch module is turned on to turn on the version control switch if the key does not exist, query the new version algorithm logic corresponding to the key, and call to execute the new version algorithm logic.
[0018] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the multi-configuration version control method when executing the computer program.
[0019] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned multi-configuration version control method are implemented.
[0020] In the scheme implemented by the version control method, device, computer equipment and storage medium with multiple configuration modes, the key of version control can be obtained; whether the key exists in the database is queried through the version key mapping method; if so, the version control switch continues to be closed and the old version algorithm logic is executed; if not, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is executed, which solves the problem that the existing switch mode is processed by adding a switch script or a switch configuration. Under this switch processing method, the number of switch scripts or configurations gradually increases, consuming resources, and the development processing process is cumbersome. When the number of switches is large, it undoubtedly increases the development time and labor cost, affecting the development timeliness, and also causes many troubles for later maintenance, and technical problems such as messy and difficult to understand codes.
[0021] At the same time, if the key value of the key key is empty, the version control switch is turned on, and if the name of the key key is empty, the version control switch is turned on, which further solves the problem of too many types and quantities of switches, which also causes troubles for customers. Many switches are switches that are only needed after a version is online for a period of time. New switches will always exist. After the number increases, there will be a large number of outdated switches due to failure to clean up in time. Customers will be at a loss about these messy switches and do not know how to use them. The customer experience is very poor, and there is also a great risk of misoperation. 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 It is a schematic diagram of an application environment of a version control method with multiple configuration modes in one embodiment of the present invention;
[0024] Figure 2 It is a flowchart of a version control method with multiple configuration modes in one embodiment of the present invention;
[0025] Figure 3 It is a structural diagram of a version control device with multiple configuration modes in one embodiment of the present invention;
[0026] Figure 4 is a schematic diagram of a structure of a computer device in one embodiment of the present invention;
[0027] Figure 5 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] The multi-configuration version control method provided by the embodiment of the present invention can be applied in the following aspects: Figure 1In the application environment, the client communicates with the server through the network. The server can obtain the key of version control through the client; query whether the key exists in the database through the version key mapping method; if so, continue to close the version control switch and execute the old version algorithm logic; if not, turn on the version control switch, query the new version algorithm logic corresponding to the key, and execute the new version algorithm logic, which solves the existing switch mode, which is processed by adding a switch script or adding a switch configuration. Under this switch processing method, the switch script or configuration gradually increases, consumes resources, and the development process is cumbersome. When the number of switches is large, it undoubtedly increases the development time and labor cost, affects the development timeliness, and also causes many troubles for later maintenance, and the code is messy and difficult to understand. Technical problems such as frequent phenomena. Among them, the client can be but not limited to various personal computers, laptops, smart phones, and tablet computers. The server can be implemented with an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments.
[0030] See also Figure 2 As shown, Figure 2 A flowchart of a version control method for multiple configuration modes provided by an embodiment of the present invention includes the following steps:
[0031] S10: Obtain the version control key;
[0032] In this embodiment, version control is a key link in the development and maintenance of software products. With the iterative update of products, smooth transition and flexible switching between new and old versions become particularly important. Existing version control methods often rely on hard coding or a single configuration source, which limits the flexibility and scalability of version control.
[0033] In one embodiment, obtaining a version control key includes:
[0034] Get the name of the key for version control;
[0035] The key value of the key is queried according to the key name.
[0036] Among them, it can be understood that querying the key value of the key according to the key name includes:
[0037] Query the key value of the key according to the key name;
[0038] If the key value of the key is empty, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is called and executed.
[0039] It can be understood that, in another embodiment, the name of the key for version control is obtained, including:
[0040] Get the name of the key of the version control and determine whether it is empty;
[0041] If the name of the key is empty, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is called and executed.
[0042] It should be noted that a specific application, for example, implements a service class VersionKeyService, which contains the method isOpen to decide whether to enable the new logic. The isOpen method first checks whether the passed key is empty. If it is empty, the default version control is enabled and returns true. The corresponding version control value is queried from the configuration layer through versionKeyMapper. If the query result is empty, the default version control is enabled and true is returned.
[0043] The aforementioned VersionKeyService plays a core role in the version control scheme. This class is responsible for deciding whether to enable new logic or fall back to old logic based on configuration information. The following is a detailed description and possible implementation of the VersionKeyService class: Functional description: VersionKeyService provides the decision logic for version control, which determines whether to enable new logic by querying configuration information. This class uses a data access object VersionKeyMapper to obtain configuration values from a database or other storage medium. Main methods: isOpen(String key): This is a public method of the class, which receives a key as a parameter and returns a Boolean value indicating whether the new logic is enabled. keySwitch(StringkeyName,String key): This is a private auxiliary method that implements the logic of version control.
[0044] VersionKeyService uses the SLF4J logging framework to log, which helps debug and monitor the version control decision process.
[0045] This service class can be called by the business logic layer to execute the corresponding logic according to the version control decision. This approach improves the flexibility and maintainability of version control and can be easily integrated into the existing software architecture.
[0046] The aforementioned String is a basic data type used to represent text data. It consists of a series of characters and can contain letters, numbers, symbols, and spaces. In different programming languages, the String type may have different characteristics and methods, but the basic concepts are similar.
[0047] In JavaScript, the String object is used to represent and manipulate strings. Strings can be viewed as sequences of characters and can be manipulated using a variety of methods, such as concatenation, cutting, replacement, searching, and formatting. Strings in JavaScript are immutable, which means that any operation on a string will return a new string object without changing the original string.
[0048] In TypeScript, the String type is an addition to JavaScript that provides static type checking for string operations. TypeScript allows developers to define typed objects with arbitrary keys, where the key can be a string and the value can be any type. This is achieved by using index signatures (such as [key: string]: any), which provides a flexible way to describe objects with dynamic properties.
[0049] In C#, the string keyword is an alias for the System.String class, which provides a series of properties and methods to operate on strings. For example, you can use the Length property to get the length of a string, use the IndexOf method to search for the index of a substring, or use the Substring method to extract a portion of a string.
[0050] S11, query whether the key exists in the database through version key mapping, if yes, execute step S12, if no, execute step S13;
[0051] Specifically, the key values of at least two of the key keys may be divided into a key key array;
[0052] The key value of the key in the database is traversed, and matched with each key in the key array to determine whether the key exists.
[0053] The step of traversing the key value of the key in the database and matching it with each key in the key array to determine whether the key exists includes:
[0054] Traverse the key values of the key key in the database with the key value without blank characters, and delete the blank characters corresponding to the key value;
[0055] Match each key in the key array to determine whether the key exists.
[0056] A specific application may be to split the queried version control value into an array by commas, and then traverse each key in the array.
[0057] For each key, remove leading and trailing whitespace characters and match against the passed in key.
[0058] If a matching key is found, a log is recorded and false is returned, indicating that version control is turned off and it is necessary to fall back to the original logic.
[0059] S12, continue to turn off the version control switch and execute the old version algorithm logic;
[0060] If the aforementioned key exists, the version control switch continues to be closed and the old version algorithm logic is executed.
[0061] S13, turning on the version control switch, querying the new version algorithm logic corresponding to the key, and calling and executing the new version algorithm logic.
[0062] If the aforementioned key exists, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is called to execute.
[0063] Specifically, in this embodiment, a logger is created using LoggerFactory to record version control related information. It also automatically injects a VersionKeyMapper object for interacting with the database, and defines a constant KEY_SWITCH as the key name of the version switch.
[0064] The class contains two main methods:
[0065] 1.isOpen(String key): This method accepts a version control key and calls the keySwitch method to determine whether the version control is enabled. If enabled, it returns true;
[0066] Otherwise returns false.
[0067] 2.keySwitch(String keyName, String key): This is a core method used to determine whether version control is enabled based on the version control name (keyName) and key (key).
[0068] First, record the version control name and key.
[0069] If the passed key is empty, true is returned directly, indicating that version control is enabled by default.
[0070] The version control value is queried from the database through versionKeyMapper.
[0071] If the query result is empty, true is also returned, indicating that version control is enabled by default.
[0072] Split the queried values into an array by commas, and then iterate over each key in the array.
[0073] If the passed key matches a key in the array (ignoring whitespace characters), a log is recorded and false is returned, indicating that version control is turned off and it is necessary to fall back to the original logic.
[0074] If no matching key is found after traversing the array, a log is recorded and true is returned, indicating that version control is enabled and new logic is executed.
[0075] If an exception occurs during execution, the error log is recorded and true is returned, indicating that version control is turned on and the new logic is executed.
[0076] This class is designed to flexibly control the logic of different versions when the system is upgraded or changed to ensure the stability and compatibility of the system. Through the version control key, the opening and closing status of each version can be accurately managed.
[0077] If no matching key is found after traversing the array, a log is recorded and true is returned, indicating that version control is enabled and new logic is executed.
[0078] In one embodiment, multiple programming languages such as Java, Python, C++, and JavaScript may be supported, and developers may select a suitable language to implement version control logic according to project requirements. The configuration layer supports multiple configuration methods such as database configuration, Apollo configuration, and file configuration, providing flexible configuration management options.
[0079] It should be noted that, in this embodiment, the database may be queried to determine whether the key exists by version key mapping, and then the following steps may be further included:
[0080] If the version key query interrupt instruction is obtained, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is called and executed. That is, in the keySwitch method, if an exception occurs when querying or processing configuration values, the service will capture the exception and record an error log. In order to ensure the stability of the system, the service will enable the new logic by default even in abnormal situations.
[0081] During the execution process, if any exception occurs, the error log is recorded and true is returned, indicating that version control is turned on and new logic is executed to ensure the robustness of the system. If an exception occurs during the execution of the version control logic, recording the error log and returning true is a processing strategy. The core idea of this strategy is "fail open", that is, in uncertain situations, the default open or start strategy is adopted. Reasons include: Business continuity: Ensure that the business process can continue even when there is a problem with the version control logic, avoiding service interruptions caused by version control problems. Fault tolerance: When facing unknown errors, choosing to execute new logic can avoid the system from entering an uncertain state, thereby improving the fault tolerance of the system. Flexibility: Allows the system to adapt to new changes when exceptions occur, rather than rigidly sticking to the old logic. Easy to debug: By recording error logs, developers can analyze the cause of the exception afterwards, and the continued operation of the system provides more context information, which is helpful for diagnosing and repairing the problem.
[0082] In practical applications, for example, when developing an e-commerce platform, it is necessary to perform version control on the product recommendation function to A / B test the effect of the new recommendation algorithm.
[0083] The product recommendation function of the e-commerce platform recently developed a new algorithm. It is hoped that the new algorithm will be used for some users without affecting all users, while retaining the old algorithm for comparison. In order to achieve this, the version control function needs to be introduced.
[0084] Database Configuration
[0085] First, we added a record to the VERSION_KEY table of the database to control the switch between the old and new recommendation algorithms:
[0086] keyname key-value recommendAlgorithm WB240101,WB240102
[0087] Here, keyname is recommendAlgorithm, indicating that this is the key used to control the recommendation algorithm version. keyvalue is WB240101,WB240102, indicating that if the user's unique identifier (such as user ID or session ID) matches these values, the user will use the old recommendation algorithm.
[0088] Service Applications
[0089] In the recommendation service, we use VersionKeyService to decide whether to use the new algorithm or the old algorithm:
[0090] java
[0091] / / Assume this method is called in the recommendation service public List<product>getRecommendedProducts(String userId){
[0092] / / Check version control to determine whether to use the new logic
[0093] if(versionKeyService.isOpen(userId)){
[0094] / / Use the new recommendation algorithm
[0095] return newRecommendAlgorithmService.getRecommendations(userId);
[0096] }else{
[0097] / / Use the old recommendation algorithm
[0098] return oldRecommendAlgorithmService.getRecommendations(userId);
[0099] }
[0100] }
[0101] Logical explanation
[0102] 1. When the getRecommendedProducts method is called, the userId of the current user is passed in.
[0103] 2. The isOpen method calls the keySwitch method and passes in userId as the version control key.
[0104] 3. The keySwitch method checks whether there is a matching keyvalue in the database. If so, it returns false, indicating that the old logic is used.
[0105] 4. Based on the return value of keySwitch, the getRecommendedProducts method decides whether to call the new algorithm service or the old algorithm service to obtain the recommended product list.
[0106] Logging
[0107] In the keySwitch method, we use logging to record the version control decision process, which helps to debug and monitor the effect of the version control function.
[0108] In this way, we can flexibly A / B test the new and old algorithms on different user groups without having to switch the algorithm for all users at the same time, which reduces the risks that the new algorithm may bring and allows us to collect data to evaluate the performance of the new algorithm.
[0109] The aforementioned isOpen method is a public method used to check whether the version control switch is turned on. Its implementation relies on a private method called keySwitch, which performs the actual check logic. The following is a brief description and analysis of the isOpen method:
[0110] java
[0111] publicboolean isOpen(String key){
[0112] returnkeySwitch(KEY_SWITCH,key);
[0113] }
[0114] Method Analysis
[0115] Method signature: public boolean isOpen(String key)
[0116] public: Indicates that this method is public and can be called by any other class.
[0117] boolean: Return type, indicating that this method will return a Boolean value, that is, the state of the switch (on or off).
[0118] String key: Parameter representing the key of the specific version control switch to check.
[0119] Method body:
[0120] returnkeySwitch(KEY_SWITCH,key);: Call the private method keySwitch and pass in two parameters: KEY_SWITCH (a constant string, which may represent the switch name of the version control) and key (method parameter, representing the specific version control key).
[0121] Key Points
[0122] Version control switch: This method is used to manage the version control switch to allow or prohibit the execution of certain functions or logic.
[0123] Switch status: A return value of true indicates that the switch is on (the new logic is executed), and a return value of false indicates that the switch is off (it may fall back to the old logic).
[0124] Logging: In the keySwitch method, there is a logging operation that records the switch's inspection results and any abnormal conditions.
[0125] Usage scenarios
[0126] Function switching: During the software version iteration process, you may need to temporarily enable or disable certain functions. The isOpen method provides a flexible control mechanism.
[0127] A / B testing: When performing functional testing or user behavior analysis, you can control the experience of different user groups by changing the switch state.
[0128] Fault recovery: When an anomaly is detected, you can fall back to the stable old logic by turning off the switch to ensure the stability and reliability of the system.
[0129] Precautions
[0130] Exception handling: In the keySwitch method, true is returned by default in the case of an exception, which means that when an unknown error occurs, the system will execute the new logic by default. This may need to be adjusted according to specific business needs and risk assessment.
[0131] Performance considerations: If the keySwitch method involves database operations or complex logic processing, you may need to consider its performance impact, especially in high-traffic environments.
[0132] In general, the isOpen method provides a concise interface to control the version control switch, but the logic and risks behind it need to be carefully evaluated and managed according to specific application scenarios and business needs.
[0133] It is understandable that the keySwitch method mentioned above is a core method in the VersionKeyService class, which is used to determine whether a specific version control logic should be enabled based on the provided key. This method queries the configuration information to determine whether to enable the new version logic or fall back to the old logic. The following is a detailed description of this method:
[0134] Method signature
[0135] java
[0136] publicboolean keySwitch(String keyName,Stringkey)
[0137] keyName: The name of the version control, used to retrieve the corresponding version control value from the configuration store.
[0138] key: The specific version control key to check if it is listed in the configuration.
[0139] It is understandable that if the keySwitch method is frequently called and involves database operations, its impact on performance may need to be considered. Therefore, the following methods can be used to optimize the performance of the keySwitch method and reduce the frequency of database queries: Cache mechanism: By storing frequently accessed data in the cache, the number of direct queries to the database can be significantly reduced, thereby reducing the database load and latency. For example, you can use an in-memory database such as Redis or Memcached to store hot data in memory to avoid getting data from the database every time. Caching strategies include LRU (Least Recently Used), LFU (Least Frequently Used), and TTL (Time to Live) to meet the needs of different scenarios. Query optimization: Optimizing database queries is one of the key measures to improve performance and reduce database pressure. Query performance can be improved through index optimization, query statement optimization, partitioned tables, etc. Rationally design the index structure and avoid using too many indexes to reduce database query time and resource consumption. Batch processing: By merging multiple operations into a batch operation, the number of database accesses can be significantly reduced and system performance can be improved. For example, batch insert, batch update, and batch delete operations can reduce the number of database accesses. Database indexes: Reasonable design and use of indexes can significantly reduce query time and resource consumption. Creating indexes for commonly used query fields can significantly improve query performance. At the same time, pay attention to index maintenance to avoid too many indexes affecting write operation performance. Sharding and database partitioning: Sharding and database partitioning are important technologies for dealing with large-scale data and high concurrent access. By distributing data to multiple database instances, the scalability and performance of the system can be significantly improved. Use asynchronous processing: Asynchronous processing is an effective way to reduce high-frequency database queries. By making time-consuming operations asynchronous, system performance and user experience can be significantly improved. For example, Java's CompletableFuture can be used in combination with a thread pool for asynchronous processing to improve performance. Database connection pool: By reusing database connections, the overhead of establishing and releasing connections for each query can be reduced, thereby improving system performance. Common database connection pool technologies include C3P0, Druid, HikariCP, etc. Code-level optimization: If the string comparison in the keySwitch method is a performance bottleneck, consider caching the hashCode value of the string to avoid recalculating the hashCode every time it is called. This method can improve performance when processing string switches, but you need to pay attention to the problem of hashCode conflicts. Use Spring Boot's asynchronous method: In Spring Boot, you can make some operations asynchronous through the @Async annotation, which can avoid executing time-consuming operations in the main thread, thereby improving the response speed of the interface.Regular cleanup and maintenance: Regularly clean up and maintain the database and cache to ensure data accuracy and query efficiency.
[0140] It should be noted that the aforementioned LRU (Least Recently Used) is a commonly used cache eviction strategy, which is based on an assumption: if the data has been accessed recently, then the probability of being accessed in the future is also higher. The LRU strategy maintains an ordered data structure, usually a combination of a hash table and a doubly linked list, to record the data items in the cache and their access order. How the LRU cache works: Accessing the cache: When accessing a data item in the cache, if the item exists, it is moved to the most recent end of the cache (usually the head of the doubly linked list). Adding data: If the cache is not full, the new data item is added to the most recent end of the cache. If the cache is full, the least recently used data item is removed first (usually the tail of the doubly linked list), and then the new data item is added to the cache. Eliminating data: When the cache reaches its capacity limit, the least recently used data item (LRU item) is eliminated to make room for the new data item.
[0141] Applications of LRU caching: Web browser cache: Browsers can use LRU strategies to decide which pages should remain in the cache for quick re-access. Database cache: Database systems may use LRU strategies to manage the cache of query results to improve the retrieval speed of frequently queried data. Operating system page replacement algorithm: In the operating system, the LRU algorithm is used to decide which memory pages should be replaced. When the memory is full, the least frequently used pages are written to disk to make room for new pages. Content Delivery Network (CDN): CDN uses LRU strategies to decide which content should be cached on edge servers for quick delivery to users.
[0142] Data structure for implementing LRU cache: In Java, you can use the LinkedHashMap class to implement LRU cache, because it maintains the insertion order or access order of elements and allows you to define an eviction strategy. In the Guava library, there is also a ready-made Cache class to implement LRU cache, which provides more configuration options and statistics.
[0143] The aforementioned LFU (Least Frequently Used) cache replacement algorithm is a strategy that determines which data should be eliminated from the cache based on the frequency of data access. Unlike the LRU (Least Recently Used) algorithm, the LFU algorithm focuses on the frequency of data access rather than the time of access. In the LFU algorithm, each cache item is assigned an access counter, and its counter increases every time the cache item is accessed. When the cache reaches its capacity limit and needs to make room for new data, the algorithm will eliminate the cache items with the smallest access counter, that is, the least frequently used data. The core idea of this method is that if a piece of data has been accessed frequently in the past, it is more likely to be accessed in the future. The implementation of the LFU algorithm usually requires maintaining one or more linked lists, each of which represents a frequency level, and a hash table to quickly locate cache items. When the access counter of a cache item increases to a certain threshold, it will be moved to the linked list of the next higher frequency level. In this way, the LFU algorithm can complete data access and elimination operations within a time complexity of 0(1). The advantage of the LFU algorithm is that it can better adapt to changes in data access patterns. For those data items with high access frequency, the LFU algorithm can keep them in the cache, thereby improving the cache hit rate. However, the disadvantage of the LFU algorithm is that it requires additional space to maintain the access counter of each cache item, and may cause performance problems in high concurrency scenarios. In practical applications, the LFU algorithm is often used in scenarios such as Web caching, database caching, and file system caching to improve system performance and stability. For example, in Redis, the LFU algorithm is used as an optional memory elimination strategy, which can be enabled by configuring maxmemory-policy to volatile-lfu or allkeys-lfu.
[0144] The multi-configuration version control method provided in this embodiment can obtain the version control key; query whether the key exists in the database through the version key mapping method; if so, continue to close the version control switch and execute the old version algorithm logic; if not, turn on the version control switch, query the new version algorithm logic corresponding to the key, and execute the new version algorithm logic, which solves the problem that the existing switch method is processed by adding a switch script or a switch configuration. Under this switch processing method, the number of switch scripts or configurations gradually increases, consuming resources, and the development processing process is cumbersome. When the number of switches is large, it undoubtedly increases the development time and labor cost, affecting the development timeliness, and also causes many troubles for later maintenance, and the technical problem of frequent phenomena such as messy and difficult to understand codes.
[0145] At the same time, if the key value of the key key is empty, the version control switch is turned on, and if the name of the key key is empty, the version control switch is turned on, which further solves the problem of too many types and quantities of switches, which also causes troubles for customers. Many switches are switches that are only needed after a period of time after the version is launched. New switches will always exist. After the number increases, there will be a large number of outdated switches due to failure to clean up in time. Customers will be at a loss about these messy switches and do not know how to use them. The customer experience is very poor, and there is also a great risk of misoperation.
[0146] At the same time, by adding general version control logic in the business logic layer, the version control layer decides version switching and use, supporting multiple programming languages such as Java, Python, C++, JavaScript, as well as multiple configuration methods such as database configuration, Apollo configuration, and file configuration.
[0147] It should be understood that the order of execution of the steps in the above embodiment does not necessarily 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 embodiment of the present invention.
[0148] In one embodiment, a multi-configuration version control device is provided, and the multi-configuration version control device corresponds one-to-one to the multi-configuration version control method in the above embodiment. Figure 3 As shown, the multi-configuration version control device includes an acquisition module 101, a query module 102, a version control switch closing module 103, and a version control switch opening module 104. The functional modules are described in detail as follows:
[0149] An acquisition module 101 is used to acquire a version control key;
[0150] In one embodiment, the acquisition module 101 specifically includes:
[0151] A key name unit, used to obtain the name of the key under version control;
[0152] The key value unit of the key is used to query the key value of the key according to the key name.
[0153] The key value unit of the key is specifically used in the following steps:
[0154] Query the key value of the key according to the key name;
[0155] If the key value of the key is empty, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is called and executed.
[0156] The key name unit is used in the following steps:
[0157] Get the name of the key of the version control and determine whether it is empty;
[0158] If the name of the key is empty, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is called and executed.
[0159] In one embodiment, the query module 102 specifically includes:
[0160] A key array unit, used for dividing the key values of at least two keys into a key array;
[0161] The traversal query unit is used to traverse the key value of the key in the database, match it with each key in the key array, and determine whether the key exists.
[0162] The traversal query unit is specifically used for the following steps:
[0163] Traverse the key values of the key in the database and delete the blank characters corresponding to the key values;
[0164] The key value without blank characters is matched with each key in the key array to determine whether the key exists.
[0165] In this embodiment, an exception handling module is also included, which is used to turn on the version control switch, query the new version algorithm logic corresponding to the key key, and execute the new version algorithm logic if a version key query interrupt instruction is obtained.
[0166] The multi-configuration version control device provided in the present embodiment can obtain the version control key; query whether the key exists in the database through the version key mapping method; if so, continue to close the version control switch and execute the old version algorithm logic; if not, turn on the version control switch, query the new version algorithm logic corresponding to the key, and execute the new version algorithm logic, which solves the problem that the existing switch method is to process by adding a switch script or a switch configuration, etc. Under this switch processing method, the number of switch scripts or configurations gradually increases, consuming resources, and the development processing process is cumbersome. When the number of switches is large, it undoubtedly increases the development time and labor cost, affecting the development timeliness, and also causes many troubles for later maintenance, and the technical problem of frequent phenomena such as messy and difficult to understand codes.
[0167] At the same time, if the key value of the key key is empty, the version control switch is turned on, and if the name of the key key is empty, the version control switch is turned on, which further solves the problem of too many types and quantities of switches, which also causes troubles for customers. Many switches are switches that are only needed after a version is online for a period of time. New switches will always exist. After the number increases, there will be a large number of outdated switches due to failure to clean up in time. Customers will be at a loss about these messy switches and do not know how to use them. The customer experience is very poor, and there is also a great risk of misoperation.
[0168] At the same time, by adding general version control logic in the business logic layer, the version control layer decides version switching and use, supporting multiple programming languages such as Java, Python, C++, JavaScript, as well as multiple configuration methods such as database configuration, Apollo configuration, and file configuration.
[0169] For the specific definition of the version control device with multiple configuration modes, please refer to the definition of the version control method with multiple configuration modes in the above text, which will not be repeated here. Each module in the above-mentioned version control device with multiple configuration modes can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0170] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, the functions or steps on the server side of a version control method in a multi-configuration manner are implemented.
[0171] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, the functions or steps on the client side of a version control method in a multi-configuration manner are implemented.
[0172] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0173] Get the version control key;
[0174] Querying the database to see whether the key exists by version key mapping;
[0175] If yes, continue to turn off the version control switch and execute the old version algorithm logic;
[0176] If not, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is called and executed.
[0177] The computer device provided in this embodiment can obtain the key of version control; query whether the key exists in the database through the version key mapping method; if so, continue to close the version control switch and execute the old version algorithm logic; if not, turn on the version control switch, query the new version algorithm logic corresponding to the key, and execute the new version algorithm logic, which solves the problem that the existing switch method is to process by adding a switch script or a switch configuration, etc. Under this switch processing method, the number of switch scripts or configurations gradually increases, consuming resources, and the development processing process is cumbersome. When the number of switches is large, it undoubtedly increases the development time and labor cost, affecting the development timeliness, and also causes many troubles for later maintenance, and the technical problem of frequent phenomena such as messy and difficult to understand codes.
[0178] At the same time, if the key value of the key key is empty, the version control switch is turned on, and if the name of the key key is empty, the version control switch is turned on, which further solves the problem of too many types and quantities of switches, which also causes troubles for customers. Many switches are switches that are only needed after a version is online for a period of time. New switches will always exist. After the number increases, there will be a large number of outdated switches due to failure to clean up in time. Customers will be at a loss about these messy switches and do not know how to use them. The customer experience is very poor, and there is also a great risk of misoperation.
[0179] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0180] Get the version control key;
[0181] Querying the database to see whether the key exists by version key mapping;
[0182] If yes, continue to turn off the version control switch and execute the old version algorithm logic;
[0183] If not, the version control switch is turned on, and the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is called and executed.
[0184] The computer-readable storage medium provided in this embodiment can obtain the key of version control; query whether the key exists in the database through the version key mapping method; if so, continue to close the version control switch and execute the old version algorithm logic; if not, turn on the version control switch, query the new version algorithm logic corresponding to the key, and execute the new version algorithm logic, which solves the problem that the existing switch method is to process by adding a switch script or a switch configuration, etc. Under this switch processing method, the number of switch scripts or configurations gradually increases, consuming resources, and the development processing process is cumbersome. When the number of switches is large, it undoubtedly increases the development time and labor cost, affecting the development timeliness, and also causes many troubles for later maintenance, and the technical problem of frequent phenomena such as messy and difficult to understand codes.
[0185] At the same time, if the key value of the key key is empty, the version control switch is turned on, and if the name of the key key is empty, the version control switch is turned on, which further solves the problem of too many types and quantities of switches, which also causes troubles for customers. Many switches are switches that are only needed after a version is online for a period of time. New switches will always exist. After the number increases, there will be a large number of outdated switches due to failure to clean up in time. Customers will be at a loss about these messy switches and do not know how to use them. The customer experience is very poor, and there is also a great risk of misoperation.
[0186] At the same time, by adding general version control logic in the business logic layer, the version control layer decides version switching and use, supporting multiple programming languages such as Java, Python, C++, JavaScript, as well as multiple configuration methods such as database configuration, Apollo configuration, and file configuration.
[0187] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0188] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed 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 can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an 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).
[0189] 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.
[0190] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those 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 invention, and should all be included in the protection scope of the present invention.
[0191] It should be noted that if software tools or components other than those of our company appear in the embodiments of the present application, they are only used for illustrative purposes and do not represent actual use.< / product>
Claims
1. A version control method with multiple configuration modes, characterized in that: include: Get the version control key; Querying whether the key exists in the database by version key mapping; If yes, continue to turn off the version control switch and execute the old version algorithm logic; If not, the version control switch is turned on, the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is executed.
2. The version control method of multiple configuration modes as claimed in claim 1, characterized in that: Get version control keys, including: Get the name of the key of the version control; The key value of the key is queried according to the key name.
3. The version control method of multiple configuration modes as claimed in claim 2, characterized in that: Query the key value of the key according to the key name, and then further include: If the key value of the key is empty, turn on the version control switch; Query the new version algorithm logic corresponding to the key, and execute the new version algorithm logic.
4. The multi-configuration version control method according to claim 2, characterized in that: Get the name of the key of the version control, and then include: Determine whether the name of the version control key is empty; If the name of the key is empty, the version control switch is turned on, the new version algorithm logic corresponding to the key is queried, and the new version algorithm logic is executed.
5. The multi-configuration version control method according to claim 1, characterized in that: Querying whether the key exists in the database by version key mapping includes: Splitting the key values of at least two of the key keys into a key key array; The key value of the key in the database is traversed, and matched with each key in the key array to determine whether the key exists.
6. The version control method of multiple configuration modes as claimed in claim 5, characterized in that: Traversing the key value of the key in the database, matching it with each key in the key array, and determining whether the key exists, including: Traverse the key values of the key in the database and delete the blank characters corresponding to the key values; The key value without blank characters is matched with each key in the key array to determine whether the key exists.
7. The version control method of multiple configuration modes as claimed in claim 1, characterized in that: Inquiring whether the key exists in the database by version key mapping, and then further comprising: If a version key query interruption instruction is obtained, the version control switch is turned on; Query the new version algorithm logic corresponding to the key, and execute the new version algorithm logic.
8. A version control device with multiple configuration modes, characterized in that: include: Get module, used to get version control key; A query module, used for querying whether the key exists in the database through version key mapping; A version control switch closing module is used to continue closing the version control switch and execute the old version algorithm logic if the key exists; The version control switch module is turned on to turn on the version control switch if the key does not exist, query the new version algorithm logic corresponding to the key, and call to execute the new version algorithm logic.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the multi-configuration version control method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the multi-configuration version control method according to any one of claims 1 to 7 are implemented.