A method and a unified cache device for data caching
By managing data objects and business data in a microservice architecture through a unified caching system, the problems of resource waste and data inconsistency caused by microservices caching themselves are solved, and efficient and secure data acquisition and synchronization are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
- Filing Date
- 2023-03-31
- Publication Date
- 2026-07-31
AI Technical Summary
In a microservice architecture, each microservice builds its own caching system, which leads to resource waste and inconsistent data formats. Furthermore, when retrieving data across systems, it consumes too many thread and network resources, affecting concurrency and latency.
A unified caching system is adopted to manage multiple data objects and business data through mapping relationships, providing security level management and asynchronous event notification for data objects, and realizing data synchronization and local cache optimization.
It improves the efficiency of data retrieval and data consistency between microservices, reduces the waste of cache resources, and enhances data security and query performance.
Smart Images

Figure CN116483746B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing, and more specifically, to a data caching method and a unified caching device. Background Technology
[0002] In a microservices architecture, different business domain systems run different microservices, and these systems have data dependencies on each other. In high-concurrency, low-latency scenarios, cross-system data retrieval will consume a large amount of limited thread and network resources, thus preventing the improvement of concurrency and latency.
[0003] A microservice may depend on data from multiple business domains, and data from one business domain may also be depended on by multiple microservices. Traditional data caching solutions require each microservice to build its own caching system, resulting in redundant construction and wasted resources. Summary of the Invention
[0004] This application provides a data caching method and a unified caching device. By establishing a unified caching system for a microservice architecture, it is possible not only to improve the efficiency of microservices in obtaining business data, but also to improve the efficiency of communication and coordination between microservices.
[0005] Firstly, a data caching method is provided, applied to a microservice architecture including at least one first microservice, at least one second microservice, and a unified caching system. The at least one second microservice uses business data for business processing provided by the at least one first microservice. The method includes: the unified caching system obtaining a first mapping relationship, which is a correspondence between multiple data objects and multiple business data, where each business data is determined based on a corresponding data object. The multiple business data are provided by one or more first microservices, which are some or all of the at least one first microservice; the unified caching system receiving business request information from one or more second microservices, the business request information including a first data object, which is some or all of the multiple data objects, and the one or more second microservices are some or all of the at least one second microservice; the unified caching system determining the first business data corresponding to the first data object based on the first mapping relationship; and the unified caching system sending the first business data to one or more second microservices, whereby the one or more second microservices perform business processing based on the first business data.
[0006] According to the technical solution provided in this application, a unified caching system sends business data to dependent services, eliminating interface interactions between dependent and dependent services, improving the efficiency of data retrieval between microservices, and avoiding the problem of uneven cache utilization among different microservices. Simultaneously, the unified caching system standardizes the data objects of microservices, avoiding inconsistencies in data formats between microservices.
[0007] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the unified caching system obtaining the security level value corresponding to the first data object; and the unified caching system taking security measures on the first business data based on the security level value corresponding to the first data object.
[0008] In conjunction with the first aspect, in some implementations of the first aspect, the security level value of the first data object is greater than or equal to the security level threshold, and the security measures taken for the first business data include at least one of the following: the unified caching system encrypts and stores the first business data; when the unified caching system sends the first business data to one or more second microservices, the unified caching system sets authentication measures for the first business data.
[0009] According to the technical solution provided in this application, data protection capabilities are provided through trusted data access credential management and encrypted storage of business data, ensuring secure and reliable data querying.
[0010] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: when the first business data changes, the unified caching system generates change notification information, which is used to indicate that the first business data has been changed to the second business data.
[0011] According to the technical solution provided in this application, data consistency between microservices is enhanced by managing event changes of data objects.
[0012] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the unified caching system taking data synchronization measures, which are used to modify the first business data stored in the unified caching system into second business data.
[0013] According to the technical solution provided in this application, data consistency between microservices is enhanced by automatically performing cache update processing.
[0014] In conjunction with the first aspect, in some implementations of the first aspect, the execution cycle of the data synchronization measures is determined based on the target time threshold.
[0015] According to the technical solution provided in this application, by regularly performing data synchronization measures, the frequency of synchronization updates and the waste of synchronization update resources caused by a small number of business data changes are avoided.
[0016] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the unified caching system determines that the frequency of one or more second microservices using the first business data when performing business processing is higher than a target number threshold; the unified caching system sends the first business data to the local cache of the one or more second microservices.
[0017] According to the technical solution provided in this application, the local caching capability of microservices for instantiating popular data objects is provided, which improves system processing efficiency and further enhances the query performance of popular cache.
[0018] Secondly, a unified caching device is provided, which is applied to a microservice architecture. The microservice architecture further includes at least one first microservice and at least one second microservice. The business data used for business processing by the at least one second microservice is provided by the at least one first microservice. The unified caching device includes: an acquisition module, used to acquire a first mapping relationship, which is a correspondence between multiple data objects and multiple business data. Each business data is determined according to the corresponding data object. The multiple business data are provided by one or more first microservices, which are some or all of the at least one first microservice; a receiving module, used to receive business request information from one or more second microservices, which includes a first data object, which is some or all of the multiple data objects, and the one or more second microservices are some or all of the at least one second microservice; and a sending module, used to determine the first business data corresponding to the first data object according to the first mapping relationship, and send the first business data to one or more second microservices, which are used for business processing based on the first business data.
[0019] In conjunction with the second aspect, in some implementations of the second aspect, the unified caching device further includes a processing module, wherein the acquisition module is specifically used to acquire the security level value corresponding to the first data object; and the processing module is used to take security measures on the first business data according to the security level value corresponding to the first data object.
[0020] In conjunction with the second aspect, in some implementations of the second aspect, the security level value of the first data object is greater than or equal to the security level threshold, and the processing module is specifically used for at least one of the following: encrypting and storing the first business data; setting authentication measures for the first business data when the sending module sends the first business data to one or more second microservices.
[0021] In conjunction with the second aspect, in some implementations of the second aspect, the unified caching device further includes a generation module, which is used to generate change notification information when the first business data changes, and the change notification information is used to indicate that the first business data has been changed to the second business data.
[0022] In conjunction with the second aspect, in some implementations of the second aspect, the processing module is specifically used to take data synchronization measures, which are used to modify the stored first business data into second business data.
[0023] In conjunction with the second aspect, in some implementations of the second aspect, the execution cycle of data synchronization measures is determined based on the target time threshold.
[0024] In conjunction with the second aspect, in some implementations of the second aspect, the processing module is specifically used to determine that the frequency of using the first business data when one or more second microservices perform business processing is higher than the target number threshold; the sending module is specifically used to send the first business data to the local cache of one or more second microservices.
[0025] Thirdly, a device is provided, comprising a processor and a memory, wherein the memory is used to store instructions and the processor is used to execute the instructions stored in the memory, causing the computing device to perform the method of the first aspect or any possible implementation thereof.
[0026] Optionally, the processor can be a general-purpose processor, which can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc.; when implemented in software, the processor can be a general-purpose processor that reads software code stored in memory, which can be integrated into the processor or exist independently outside the processor.
[0027] Fourthly, a chip is provided that acquires and executes instructions to implement the method in the first aspect or any possible implementation of the first aspect.
[0028] Optionally, as one implementation, the chip includes a processor and a data interface, through which the processor reads instructions stored in the memory and executes the method in the first aspect or any possible implementation of the first aspect.
[0029] Optionally, as one implementation, the chip may further include a memory storing instructions, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to perform the method in the first aspect or any possible implementation of the first aspect.
[0030] Fifthly, a computer program product containing instructions is provided, which, when executed by a computing device or a cluster of computing devices, causes the computing device or the cluster of computing devices to perform the method described in the first aspect or any possible implementation thereof.
[0031] In a sixth aspect, a computer-readable storage medium is provided, including computer program instructions that, when executed by a computing device or a cluster of computing devices, cause the computing device or the cluster of computing devices to perform the method described in the first aspect or any possible implementation thereof.
[0032] As examples, these computer-readable storage media include, but are not limited to, one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), flash memory, electrically EPROM (EEPROM), and hard drive.
[0033] Alternatively, as one implementation method, the aforementioned storage medium can specifically be a non-volatile storage medium. Attached Figure Description
[0034] Figure 1 This is a schematic diagram of a cloud server-based system provided in an embodiment of this application.
[0035] Figure 2 This is a schematic diagram of a traditional architecture and a microservice architecture provided in the embodiments of this application.
[0036] Figure 3 This is a schematic block diagram illustrating a data caching method provided in an embodiment of this application.
[0037] Figure 4 This is a schematic diagram of a unified cache management system provided in an embodiment of this application.
[0038] Figure 5 This is a schematic structural block diagram of a unified caching device provided in an embodiment of this application.
[0039] Figure 6 This is a schematic structural block diagram of a computing device provided in an embodiment of this application.
[0040] Figure 7 This is a schematic structural block diagram of a computing device cluster provided in an embodiment of this application.
[0041] Figure 8 This is a schematic structural block diagram of another computing device cluster provided in an embodiment of this application. Detailed Implementation
[0042] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0043] It should be understood that in the various embodiments of this application, the sequence number of each process does not imply 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 this application.
[0044] Furthermore, in the embodiments of this application, the words "exemplary," "for example," etc., are used to indicate that they are examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the term "exemplary" is intended to present the concept in a concrete manner.
[0045] In the embodiments of this application, "corresponding" and "corresponding" can sometimes be used interchangeably. It should be noted that when the distinction is not emphasized, their intended meanings are consistent.
[0046] The network architecture and business scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0047] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0048] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, and B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0049] Microservices architecture is a technology for deploying applications and services in a cloud environment. It comprises multiple microservices. In microservices, a single application is divided into a set of small services that coordinate and cooperate to provide end-user value. Each service runs in its own independent process, and services communicate with each other using lightweight communication mechanisms. A microservice is an independent entity. Microservices can be deployed independently on a Platform as a Service (PaaS) platform or exist as an operating system process.
[0050] To facilitate understanding of the cloud environment, Figure 1 A system diagram based on a cloud server system is shown. (For example...) Figure 1 As shown, the cloud management platform 110 is used to manage the infrastructure that provides multiple cloud services. The infrastructure includes multiple cloud data centers, each cloud data center includes multiple servers, and each server includes cloud service resources to provide corresponding cloud services to tenants.
[0051] The cloud management platform 110 provides access interfaces (such as user interfaces or application program interfaces, APIs). Tenants can use clients to remotely access these interfaces to register a cloud account and password on the cloud management platform and log in. After successful authentication of the cloud account and password, the tenant can further select and purchase virtual machines with specific specifications (processor, memory, disk) on the cloud management platform. After successful purchase, the cloud management platform provides a remote login account and password for the purchased virtual machine. The client can then remotely log in to the virtual machine and install and run the tenant's applications within it. Tenants of cloud services can be individuals, enterprises, schools, hospitals, government agencies, etc.
[0052] The cloud management platform 110 includes, but is not limited to, a user console, compute management services, network management services, storage management services, authentication services, and image management services. The user console provides an interface or API for interaction with tenants. The compute management services manage servers running virtual machines and containers, as well as bare metal servers. The network management services manage network services (such as gateways and firewalls). The storage management services manage storage services (such as data bucket services). The authentication services manage tenant account passwords. The image management services manage virtual machine images. Tenants can log in to the cloud management platform 110 via client 130 and the internet 120 to manage their rented cloud services.
[0053] For example, in an embodiment of this application, a cloud server in a cloud data center used for unified caching can receive and store business data sent by one or more microservices in a microservice architecture, and send the business data stored in the cloud server according to the business request information of other microservices.
[0054] To facilitate understanding of microservice architecture Figure 2 The diagram illustrates a traditional architecture and a microservices architecture. (For example...) Figure 2 As shown, online supermarkets can offer services such as user services, product services, and order services. Figure 2 As shown in (a), in a traditional service architecture, developers can place all the aforementioned functional services in a unified system, such as a mobile application or a browser website. In this traditional service architecture, the website and mobile application contain a lot of duplicate code with the same business logic, and the interfaces used for data calls are disorganized. Furthermore, when maintaining a traditional architecture, if a small function within a particular service needs modification, that small function must be modified in all systems, resulting in low efficiency.
[0055] However, in Figure 2As shown in (b), in a microservice architecture, developers can create applications corresponding to each of the aforementioned functional services based on their different business domains. These applications can be developed, managed, and iterated independently. Each application backend only needs to obtain the required data from these services, thereby eliminating a large amount of redundant code, leaving only the controller layer and the frontend.
[0056] In a microservices architecture, different business domain systems run different microservices, and these different domain systems have data dependencies on each other. For example, Figure 2 In this context, the user service, product service, and order service correspond to user business, product business, and order business, respectively. The establishment of the order business depends on the user business and product business; therefore, the order service relies on the business data of the user service and product service. For ease of description, the microservice that depends on the data of other business services will be referred to as a "dependent service," and the microservice whose business data is depended upon by other microservices will be referred to as a "depended service." In the embodiments of this application, a microservice can be both a dependent service and a dependent service; that is, it can depend on the business data of other microservices, and its business data can also be depended upon by other microservices.
[0057] In the current microservice architecture, each microservice establishes its own caching system. Caching refers to temporarily storing data in high-speed storage for later retrieval, reducing latency. For example, a dependent service can establish a local cache to store business data generated during business processing. When a dependent service needs to access business data, it retrieves it from the dependent service's local cache. Alternatively, a dependent service can also establish its own local cache. After retrieving business data from the dependent service, the dependent service stores the retrieved data in its local cache and prioritizes retrieving data from the local cache. Only if the cache does not contain the business data will it retrieve it from the dependent service.
[0058] However, with a large number of microservices, a large amount of cached data is created accordingly. Some data is stored in different caches, leading to duplicate caching and wasted cache space. In addition, the cache utilization rate of different microservices is uneven, and resources requested based on peak traffic cannot be shared, resulting in serious waste of cache resources.
[0059] Furthermore, due to the strong coupling between dependent and dependent services—that is, data exchange is achieved through specific data objects and interfaces—inconsistencies in format and complexity in interface changes may arise between the data cached by the dependent service and the data required by the dependent service. For example, the user service can provide business data in the form of "user name, mobile phone number," while the order service requires "mobile phone number, user name" as its business data object for processing. Consequently, the order service needs to process the data before using the business data provided by the user service. As another example, if the interface between the user service and the order service needs to be updated or upgraded, the two microservices must coordinate to achieve synchronous updates and upgrades. Correspondingly, the product service, which depends on the order service, may also need to update and upgrade its interface as the order service's interface is updated. When many services in the system require interface updates and upgrades, the complexity and workload of communication and coordination become significant.
[0060] To address the aforementioned issues, this application proposes a data caching method 300. This method is applied in a microservice architecture, which includes at least one dependent service, at least one dependent service, and a unified caching system. Figure 3 A schematic block diagram of a data caching method 300 is shown, wherein method 300 includes steps 310, 320, and 330. Unlike the current approach where each microservice establishes its own cache, the technical solution of this application establishes a unified caching system for the microservice architecture. When this unified caching system executes method 300, it not only improves the efficiency of microservices in obtaining business data but also enhances the efficiency of communication and coordination between microservices.
[0061] Step 310: The unified caching system obtains the first mapping relationship, which is the correspondence between multiple data objects and multiple business data. Each business data is determined according to the corresponding data object.
[0062] It should be understood that business data is received and stored by the unified caching system through specific data objects, thereby resolving the issue of inconsistent data formats between dependent and dependent services. A data object is a collection of business data of the same nature; that is, a mapping relationship exists between data objects and business data of the same nature. The description of a data object can include the data's definition, model, usage specifications, such as the data's domain, data name, data parameters, data type, management strategy, data change events, synchronization interface, field information, status, and cache data management strategy. The business data corresponding to the above description of the data object is the business data that has a mapping relationship with the data object. When a dependent service needs business data for business processing, the unified caching system can send the business data corresponding to the data object to the dependent service according to this mapping relationship. The following embodiments will illustrate this mapping relationship, and will not be elaborated upon further.
[0063] Optionally, the data object can be determined based on the specific content of the business data required by the dependent service, based on the data object information entered by the data administrator through the management platform, or based on the specific content of the business data generated by the dependent service.
[0064] Step 320: The unified caching system receives business request information from one or more dependent services, including the first data object.
[0065] It should be understood that when a dependent service needs business data for business processing, it will retrieve the business data from the unified caching system. This means the service sends a business request to the unified caching system, which then queries the dependent service for the required business data based on the request. The first data object is the data object corresponding to the first business data required by the dependent service for business processing. This first business data may be some or all of the aforementioned multiple business data.
[0066] Step 330: The unified caching system determines the first business data corresponding to the first data object based on the first mapping relationship, and sends the first business data to one or more dependent services.
[0067] It should be understood that, based on the aforementioned first mapping relationship, the unified caching system queries all business data within the unified caching system for the first business data corresponding to the first data object, and sends the first business data to the dependent services for their business processing. The one or more dependent services then perform business processing based on this first business data.
[0068] Method 300 uses a unified caching system to determine the business data of dependent services based on the first mapping relationship and sends the business data to the dependent services. This eliminates interface interactions between dependent and dependent services, improves the efficiency of data retrieval between microservices, and avoids the problem of uneven cache utilization among different microservices. Simultaneously, the unified caching system standardizes the data objects of microservices, avoiding inconsistencies in data formats between microservices.
[0069] The following describes the specific process of method 300 through a specific embodiment provided in this application. Figure 4 A schematic diagram of a data cache provided in this application is shown. Wherein, Figure 4 The microservice architecture shown includes multiple dependent services, multiple dependent services, and a unified caching system. Meanwhile, Figure 4 Examples of two data objects are shown: customer level and payment method.
[0070] For example, the data object descriptions corresponding to customer level and payment method are as follows: Figure 4 As shown, the data object includes its domain, name, parameter name, data type, value range, and status. Optionally, the data object may also include a caching strategy such as full caching. The unified caching system can receive and store business data that has a mapping relationship with customer level and payment method. For example, the business data that has a mapping relationship with customer level can be the business data indicated by the customer level in the data object description, such as "domain: customer domain, data type: enumeration, value: V5, status: published". In the embodiments of this application, dependent service 1 and dependent service 2 can obtain business data corresponding to customer level and payment method for business processing.
[0071] Optionally, data objects such as customer level and payment method can be determined based on the types of business data from multiple dependent services. For example, dependent service 1 corresponds to a service in the user domain, which generates customer-related business data, including customer level. The unified caching system or the administrator of dependent service 1 can then determine the customer level data object based on the business data type of dependent service 1. As another example, dependent service 2 corresponds to a service in the order domain, which generates order-related business data, including order payment. The unified caching system or the administrator of dependent service 2 can then determine the payment method data object based on the business data type of dependent service 2.
[0072] Optionally, the data object can be a business data type required by the dependent service for business processing. For example, dependent services 1 and 2 require business data related to customer level and payment method for orders. Administrators can determine data objects such as customer level and payment method based on the specific business data types required by the dependent service. However, the content of the specific data object still needs to be determined by the business data of the dependent service.
[0073] In the embodiments of this application, administrators configure data objects such as customer levels and payment methods into a unified caching system. The unified caching system receives and stores business data corresponding to the data objects sent by dependent services. For example, business data in dependent service 1 with a value range of [V0, V10], an enumeration data type, and a published status, such as "Company A: V5" and "Customer B: V10", and business data in dependent service 2 with a value range of [prepaid, monthly settlement], an enumeration data type, and a published status, such as "Company A: Prepaid". Simultaneously, the unified caching system can mark the stored business data using attributes such as domain, name, and parameter name to distinguish the stored full data, such as "Company A, Domain: Customer Domain, Name: Customer Level, customer_level: V5".
[0074] After the unified caching system stores business data, dependent services need to send business request information to the unified caching system, such as requesting to query business data in the unified caching system for business processing. In the embodiments of this application, if dependent service 1 needs to request to query business data corresponding to a customer level from the unified caching system, dependent service 1 can send a customer level data object to the unified caching system. The unified caching system can then query the business data corresponding to the customer level stored in the system based on the mapping relationship between the data object and the business data. Optionally, dependent service 1 can also send the value range corresponding to the customer level at the same time as sending the customer level data object. For example, if the unified caching system stores customer levels with a value range of [V1, V10], dependent service 1 can send the customer level data object at the same time as sending the customer level as V5 or [V5, V8]. Then, the unified caching system will send the business data corresponding to the customer level with a value range of V5 or [V5, V8] to dependent service 1, such as "Company A: V5" mentioned above.
[0075] Optionally, the unified caching system may include a query software package SDK. Dependent services can use the query SDK integrated within the dependent services to send business request information, i.e., the data objects in this embodiment, to the unified caching system. The unified caching system then uses the query SDK to query the business data required by the dependent services and sends the business data to the dependent services using the query SDK integrated within the dependent services.
[0076] Optionally, each data object can correspond to one or more security level values, enabling the unified caching system to take security measures for the business data corresponding to the data object to avoid data leakage. For example, if the security level values are L1 to L4, where L4 is the highest and L1 is the lowest and requires no security measures, and if the security level value for the customer level is L2, the unified caching system can encrypt and store the business data corresponding to the customer level when it receives it from dependent service 1. As another example, if the security level value for the payment method is L3, the unified caching system can set authentication measures for the payment method-related business data when sending it to dependent service 2 to prevent unauthorized access. If the security level of a data object is L4, the unified caching system can both encrypt and authenticate the business data in the table corresponding to that data object. Furthermore, the security level values can also include an anonymization level; the unified caching system can anonymize the business data when storing or sending business data corresponding to a data object with an anonymization level of 1.
[0077] Optionally, when sending business data to dependent services, the unified caching system can determine whether to send the business data directly to the local cache of the dependent service based on the frequency with which the dependent service uses the business data. In other words, the local cache of the dependent service only stores frequently used business data. This further improves the query performance and efficiency of popular business data.
[0078] For example, the frequency of data object usage can be determined based on frequently used data objects set by administrators. After configuring data objects into the unified caching system, administrators can predefine frequently used data objects. These frequently used data objects can be those that administrators determine are frequently used by dependent services. For example, administrators can predefine... Figure 4 The customer tiers and payment methods shown are defined as follows: customer tiers are considered "hot" data objects, and payment methods are considered "non-hot" data objects. Once the unified caching system determines that a customer tier is a "hot" data object, when dependent services 1 and 2 require business data corresponding to that customer tier for business processing, the unified caching system can directly send the corresponding business data to the local caches of dependent services 1 and 2 via the query SDK. Subsequently, when dependent services 1 and 2 require business data corresponding to that customer tier for business processing, they can preferentially retrieve the data from the local cache.
[0079] For example, the frequency of use can be determined by the unified caching system based on the frequency of data objects sent by dependent services. For instance, if dependent service 2 calls the payment method more than a target threshold (e.g., 10 times) or 50% of the total number of business request calls, the unified caching system determines that the business data corresponding to the payment method is frequently used by dependent service 2. Therefore, upon receiving the business request information from dependent service 2, the unified caching system can directly send the business data corresponding to the payment method to dependent service 2's local cache.
[0080] If the unified caching system in a microservice architecture only serves to store data and exchange data with microservices, it cannot automatically modify the changed data when the business data provided by the dependent services changes.
[0081] Optionally, the unified caching system may include asynchronous event management. When the business data provided by the dependent service changes, the unified caching system will promptly push the data object corresponding to the changed business data through asynchronous event management. For example, when configuring a data object, its attributes may also include an event ID, such as `customer_level_update_event` for customer level and `payment_method_update_event` for payment method. When the business data corresponding to the customer level provided by dependent service 1 changes, such as "Company A: V5" changing to "Company A: V10" as mentioned above, dependent service 1 can notify the unified caching system through a Kafka interface or online notification. The unified caching system can then push the customer level event ID "customer_level_update_event" in real time, informing administrators that the business data corresponding to the customer level has changed.
[0082] Optionally, after the unified caching system pushes the event ID of the data object in real time, it can also send a broadcast message. For example, the broadcast message may include a client-level event ID, used to notify all microservices in the microservice architecture that may use the business data corresponding to the client level for business processing, so as to convey that the business data corresponding to the client level has changed.
[0083] Optionally, the unified caching system can also perform synchronized data updates. After the unified caching system pushes the event ID of the data object whose business data has changed, the changed business data can be synchronized and updated. For example, after the business data corresponding to the aforementioned customer level changes, the unified caching system can retrieve the changed business data provided by the dependent service 1 through the synchronization interface and replace the original business data. The dependent service 1 can then re-provide the business data conforming to the customer level data object to the unified caching system through the synchronization interface.
[0084] Optionally, to avoid frequent synchronization updates and wasted resources due to minor changes in business data, the unified caching system can perform synchronized data updates periodically or according to time period thresholds. For example, if the business data provided by the dependent service changes frequently, the unified caching system can perform synchronized data updates at fixed times every day, such as once per hour, to avoid frequent data updates.
[0085] Optionally, different data objects can correspond to different data update cycles. For example, payment methods, due to their relatively low change rate, can correspond to a longer data update cycle, while customer levels can correspond to a shorter data update cycle. In the embodiments of this application, the data update cycle can also be configured when configuring data objects, for example, "Customer level, synchronization strategy: synchronized update once every 24 hours".
[0086] Optionally, when the unified caching system receives newly added or modified data objects, it can group the newly added data objects into similar categories and replace the modified data objects. For example, a newly added data object could be "order information," where the data type of "order information" is an enumeration, with values including payment methods (prepayment, monthly settlement) and order numbers, and the event ID is "order_information_update_event." This means that order information and payment methods share the same value range. When adding the order information data object to the unified caching system, the system can determine that these two data objects are of the same type based on their value ranges and group their event IDs into similar event IDs. That is, when the business data corresponding to the payment method changes, the event ID pushed by the unified caching system includes both the payment method's "payment_method_update_event" and the order information's "order_information_update_event." In other embodiments of this application, the unified caching system can also set the synchronous data update of the two data objects to the same time period threshold. When performing synchronous updates of business data, the unified caching system can simultaneously update the business data corresponding to the payment method and order information to avoid the problem of inconsistent values of the business data of the payment method and order information.
[0087] The embodiments of this application, based on configured data objects, store business data sent by dependent services through a unified caching system and then send the business data to the dependent services. This avoids the dependent services retrieving data from each dependent service individually, thus improving the efficiency of dependent services in data retrieval. Furthermore, by introducing features such as popular data objects, asynchronous event management, synchronous data updates, and data object security levels into the unified caching system, the query efficiency, data accuracy, and security reliability of business data are improved.
[0088] The following text combines Figure 5 This document describes the structural block diagram of the apparatus according to embodiments of this application. It should be noted that... Figure 5 The device shown can perform Figure 3 The method is shown below. It should be understood that the apparatus described below is capable of performing the methods of the foregoing embodiments of this application. To avoid unnecessary repetition, repeated descriptions will be appropriately omitted when introducing the apparatus of the embodiments of this application below.
[0089] Figure 5 This is a schematic diagram of a unified caching device according to an embodiment of this application. Figure 5 The unified caching device 500 shown includes: an acquisition module 510, a receiving module 520, and a sending module 530.
[0090] Specifically, the acquisition module 510 is used to acquire a first mapping relationship, which is a correspondence between multiple data objects and multiple business data. Each business data is determined according to the corresponding data object. The multiple business data are provided by one or more first microservices, and the one or more first microservices are some or all of the at least one first microservice.
[0091] Specifically, the receiving module 520 is used to receive business request information of one or more dependent services, the business request information including a first data object, and the one or more dependent services being some or all of the dependent services in at least one dependent service.
[0092] Specifically, the sending module 530 is used to determine the first business data corresponding to the first data object according to the first mapping relationship, and send the first business data to one or more second microservices, wherein the one or more dependent services are used to perform business processing based on the first business data.
[0093] The specific functions and beneficial effects of the acquisition module 510, the receiving module 520 and the sending module 530 are described in the above embodiments and will not be repeated here for the sake of brevity.
[0094] All of the above modules can be implemented in software or hardware. For example, the implementation of receiving module 520 will be described below. Similarly, the implementation of acquiring module 510 and sending module 530 can refer to the implementation of receiving module 520.
[0095] As an example of a software functional unit, the receiving module 520 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, or a container. Further, the aforementioned computing instance may be one or more. For example, the receiving module 520 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed within the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed within the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.
[0096] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.
[0097] As an example of a hardware functional unit, the receiving module 520 may include at least one computing device, such as a server. Alternatively, the receiving module 520 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.
[0098] The multiple computing devices included in the receiving module 520 can be distributed in the same region or in different regions. Similarly, the multiple computing devices included in the receiving module 520 can be distributed in the same Availability Zone (AZ) or in different AZs. Likewise, the multiple computing devices included in the receiving module 520 can be distributed in the same Virtual Private Cloud (VPC) or in multiple VPCs. Furthermore, the multiple computing devices included in the receiving module 520 can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0099] This application also provides a computing device 600. For example... Figure 6 As shown, the computing device 600 includes a bus 602, a processor 604, a memory 606, and a communication interface 608. The processor 604, the memory 606, and the communication interface 608 communicate with each other via the bus 602. The computing device 600 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 600.
[0100] Bus 602 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 6 The bus 602 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 602 may include a path for transmitting information between various components of the computing device 600 (e.g., memory 606, processor 604, communication interface 608).
[0101] Processor 604 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0102] Memory 606 may include volatile memory, such as random access memory (RAM). Processor 604 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0103] The memory 606 stores executable program code, which the processor 604 executes to implement the functions of the aforementioned acquisition module 510, receiving module 520, and sending module 530, thereby implementing the aforementioned data caching method. That is, the memory 606 stores instructions for executing the aforementioned data caching method.
[0104] The communication interface 608 uses transceiver modules, such as, but not limited to, network interface cards and transceivers, to enable communication between the computing device 600 and other devices or communication networks.
[0105] This application also provides a computing device cluster. The computing device cluster includes at least two computing devices. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0106] like Figure 7 As shown, the computing device cluster includes at least two computing devices 600. The memory 606 of the multiple computing devices 600 in the computing device cluster may store the same instructions for executing the above-described data caching method.
[0107] In some possible implementations, the memories 606 of multiple computing devices 600 in the computing device cluster may each store partial instructions for executing the aforementioned data caching method. In other words, a combination of one or more computing devices 600 can jointly execute the instructions for executing the aforementioned data caching method.
[0108] It should be noted that the memories 606 in different computing devices 600 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the aforementioned device. That is, the instructions stored in the memories 606 of different computing devices 600 can implement the functions of one or more modules among the acquisition module, receiving module, and sending module.
[0109] In some possible implementations, multiple computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 8 One possible implementation is shown. For example... Figure 8 As shown, two computing devices 600A and 600B are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this type of possible implementation, the memory 606 in computing device 600A stores instructions for the functions of the acquisition module. Simultaneously, the memory 606 in computing device 600B stores instructions for the functions of the receiving and transmitting modules.
[0110] It should be understood that Figure 8 The functions of computing device 600A shown can also be performed by multiple computing devices 600. Similarly, the functions of computing device 600B can also be performed by multiple computing devices 600.
[0111] This application also provides a chip, which includes a processor and a data interface. The processor reads instructions stored in the memory through the data interface to execute the above-described data caching method.
[0112] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to perform the aforementioned data caching method.
[0113] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of being stored by a computing device, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to perform the aforementioned data caching method.
[0114] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0115] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.
[0116] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0117] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0118] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0119] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0120] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0121] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method of data caching, characterized by, The method is applied to a microservice architecture, which includes at least one first microservice, at least one second microservice, and a unified caching system. The business data used for business processing by the at least one second microservice is provided by the at least one first microservice. The method includes: The unified caching system obtains a first mapping relationship, which is a correspondence between multiple data objects and multiple business data. Each business data is determined according to the corresponding data object. The multiple business data are provided by one or more first microservices. The one or more first microservices are some or all of the first microservices in the at least one first microservice. The unified caching system receives business request information from one or more second microservices. The business request information includes a first data object, which is part or all of the multiple data objects. The one or more second microservices are part or all of the at least one second microservice. The unified caching system determines the first business data corresponding to the first data object based on the first mapping relationship; The unified caching system sends the first business data to one or more second microservices, and the one or more second microservices are used to perform business processing based on the first business data.
2. The method of claim 1, wherein, The method further includes: The unified caching system obtains the security level value corresponding to the first data object; The unified caching system takes security measures on the first business data based on the security level value corresponding to the first data object.
3. The method of claim 2, wherein, The security level value of the first data object is greater than or equal to the security level threshold, and the security measures taken for the first business data include at least one of the following: The unified caching system encrypts and stores the first business data; When the unified caching system sends the first business data to one or more second microservices, the unified caching system sets authentication measures for the first business data.
4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: If the first business data changes, the unified caching system generates a change notification message, which is used to indicate that the first business data has been changed to the second business data.
5. The method of claim 4, wherein, The method further includes: The unified caching system employs data synchronization measures, which are used to modify the first business data stored in the unified caching system into second business data.
6. The method of claim 5, wherein, The execution cycle of the data synchronization measures is determined based on the target time threshold.
7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: The unified caching system determines that the frequency of the first business data used by one or more second microservices during business processing is higher than a target number threshold. The unified caching system sends the first business data to the local cache of the one or more second microservices.
8. A uniform cache device, characterized by The unified caching device is applied to a microservice architecture, which further includes at least one first microservice and at least one second microservice. The business data used by the at least one second microservice for business processing is provided by the at least one first microservice. The unified caching device includes: The acquisition module is used to: acquire a first mapping relationship, wherein the first mapping relationship is a correspondence between multiple data objects and multiple business data, each business data is determined according to the corresponding data object, the multiple business data is provided by one or more first microservices, and the one or more first microservices are some or all of the first microservices in the at least one first microservice; The receiving module is configured to: receive business request information of one or more second microservices, wherein the business request information includes a first data object, the first data object being some or all of the multiple data objects, and the one or more second microservices being some or all of the at least one second microservice; The sending module is configured to: determine the first business data corresponding to the first data object according to the first mapping relationship, and send the first business data to the one or more second microservices, wherein the one or more second microservices are configured to perform business processing based on the first business data.
9. The uniform caching apparatus of claim 8, wherein, The unified caching device also includes a processing module. The acquisition module is specifically used to acquire the security level value corresponding to the first data object; The processing module is used to take security measures on the first business data according to the security level value corresponding to the first data object.
10. The uniform caching apparatus of claim 9, wherein, The security level value of the first data object is greater than or equal to the security level threshold, and the processing module is specifically used for at least one of the following: The first business data is stored in encrypted form; When the sending module sends the first business data to one or more second microservices, authentication measures are set for the first business data.
11. The uniform caching apparatus of any of claims 8 to 10, wherein, The unified caching device further includes a generation module, which is used to generate change notification information when the first business data changes, and the change notification information is used to indicate that the first business data has been changed to the second business data.
12. The uniform caching apparatus of claim 11, wherein, The processing module is specifically used to take data synchronization measures, which are used to modify the stored first business data into second business data.
13. The uniform caching apparatus of claim 12, wherein, The execution cycle of the data synchronization measures is determined based on the target time threshold.
14. The uniform caching apparatus of any of claims 8 to 13, wherein, The unified caching device also includes a processing module. The processing module is specifically used to determine that the frequency of the first business data used by the one or more second microservices during business processing is higher than a target number threshold. The sending module is specifically used to send the first business data to the local cache of the one or more second microservices.
15. A computing device, comprising: It includes a processor and a memory, the processor being configured to execute instructions stored in the memory, causing the computing device to perform the method as described in any one of claims 1 to 7.
16. A chip, characterized by include: A processor and a data interface; the processor reads instructions stored in memory through the data interface, causing the chip to execute the method as described in any one of claims 1 to 7.
17. A computer program product comprising instructions, characterized in that, When the instruction is executed by the computing device, the computing device performs the method as described in any one of claims 1 to 7.
18. A computer readable medium characterized by It includes computer program instructions that, when executed on a computing device, cause the computing device to perform the method as described in any one of claims 1 to 7.