A data processing method and domain-driven design architecture

By intercepting and parsing data modification requests in the domain-driven design architecture, only part of the data in the aggregation is updated, which solves the problem of resource occupation and performance impact caused by the full update of the aggregation, and achieves efficient data processing.

CN113821519BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011349021.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-26
Publication Date
2024-10-18
Estimated Expiration
2040-11-26

AI Technical Summary

Technical Problem

The existing domain-driven design architecture requires a full update of the entire aggregation when some data in the aggregation is modified, which leads to excessive use of computing resources, increases CPU overhead, and affects system performance.

Method used

Monitor and intercept data modification requests through the domain layer, parse and obtain the identification and data of the aggregation to be modified, update only the modified data, use the cache queue and event manager to write the data, and the application layer will modify it according to the target data to avoid Fully updated.

Benefits of technology

It reduces the occupation of computing resources, reduces CPU overhead, and ensures that the operating performance of the domain-driven design architecture is not affected.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113821519B_ABST
    Figure CN113821519B_ABST
Patent Text Reader

Abstract

The present invention discloses a data processing method and a domain-driven design architecture, and relates to the field of computer technology. A specific implementation of the method includes: the domain layer of the domain-driven design architecture monitors in real time whether a data modification request is received, and when a data modification request is monitored, the data modification request is intercepted; the domain layer parses the data modification request to obtain a first identifier of the aggregation to be modified, a second identifier of the data to be modified in the aggregation to be modified, and target data corresponding to the data to be modified; the application layer of the domain-driven design architecture determines the data to be modified in the aggregation to be modified according to the first identifier and the second identifier, and modifies the data to be modified according to the target data. This implementation can only update the modified data in the aggregation, without the need to fully update the entire aggregation, thereby reducing the occupation of computing resources, reducing CPU overhead, and ensuring that the operating performance of the domain-driven design architecture is not affected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data processing method and a domain driven design architecture. Background Art

[0002] As software systems become increasingly complex, domain-driven design architectures have emerged. In domain-driven design architectures, developers design highly related data into an aggregate, and then write, read, or modify the aggregate as a complete unit.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] Since the aggregation is treated as a complete unit, each time part of the data in the aggregation is modified, the entire aggregation needs to be fully updated. This not only takes up too many computing resources and increases CPU overhead, but also when there is a lot of data in the aggregation, it may affect other businesses and affect the operating performance of the domain-driven design architecture. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a data processing method and a domain-driven design architecture, which can update only the modified data when modifying part of the data in the aggregation, without the need to fully update the entire aggregation, thereby reducing the occupancy of computing resources, reducing CPU overhead, and ensuring that the operating performance of the domain-driven design architecture is not affected.

[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a data processing method is provided.

[0007] A data processing method according to an embodiment of the present invention is applied to a domain driven design architecture, including:

[0008] The domain layer of the domain-driven design architecture monitors in real time whether a data modification request is received. When a data modification request is detected, the data modification request is intercepted.

[0009] The domain layer parses the data modification request to obtain the first identifier of the aggregate to be modified, the second identifier of the data to be modified in the aggregate to be modified, and the target data corresponding to the data to be modified;

[0010] The application layer of the domain-driven design architecture determines the data to be modified in the aggregation to be modified according to the first identifier and the second identifier, and modifies the data to be modified according to the target data.

[0011] Optionally,

[0012] When the domain layer parses and obtains first identifiers corresponding to multiple aggregations to be modified, the method further includes:

[0013] The domain layer writes the first identifiers corresponding to multiple aggregates to be modified, the second identifiers of the data to be modified in each aggregate to be modified, and the target data corresponding to the data to be modified in each aggregate to be modified into the cache queue, so that the application layer obtains the first identifier, the second identifier and the target data corresponding to each aggregate to be modified from the cache queue in turn.

[0014] Optionally,

[0015] The domain layer includes: event generator, event manager and event listener.

[0016] The event generator records the first identifier and the second identifier of the data to be modified in the aggregate to be modified corresponding to the first identifier, and generates a data modification event;

[0017] The event generator sends a data modification event to the event manager, so that the event manager notifies the event listener according to the data modification event, so that the event listener writes the first identifier, the second identifier and the target data into the cache queue accordingly according to the notification of the event manager.

[0018] Optionally,

[0019] The event listener writes the first identifier, the second identifier and the target data into the cache queue accordingly according to the notification of the event manager and the preset read-write cycle.

[0020] Optionally,

[0021] The event listener writes the first identifier, the second identifier, and the target data into the cache queue accordingly according to the notification of the event manager and the preset read-write cycle, including:

[0022] The event listener reads the data modification event from the event manager according to the notification of the event manager to obtain the first identifier and the second identifier;

[0023] The event listener obtains the target data according to the first identifier and the second identifier by using the Java reflection mechanism, and writes the first identifier, the second identifier and the target data into the cache queue accordingly.

[0024] Optionally,

[0025] When the same second identifier corresponds to multiple target data, the method further includes:

[0026] The data to be modified is modified according to the target data closest to the current time among the multiple target data.

[0027] Optionally,

[0028] The domain layer intercepts data modification requests through String Aop.

[0029] To achieve the above objective, according to another aspect of an embodiment of the present invention, a domain driven design architecture is provided.

[0030] A domain-driven design architecture according to an embodiment of the present invention includes a domain layer and an application layer; wherein:

[0031] The domain layer is used to: monitor in real time whether a data modification request is received, and intercept the data modification request when a data modification request is detected; parse the data modification request to obtain the first identifier of the aggregate to be modified, the second identifier of the data to be modified in the aggregate to be modified, and the target data corresponding to the data to be modified;

[0032] The application layer is used to: determine the data to be modified in the aggregation to be modified according to the first identifier and the second identifier, and modify the data to be modified according to the target data.

[0033] To achieve the above objective, according to another aspect of an embodiment of the present invention, a data processing electronic device is provided.

[0034] An electronic device for modifying data according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a data processing method according to an embodiment of the present invention.

[0035] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided.

[0036] A computer-readable storage medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a data processing method according to an embodiment of the present invention is implemented.

[0037] One embodiment of the above invention has the following advantages or beneficial effects: when the domain layer of the domain-driven design architecture detects a data modification request, the data modification request is intercepted and parsed to obtain the first identifier of the aggregate to be modified, the second identifier of the data to be modified in the aggregate to be modified, and the target data corresponding to the data to be modified, and then the application layer of the domain-driven design architecture determines the data to be modified in the aggregate to be modified according to the first identifier and the second identifier, and modifies the data to be modified according to the target data. It is achieved that when modifying part of the data in the aggregate, only the modified data is updated, and there is no need to fully update the entire aggregate, thereby reducing the occupation of computing resources, reducing CPU overhead, and ensuring that the operating performance of the domain-driven design architecture is not affected.

[0038] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0040] Figure 1 is a schematic diagram of main steps of a data processing method according to an embodiment of the present invention;

[0041] Figure 2 is a schematic diagram of a cache queue structure according to an embodiment of the present invention;

[0042] Figure 3 is a schematic diagram of a domain layer according to an embodiment of the present invention;

[0043] Figure 4 It is a schematic diagram of main steps of a method in which an event listener writes a first identifier, a second identifier and target data into a cache queue correspondingly according to an embodiment of the present invention;

[0044] Figure 5 is a schematic diagram of main steps of a method for modifying data to be modified at the application layer according to an embodiment of the present invention;

[0045] Figure 6 is a schematic diagram of main modules of a domain-driven design architecture according to an embodiment of the present invention;

[0046] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0047] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0048] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0049] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.

[0050] The domain-driven design architecture includes the interface layer, application layer, domain layer and infrastructure layer, among which: the interface layer provides an accessible interface for users or callers; the application layer is used to complete specific tasks; the domain layer is the core of the domain-driven design architecture, containing most of the objects and business logic; the infrastructure layer provides general technical services such as data storage for the other three layers, and the database is located in the infrastructure layer.

[0051] At present, the common practice of domain-driven design architecture is to design highly correlated data into an aggregate, where the aggregate is equivalent to a collection of multiple data tables; then the architecture uses the aggregate as the unit of processing to perform operations such as writing, reading or modifying. However, every time part of the data in the aggregate is modified, the data in the entire aggregate needs to be fully updated, which not only takes up too many computing resources and increases CPU overhead, but also may affect other businesses and affect system performance when there is a lot of data in the aggregate. In view of this, this solution provides a data processing method applied to the domain-driven design architecture.

[0052] Figure 1 It is a schematic diagram of main steps of a data processing method according to an embodiment of the present invention.

[0053] like Figure 1 As shown, a data processing method according to an embodiment of the present invention is applied to a domain driven design architecture and mainly includes the following steps:

[0054] Step S101: The domain layer of the domain-driven design architecture monitors in real time whether a data modification request is received, and intercepts the data modification request when a data modification request is detected.

[0055] In an embodiment of the present invention, when the domain layer detects a data modification request, the data modification request can be intercepted on the aggregate root object by means of String Aop, or by means of Filter, or by means of other dynamic proxy technologies and interceptor technologies, and this scheme does not impose any specific restrictions on this. In a preferred embodiment of the present invention, the domain layer intercepts the data modification request by means of String Aop, wherein the String Aop method intercepts the data modification request in an aspect-oriented manner, and thus the entity object information of the specific modification, such as the package name, class name, method name, and parameters in the data modification request can be obtained.

[0056] Step S102: The domain layer parses the data modification request to obtain the first identifier of the aggregate to be modified, the second identifier of the data to be modified in the aggregate to be modified, and the target data corresponding to the data to be modified.

[0057] In an embodiment of the present invention, the data modification request may include a json file. After the domain layer intercepts the data modification request, the json file can be parsed to obtain the first identifier of the aggregation to be modified, the second identifier of the data to be modified in the aggregation to be modified, and the target data corresponding to the data to be modified.

[0058] In an embodiment of the present invention, the modified entity class name, entity parameter object, and unique identifier field name may also be annotated in the data modification request in the form of annotations, wherein the modified entity class name is the first identifier, the unique identifier field name is the second identifier, and the modified entity parameter object is the target data. After the domain layer intercepts the data modification request in the String Aop manner, it can use the Java reflection mechanism to obtain the above data in the aspect logic according to the annotation information to build a cache queue. The cache queue is used to store the modified entity class name, entity parameter object, and unique identifier field name obtained by the domain layer, so that the application layer can obtain these data from the cache queue and modify the corresponding data to be modified. In a preferred embodiment of the present invention, the structure of the cache queue can be as follows Figure 2 shown.

[0059] In the embodiment of the present invention, the first identifier can be the class name of the aggregate to be modified, or the class name of the aggregate to be modified plus a unique field for indicating the aggregate to be modified. The second identifier can be the object name corresponding to the data to be modified, or the object name corresponding to the data to be modified plus a unique field for indicating the data to be modified.

[0060] In an embodiment of the present invention, when the domain layer parses and obtains the first identifiers corresponding to multiple aggregates to be modified, the domain layer can also write the first identifiers corresponding to the multiple aggregates to be modified, the second identifier of the data to be modified in each aggregate to be modified, and the target data corresponding to the data to be modified in each aggregate to be modified into the cache queue, so that the application layer can obtain the first identifier, the second identifier and the target data corresponding to each aggregate to be modified from the cache queue in turn.

[0061] In an embodiment of the present invention, after the domain layer parses the data modification request, it can obtain the second identifier of the data to be modified and the target data corresponding to the data to be modified. The application layer then searches the database of the infrastructure layer for the corresponding data to be modified based on the second identifier, and then modifies the data to be modified into the corresponding target data.

[0062] In an embodiment of the present invention, after the domain layer parses the data modification request, it can obtain the second identifier and its corresponding target data, wherein the second identifier also corresponds to the data to be modified in the database of the infrastructure layer, and then the application layer modifies the corresponding data to be modified in the database of the infrastructure layer into the target data according to the second identifier.

[0063] In the embodiment of the present invention, Figure 3 As shown, the domain layer may include: an event generator, an event manager and an event listener; wherein: the event generator records a first identifier and a second identifier of the data to be modified in the aggregate to be modified corresponding to the first identifier, and generates a data modification event; the event generator sends a data modification event to the event manager, so that the event manager notifies the event listener according to the data modification event; the event listener writes the first identifier, the second identifier and the target data into the cache queue accordingly according to the notification of the event manager.

[0064] In the embodiment of the present invention, the method in which the event listener writes the first identifier, the second identifier, and the target data into the cache queue accordingly can be specifically as follows: Figure 4 As shown, the method mainly includes the following steps:

[0065] Step S401: according to the notification of the event manager, read the data modification event from the event manager to obtain the first identifier and the second identifier;

[0066] Step S402: Acquire target data using the Java reflection mechanism according to the first identifier and the second identifier;

[0067] Step S403: According to a preset read-write cycle, the first identifier, the second identifier and the target data are correspondingly written into the cache queue.

[0068] By presetting a read-write cycle for the event listener, asynchronous operations of intercepting data modification requests and writing to the cache queue can be implemented. That is, each time the domain layer intercepts a data modification request, it does not immediately write the modification information to the cache queue, but instead notifies the event listener by generating a data modification event. The event listener then writes one or more sets of first identifiers, second identifiers, and target data to the cache queue according to the read-write cycle, so as to reduce the number of read and write operations on the cache queue, save computing resources, and facilitate the merging of multiple modification operations on the same data to be modified.

[0069] Step S103: The application layer of the domain-driven design architecture determines the data to be modified in the aggregation to be modified according to the first identifier and the second identifier, and modifies the data to be modified according to the target data.

[0070] In an embodiment of the present invention, the application layer may include an aggregation resource library, which is used to manage aggregations. The aggregation resource library obtains the first identifier of the aggregation to be modified through a reflection mechanism, and then queries the cache queue according to the first identifier to determine whether the entity change list in the cache queue is empty. If not, the entity change list to be modified is modified to persist the target data in the database. The entity change list includes the second identifier, the target data, and the corresponding relationship between the two. Specifically, Figure 5 As shown, Figure 5 1 is a schematic diagram of main steps of a method for modifying data to be modified at an application layer according to an embodiment of the present invention. The method mainly includes the following steps:

[0071] Step S501: query the cache queue to determine whether the entity change list in the cache queue is empty.

[0072] In the embodiment of the present invention, if the entity change list is empty, it means that there is no data change, and the application layer does not need to perform other operations related to modifying the data.

[0073] Step S502: when the entity change list is not empty, the entity change list is obtained, and the target data is grouped according to the second identifier in the entity change list.

[0074] Step S503: when the grouping determines that the same second identifier corresponds to multiple target data, the multiple target data are merged.

[0075] In an embodiment of the present invention, due to the asynchronous operation of the listener, the same second identifier may correspond to multiple target data, that is, there may be multiple data modification requests pointing to the same data to be modified. Therefore, the aggregation resource library can group the target data according to the second identifier in the entity change list, wherein the second identifiers of the target data in the same group are the same. When the same second identifier corresponds to multiple target data, the aggregation resource library can merge the multiple target data. In a preferred embodiment of the present invention, when the aggregation resource library merges multiple target data, the target data closest to the current time among the multiple target data can be selected as the result of the merger, so that when the same data to be modified is indicated to be modified by multiple data modification requests, the aggregation resource library can modify the data to be modified to the target data closest to the current time at one time, reducing the number of read and write times to the database, saving computing resources, and ensuring the operating performance of the domain-driven design architecture.

[0076] Step S504: according to the merged result, access the database of the infrastructure layer to modify the data to be modified.

[0077] In the embodiment of the present invention, the domain-driven design architecture also includes an infrastructure layer, and the database is located in the infrastructure layer. The aggregate resource library can access the database of the infrastructure layer through Dao (Data Access Object, data access object), and modify the data to be modified into the target data, completing the persistence operation on the target data.

[0078] According to a data processing method of an embodiment of the present invention, it can be seen that when the domain layer of the domain-driven design architecture detects a data modification request, the data modification request is intercepted and parsed to obtain the first identifier of the aggregate to be modified, the second identifier of the data to be modified in the aggregate to be modified, and the target data corresponding to the data to be modified. Then, the application layer of the domain-driven design architecture determines the data to be modified in the aggregate to be modified based on the first identifier and the second identifier, and modifies the data to be modified based on the target data. This achieves that when modifying part of the data in the aggregate, only the modified data is updated, and there is no need to fully update the entire aggregate, thereby reducing the occupancy of computing resources, reducing CPU overhead, and ensuring that the operating performance of the domain-driven design architecture is not affected.

[0079] Figure 6 is a schematic diagram of main modules of a domain-driven design architecture according to an embodiment of the present invention.

[0080] like Figure 6 As shown, a domain-driven design architecture 600 of an embodiment of the present invention includes: a domain layer 601 and an application layer 602; wherein:

[0081] The domain layer 601 is used to: monitor in real time whether a data modification request is received, and intercept the data modification request when a data modification request is detected; parse the data modification request to obtain the first identifier of the aggregate to be modified, the second identifier of the data to be modified in the aggregate to be modified, and the target data corresponding to the data to be modified;

[0082] The application layer 602 is used to determine the data to be modified in the aggregate to be modified according to the first identifier and the second identifier, and modify the data to be modified according to the target data.

[0083] In an embodiment of the present invention, when the domain layer 601 parses and obtains first identifiers corresponding to multiple aggregates to be modified, the domain layer 601 is further used to: write the first identifiers corresponding to the multiple aggregates to be modified, the second identifier of the data to be modified in each aggregate to be modified, and the target data corresponding to the data to be modified in each aggregate to be modified into a cache queue, so that the application layer obtains the first identifier, the second identifier and the target data corresponding to each aggregate to be modified from the cache queue in turn.

[0084] In an embodiment of the present invention, the domain layer 601 further includes: an event generator, an event manager and an event listener, wherein: the event generator records a first identifier and a second identifier of the data to be modified in the aggregate to be modified corresponding to the first identifier, and generates a data modification event; the event generator sends a data modification event to the event manager, so that the event manager notifies the event listener according to the data modification event, so that the event listener writes the first identifier, the second identifier and the target data into the cache queue accordingly according to the notification of the event manager.

[0085] In the embodiment of the present invention, the event listener writes the first identifier, the second identifier and the target data into the cache queue accordingly according to the notification of the event manager and the preset read and write cycle.

[0086] In an embodiment of the present invention, the event listener reads the data modification event from the event manager according to the notification of the event manager to obtain the first identifier and the second identifier; the event listener obtains the target data using the Java reflection mechanism according to the first identifier and the second identifier, and writes the first identifier, the second identifier and the target data into the cache queue accordingly.

[0087] In the embodiment of the present invention, when the same second identifier corresponds to multiple target data, the application layer 602 is further configured to modify the data to be modified according to the target data closest to the current time among the multiple target data.

[0088] In the embodiment of the present invention, the domain layer 601 intercepts data modification requests in a String Aop manner.

[0089] It can be seen from a domain-driven design architecture according to an embodiment of the present invention that when the domain layer of the domain-driven design architecture detects a data modification request, it intercepts the data modification request and parses it to obtain the first identifier of the aggregate to be modified, the second identifier of the data to be modified in the aggregate to be modified, and the target data corresponding to the data to be modified. The application layer of the domain-driven design architecture then determines the data to be modified in the aggregate to be modified based on the first identifier and the second identifier, and modifies the data to be modified based on the target data. This achieves that when modifying part of the data in the aggregate, only the modified data is updated, and there is no need to fully update the entire aggregate, thereby reducing the occupancy of computing resources, reducing CPU overhead, and ensuring that the operating performance of the domain-driven design architecture is not affected.

[0090] Figure 7 An exemplary system architecture 700 is shown to which a data processing method or a domain-driven design architecture according to an embodiment of the present invention can be applied.

[0091] like Figure 7As shown, system architecture 700 may include terminal devices 701, 702, 703, network 704 and server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0092] Users can use terminal devices 701, 702, and 703 to interact with server 705 through network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0093] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0094] The server 705 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using the terminal devices 701, 702, and 703. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.

[0095] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0096] Reference below Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0097] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0098] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.

[0099] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.

[0100] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0101] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0102] The architecture involved in the embodiments of the present invention may be implemented in software or hardware. The described architecture may also be set in a processor, for example, it may be described as: a processor includes a domain layer and an application layer. The names of these architectures do not constitute a limitation on the architecture itself in some cases, for example, the domain layer may also be described as "an architecture for monitoring and intercepting data modification requests".

[0103] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: the domain layer of the domain-driven design architecture monitors in real time whether a data modification request is received, and intercepts the data modification request when a data modification request is detected; the domain layer parses the data modification request to obtain a first identifier of the aggregate to be modified, a second identifier of the data to be modified in the aggregate to be modified, and target data corresponding to the data to be modified; the application layer of the domain-driven design architecture determines the data to be modified in the aggregate to be modified based on the first identifier and the second identifier, and modifies the data to be modified based on the target data.

[0104] According to the technical solution of the embodiment of the present invention, when the domain layer of the domain-driven design architecture detects a data modification request, the data modification request is intercepted and parsed to obtain the first identifier of the aggregate to be modified, the second identifier of the data to be modified in the aggregate to be modified, and the target data corresponding to the data to be modified. Then, the application layer of the domain-driven design architecture determines the data to be modified in the aggregate to be modified based on the first identifier and the second identifier, and modifies the data to be modified based on the target data. This achieves that when modifying part of the data in the aggregate, only the modified data is updated, and there is no need to fully update the entire aggregate, thereby reducing the occupancy of computing resources, reducing CPU overhead, and ensuring that the operating performance of the domain-driven design architecture is not affected.

[0105] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A data processing method, characterized in that: Applied to domain-driven design architecture, including: The domain layer of the domain-driven design architecture monitors in real time whether a data modification request is received, and intercepts the data modification request when the data modification request is detected; The domain layer parses the data modification request to obtain a first identifier of the aggregate to be modified, a second identifier of the data to be modified in the aggregate to be modified, and target data corresponding to the data to be modified; wherein the modified entity class name, entity parameter object, and unique identifier field name are annotated in the data modification request in the form of annotations; the first identifier is the modified entity class name, or the modified entity class name plus a unique field for indicating the aggregate to be modified; the second identifier is the unique identifier field name, or the unique identifier field name plus a unique field for indicating the data to be modified; The application layer of the domain-driven design architecture determines the data to be modified in the aggregation to be modified according to the first identifier and the second identifier, and modifies the data to be modified according to the target data.

2. According to the method of claim 1, when the domain layer parses and obtains first identifiers corresponding to a plurality of the aggregations to be modified, the method further comprises: The domain layer writes the first identifiers corresponding to the multiple aggregates to be modified, the second identifiers of the data to be modified in each aggregate to be modified, and the target data corresponding to the data to be modified in each aggregate to be modified into the cache queue, so that the application layer obtains the first identifier, the second identifier and the target data corresponding to each aggregate to be modified from the cache queue in turn.

3. The method according to claim 2, characterized in that The domain layer includes: event generator, event manager and event listener. The event generator records the first identifier and the second identifier of the data to be modified in the aggregate to be modified corresponding to the first identifier, and generates a data modification event; The event generator sends the data modification event to the event manager, so that the event manager notifies the event listener according to the data modification event, so that the event listener writes the first identifier, the second identifier and the target data into the cache queue accordingly according to the notification of the event manager.

4. The method according to claim 3, characterized in that: The event listener writes the first identifier, the second identifier, and the target data into the cache queue accordingly according to the notification of the event manager and a preset read-write cycle.

5. The method according to claim 3, characterized in that: The event listener writes the first identifier, the second identifier, and the target data into the cache queue according to the notification of the event manager and the preset read-write cycle, including: The event listener reads the data modification event from the event manager according to the notification of the event manager to obtain the first identifier and the second identifier; The event listener obtains the target data according to the first identifier and the second identifier by using the Java reflection mechanism, and writes the first identifier, the second identifier and the target data into a cache queue accordingly.

6. The method according to claim 1, characterized in that When the same second identifier corresponds to a plurality of target data, the method further includes: The data to be modified is modified according to the target data closest to the current time among the multiple target data.

7. The method according to any one of claims 1 to 6, characterized in that: The domain layer intercepts the data modification request through String Aop.

8. A domain driven design architecture, characterized in that: It includes the domain layer and the application layer; among them: The domain layer is used to: monitor in real time whether a data modification request is received, and intercept the data modification request when the data modification request is monitored; parse the data modification request to obtain a first identifier of the aggregate to be modified, a second identifier of the data to be modified in the aggregate to be modified, and target data corresponding to the data to be modified; wherein the modified entity class name, entity parameter object, and unique identifier field name are annotated in the data modification request in the form of annotations; the first identifier is the modified entity class name, or the modified entity class name plus a unique field for indicating the aggregate to be modified; the second identifier is a unique identifier field name, or a unique identifier field name plus a unique field for indicating the data to be modified; The application layer is used to: determine the data to be modified in the aggregation to be modified according to the first identifier and the second identifier, and modify the data to be modified according to the target data.

9. A data processing electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method and a device for realizing data writing

    CN109522273A