State data management method, device and system
By coordinating between the scheduler and the state data warehouse, and utilizing the publish-subscribe pattern and custom business logic processing, the problems of database capacity consumption and code redundancy in state data management are solved, achieving more efficient state data management that is suitable for large-scale project development.
Patent Information
- Application Number
- CN202210186488.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-28
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2042-02-28
AI Technical Summary
In existing technologies, unnecessary storage of state data consumes database capacity and leads to code redundancy.
The scheduler receives and forwards status data scheduling commands to the scheduling command processing method interface, updates the status data warehouse, and notifies subscribers in the subscriber list after the data update is complete. This reduces the database storage of temporary and intermediate status data. The publish-subscribe pattern and scheduling command processing method interface allow developers to customize business logic processing.
It reduces redundant database data and backend code, improves R&D efficiency, enhances system flexibility and scalability, and is suitable for large-scale project development.
Smart Images

Figure CN114610730B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Internet, in particular to a state data management method, device, system, computer readable storage medium and electronic equipment. BACKGROUND
[0002] A website is usually composed of two parts: front end and back end. The front end processes the structure (html) of the page, the style (css) and the interaction (js) of the user with the website, and the back end provides the storage, update, query and deletion of the data of the website. When developing a website, the usual process is to access a url address, the back end program reads the data from the database and splices it on the page before returning it to the browser for display.
[0003] In the process of user interaction with the website, many states will be generated, such as user information, in-site messages, etc. These states are usually used by each page and module of the website, so the global state management of js is very important.
[0004] At present, the usual management method is to store the state data generated in the user operation process in the database, and read the state data generated by the user last time from the database every time a browser request is received, splice it on the page and return it to the browser. In these state data, in addition to the data that needs to be stored persistently, such as user information and operation logs, there are also a large amount of intermediate states generated in the user operation process, such as the display and hiding of an element on a certain state control page. These intermediate state data are unnecessary storage data, storing them in the database will occupy the capacity of the database, and every time a new html file is returned, it will also carry the intermediate state data generated by the user last time, which will also cause code redundancy. SUMMARY
[0005] In view of this, the present application provides a state data management method, device and system to solve the problem of unnecessary storage of state data occupying the capacity of the database and causing code redundancy in the prior art.
[0006] In a first aspect, an embodiment of the present application provides a state data management method applied to a dispatcher, including: receiving and forwarding a state data scheduling command to a scheduling command processing method interface, so that the scheduling command processing method interface performs business logic processing according to the state data scheduling command, and returns a processed state data notification to the dispatcher; receiving the processed state data notification, updating the data in a state data warehouse based on the processed state data notification; after the data in the state data warehouse is updated, sending a message to notify the subscribers in the subscriber list that the data in the state data warehouse is updated.
[0007] Further, the method further comprises: in response to the B component initiating a subscription request or a cancelation request, adding or removing the B component from the subscriber list in advance.
[0008] Further, if the B component is included in the subscriber list, the B component acquires updated data in the state data repository after receiving a message that data in the state data repository is updated to perform page display.
[0009] Further, the state data scheduling command is sent by the A component.
[0010] Further, the state data scheduling command comprises a command identifier and command data.
[0011] In a second aspect, an embodiment of the present application further provides a state data management method applied to a scheduling command processing method interface, comprising: receiving a state data scheduling command forwarded by a scheduler; performing business logic processing according to the state data scheduling command; sending a processed state data notification to the scheduler to update data in a state data repository, and sending a message to notify a subscriber in a subscriber list that data in the state data repository is updated after the data is updated.
[0012] Further, the method further comprises: in response to the B component initiating a subscription request or a cancelation request, the scheduler adding or removing the B component from the subscriber list in advance.
[0013] Further, if the B component is included in the subscriber list, the B component acquires updated data in the state data repository after receiving a message that data in the state data repository is updated to perform page display.
[0014] Further, the state data scheduling command is sent by the A component to the scheduler.
[0015] Further, the state data scheduling command comprises a command identifier and command data.
[0016] In a third aspect, an embodiment of the present application further provides a state data management apparatus applied to a scheduler, comprising: a command forwarding unit configured to receive and forward a state data scheduling command to a scheduling command processing method interface, so that the scheduling command processing method interface performs business logic processing according to the state data scheduling command, and returns a processed state data notification to the scheduler; a data updating unit configured to receive the processed state data notification, and update data in a state data repository based on the processed state data notification; and a message sending unit configured to send a message to notify a subscriber in a subscriber list that data in the state data repository is updated after the data in the state data repository is updated.
[0017] Further, the device further comprises a subscription unit, configured to add or remove the B component from the subscriber list in response to the initiation or cancellation of subscription request of the B component in advance.
[0018] Further, if the B component is included in the subscriber list, the B component acquires the updated data in the state data repository to perform page display after receiving the message that the data in the state data repository is updated.
[0019] Further, the state data scheduling command is sent by the A component.
[0020] Further, the state data scheduling command comprises a command identifier and command data.
[0021] In the fourth aspect, an embodiment of the present application further provides a state data management device applied to a scheduling command processing method interface, comprising: a command receiving unit configured to receive a state data scheduling command forwarded by a scheduler; a service processing unit configured to perform service logic processing according to the state data scheduling command; and a notification sending unit configured to send the processed state data to the scheduler to update the data in a state data repository, and send a message to notify a subscriber in a subscriber list that the data in the state data repository is updated after the data is updated.
[0022] Further, the device further comprises a subscription unit, configured to add or remove the B component from the subscriber list in response to the initiation or cancellation of subscription request of the B component in advance.
[0023] Further, if the B component is included in the subscriber list, the B component acquires the updated data in the state data repository to perform page display after receiving the message that the data in the state data repository is updated.
[0024] Further, the state data scheduling command is sent by the A component.
[0025] Further, the state data scheduling command comprises a command identifier and command data.
[0026] In a fifth aspect, the embodiments of the present application further provide a state data management system, comprising: a dispatcher, configured to receive and forward a state data scheduling command to a scheduling command processing method interface, and receive a processed state data notification returned by the scheduling command processing method interface, and update data in a state data repository based on the processed state data notification, and send a message to notify a subscriber in a subscriber list that the data in the state data repository is updated after the data in the state data repository is updated; the scheduling command processing method interface, configured to receive the state data scheduling command, and perform business logic processing according to the state data scheduling command, and return the processed state data notification to the dispatcher; and the state data repository, configured to store state data, and update the state data based on the processed state data notification.
[0027] Further, the system further comprises a B component, configured to initiate a subscription request or a cancel subscription request to the dispatcher in advance, so that the dispatcher adds or removes the B component from the subscriber list.
[0028] Further, if the B component is included in the subscriber list, the B component is further configured to obtain updated data in the state data repository to perform page display after receiving the message that the data in the state data repository is updated.
[0029] Further, the system further comprises an A component, configured to send a state data scheduling command to the dispatcher.
[0030] Further, the state data scheduling command comprises a command identifier and command data.
[0031] In a sixth aspect, the embodiments of the present application further provide a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the method provided by the embodiments of the present application.
[0032] In a seventh aspect, the embodiments of the present application further provide an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; and the processor is configured to read the executable instructions from the memory, and execute the instructions to implement the method provided by the embodiments of the present application.
[0033] The state data management method, device and system provided by the embodiment of the present application can realize that the unnecessary storage state data such as temporary and intermediate state data does not need to be stored in the database, reduce the database redundant data and the backend redundant code, and the backend research and development can focus on the development of business logic without needing to care about the management of intermediate state data, thereby improving the research and development efficiency; the scheduling command processing method interface is adopted, the developer user can write the scheduling command processing logic by himself, and the developer user is given greater freedom and flexibility, the system is highly scalable, and the team cooperation and maintenance are facilitated, and the system is suitable for large project development. BRIEF DESCRIPTION OF DRAWINGS
[0034] Figure 1 The structural schematic diagram of the state data management system provided by an exemplary embodiment of the present application is shown in the figure.
[0035] Figure 2 The flowchart of the state data management method provided by an exemplary embodiment of the present application is shown in the figure.
[0036] Figure 3 The flowchart of the state data management method provided by an exemplary embodiment of the present application is shown in the figure.
[0037] Figure 4 The structural schematic diagram of the state data management device provided by an exemplary embodiment of the present application is shown in the figure.
[0038] Figure 5 The structural schematic diagram of the state data management device provided by an exemplary embodiment of the present application is shown in the figure.
[0039] Figure 6 The block diagram of the electronic device provided by an exemplary embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0040] The exemplary embodiments of the present application are described in detail with reference to the accompanying drawings, however, the present application can be implemented in many different forms, and is not limited to the embodiments described herein, and these embodiments are provided to fully and completely disclose the present application and fully convey the scope of the present application to those skilled in the art. The terms used in the exemplary embodiments shown in the accompanying drawings are not limited to the present application. In the accompanying drawings, the same elements / units use the same reference signs.
[0041] Unless otherwise indicated herein, the terms that are used in this description including technical and scientific terms have the meanings that are commonly understood by one of ordinary skill in the art. Also, it is to be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting. Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the relevant art and the present disclosure and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
[0042] Figure 1 An exemplary embodiment of the state data management system is provided with a schematic diagram of the architecture of the state data management system.
[0043] As Figure 1 shown, the system comprises:
[0044] The scheduler 101 is configured to receive and forward the state data scheduling command to the scheduling command processing method interface, receive the processed state data notification returned by the scheduling command processing method interface, update the data in the state data warehouse based on the processed state data notification, and send a message to notify the subscribers in the subscriber list that the data update in the state data warehouse is complete after the data update in the state data warehouse is complete.
[0045] The scheduler manage has its particularity, and there can be only one scheduler globally. To avoid multiple creation of the scheduler by the user, the singleton pattern can be used to check the scheduler before creation. If there is no creation, the scheduler is mounted to the attribute of the creation method after the creation; if there is a scheduler in the attribute of the creation method, it means that the scheduler has been created before, and the user is given the previously created scheduler, which ensures the global uniqueness of the scheduler.
[0046] Further, the state data scheduling command comprises a command identifier and command data.
[0047] The scheduling command comprises two parts: one part is type, which is used for unique marking of the command, i.e., the command identifier; and the other part is data, which is the data required for executing the command, i.e., the command data.
[0048] The scheduling command processing method interface 102 is configured to receive the state data scheduling command, perform business logic processing according to the state data scheduling command, and return the processed state data notification to the scheduler.
[0049] The dispatch command processing method interface handler is a commonly used application programming interface (API) for message transmission, and is mainly used for message processing. The dispatch command processing method interface handler can be a dispatch command processing method written by a user. When writing the handler to process different business logics, the user can call front-end and back-end programs as needed, obtain resources, execute scripts, and the like, to complete the entire business logic processing process. That is, the handler can serve as a bridge for connecting front-end and back-end data. By abstracting the dispatch command processing method interface handler layer, a developer user can write a dispatch command processing logic, giving the developer user greater freedom and flexibility. The state data can include initial state data, temporary state data, intermediate state data, final state data, and the like.
[0050] The state data repository 103 is configured to store state data, and update the state data based on the processed state data.
[0051] The state data repository state is configured to store all state data and updated state data. By storing all state data in a globally unique state data repository, global sharing of the state data is ensured.
[0052] Specifically, the state management system provided by the embodiments of the present application can be used for managing global state data of user interaction (js) with a website during website development using Django.
[0053] The above embodiments can achieve that the unnecessary storage state data such as temporary and intermediate state data does not need to be stored in a database, thereby reducing database redundant data and backend redundant code, and the backend development can focus on the development of business logic without needing to care about the management of intermediate state data, which helps to improve the development efficiency. The dispatch command processing method interface is adopted, and a developer user can write a dispatch command processing logic, thereby giving the developer user greater freedom and flexibility, and the system is highly scalable, which is convenient for team collaboration and maintenance, and is suitable for large project development.
[0054] Further, the system further includes a B component 104 configured to: initiate a subscription request or a cancel subscription request to the dispatcher in advance, so that the dispatcher adds or removes the B component from a subscriber list.
[0055] The B component can be preconfigured to call a watch method or an unwatch method to listen to or cancel listening to state data changes, so as to enter or remove the B component from the subscriber list. Since the subscriber list is managed by the dispatcher, a related request needs to be initiated to the dispatcher.
[0056] Further, if the B component 104 is included in the subscriber list, the B component 104 is further configured to: after receiving a message that data updating in the state data warehouse is completed, obtain the updated data in the state data warehouse for page display.
[0057] The B component listens to the state data change by calling the watch method, that is, the B component enters the subscriber list listeners. When the state data is updated, the dispatcher manage notifies all the subscribers, and the B component receives the message sent by the dispatcher and calls the getState method to obtain the changed state data from the state data warehouse for page display.
[0058] In the above embodiment, the B component can obtain the state data updating in real time by entering the subscriber list, and thus the real-time updating of the page display data is realized, the B component is more responsible for interface display, the operation process is more fine and standardized, and the database redundant data is reduced, the backend redundant code is also reduced, and the research and development efficiency is improved.
[0059] Further, the system further includes an A component configured to send a state data scheduling command to the dispatcher.
[0060] The A component sends the state data scheduling command to the dispatcher manage by the send method to schedule the state data uniformly.
[0061] Hereinafter, the embodiments of the present application are further described by specific examples:
[0062] For example, a page is composed of a plurality of components, assuming that a page of a counter is composed of an A component and a B component, the A component includes a button, and the B component includes a counting result. It is required to realize that when the button in the A component is pressed, the B component counts up by 1, when the count reaches 10, a record of the user counting up to 10 is stored in the database, and the counting result is cleared.
[0063] The prior art method is that when a button is pressed, a request is initiated, the request reaches the backend, the backend program adds 1 to the current value, stores the intermediate result data in the database, splices the calculation result, returns a new page to the browser for display, and when the count reaches 10, the previous record of the intermediate result is deleted, a record of 10 is recorded, and a new page with a value result of 0 is returned.
[0064] In the above process, the intermediate calculation results from 1 to 9 need to be stored in the database, which produces redundant data, and the backend program also produces redundant code.
[0065] The method of the embodiment of the present application is that pressing a button in the A component sends an instruction, a user customizes and writes a processing process handler of the instruction, it is found that 10 has been added in the processing process, a back-end program is called to store data in a database, the B component only needs to watch the change of data and display on a page, the business logic is put into the processing process handler written by the user, which makes the operation flow granularity finer and more standardized, the component B is responsible for interface display, which is more pure, meanwhile, the intermediate state data back-end program does not need to be perceived, it is shielded to the back-end program before the value is added to 10, and it is stored in the warehouse after being added to 10, which reduces the database redundant data and the back-end redundant code; and the user state data is stored in a global unique state warehouse, which guarantees the global sharing of the state; the global state data is processed by providing send, watch, getState and other methods through the publish / subscribe mode construction, the writing is standardized, easy to understand and convenient for team maintenance; the handler layer is abstracted, the user can write the dispatch command processing logic by himself, and a greater degree of freedom and flexibility is given to the developer.
[0066] Figure 2 The flow chart of the state data management method provided for an exemplary embodiment of the present application is shown.
[0067] The method is applied to a dispatcher, as shown in the figure, the method comprises the following steps. Figure 2
[0068] Step S201: receiving and forwarding the state data scheduling command to the scheduling command processing method interface, so that the scheduling command processing method interface processes the business logic according to the state data scheduling command, and returns the processed state data to the dispatcher.
[0069] The dispatcher manage has its particularity, and there can be only one dispatcher globally. In order to avoid the user creating the dispatcher multiple times, the singleton mode can be used to check the dispatcher before creation. If it has not been created, the dispatcher is mounted to the attribute of the creation method after being created; if there is a dispatcher in the attribute of the creation method, it means that the dispatcher has been created before, and the user is given is the dispatcher created before, which guarantees the global uniqueness of the dispatcher.
[0070] The dispatch command processing method interface handler is a commonly used application programming interface (API) for message transmission, and is mainly used for message processing. The dispatch command processing method interface handler can be a dispatch command processing method written by a user. When the user writes the handler to process different business logics, the user can call front-end and back-end programs as needed, obtain resources, execute scripts, and the like, to complete the entire business logic processing process. That is, the handler can serve as a bridge for connecting front-end and back-end data. By abstracting the dispatch command processing method interface handler layer, a developer user can write a dispatch command processing logic, thereby giving the developer user greater freedom and flexibility. The state data can include initial state data, temporary state data, intermediate state data, and final state data, and the like.
[0071] Further, the state data dispatch command includes a command identifier and command data.
[0072] The dispatch command includes two parts: one part is type, which is used for unique marking of the command, that is, the command identifier; and the other part is data, which is data required for executing the command, that is, the command data.
[0073] Step S202: receiving a processed state data notification, and updating data in the state data repository based on the processed state data notification.
[0074] The state data repository state is used for storing all state data and updating the state data. By storing all state data in the globally unique state data repository, global sharing of the state data is ensured.
[0075] Step S203: after the data in the state data repository is updated, a message is sent to notify the subscribers in the subscriber list that the data in the state data repository is updated.
[0076] The subscribers in the subscriber list listeners can initiate a request to the dispatcher in advance and obtain the setting through the dispatcher according to a requirement. After the state data is updated each time, the dispatcher sends a message to the subscribers in the subscriber list to notify all the subscribers that the state data is updated.
[0077] Specifically, the state data management method provided in the embodiments of the present application can be used for managing global state data of user and website interaction (js) when Django is used to develop a website.
[0078] The above embodiment can realize that the unnecessary storage of temporary and intermediate state data does not need to be stored in the database, reduce the database redundant data, and also reduce the backend redundant code, so that the backend research and development can focus on the development of business logic without needing to care about the management of intermediate state data, which helps to improve the research and development efficiency; the scheduling command processing method interface is adopted, the developer user can write the scheduling command processing logic by himself, which gives the developer user greater freedom and flexibility, the system is highly extensible, is convenient for team cooperation and maintenance, and is suitable for large project development.
[0079] Further, the method further comprises:
[0080] The B component is added or removed from the subscriber list in advance in response to the initiation of the subscription request or the unsubscription request of the B component.
[0081] The watch method or the unwatch method of the B component can be preset to listen to or cancel to listen to the state data change, so that the B component enters or exits the subscriber list. Since the subscriber list is managed by the dispatcher, the dispatcher needs to initiate a related request.
[0082] Further, if the B component is included in the subscriber list, the B component obtains the updated data in the state data warehouse after receiving the message that the data in the state data warehouse is updated.
[0083] The B component listens to the state data change by calling the watch method, that is, the B component enters the subscriber list listeners. When the state data is updated, the dispatcher manage notifies all the subscribers, and the B component receives the message sent by the dispatcher and calls the getState method to obtain the changed state data from the state data warehouse for page display.
[0084] In the above embodiment, the B component can obtain the state data update in real time by entering the subscriber list, and then realize real-time update of page display data, so that the B component is responsible for interface display is more pure, the operation process granularity is finer and more standardized, and the database redundant data is reduced while the backend redundant code is reduced, which helps to improve the research and development efficiency.
[0085] Further, the state data scheduling command is issued by the A component.
[0086] The A component sends a state data scheduling command to the scheduler manage through a send method to uniformly schedule the state data.
[0087] The embodiments of the present application are further described below by way of specific examples:
[0088] For example, a page is composed of multiple components. Suppose that the page is composed of an A component and a B component, the A component contains a button, and the B component contains a counting result. The A component needs to press the button to add 1 to the counting result of the B component. When the counting result reaches 10, a record of the user reaching 10 is stored in the database, and the counting result is cleared.
[0089] The prior art method is as follows. When a button is pressed, a request is initiated, and the request reaches the backend. The backend program adds 1 to the current value, stores the intermediate result data in the database, splices the counting result, returns a new page to the browser, and displays the counting result. When the counting result reaches 10, the previous intermediate result is deleted, a record of 10 is recorded, and a new page with a counting result of 0 is returned.
[0090] In the above process, the intermediate counting results from 1 to 9 need to be stored in the database, which produces redundant data and redundant code in the backend program.
[0091] The method of the embodiments of the present application is as follows. When a button in the A component is pressed, an instruction is sent, and the user customizes the processing process handler of the instruction. In the processing process, it is found that the counting result has reached 10, the backend program is called to store the data in the database, the B component only needs to watch the change of the data and display it on the page, the business logic is placed in the processing process handler written by the user, which makes the operation process more fine and more standardized, the component B is responsible for the interface display, and the intermediate state data does not need to be perceived by the backend program. Before the counting result reaches 10, the backend program is shielded, and after the counting result reaches 10, the data is stored in the database, which reduces the redundant data in the database and the redundant code in the backend. The user state data is stored in the globally unique state warehouse state, which ensures the global sharing of the state. The publish / subscribe mode is constructed, and the send, watch, and getState methods are provided to process the global state data, which is easy to write, easy to understand, and easy to maintain by the team. The handler layer is abstracted, the user can write the scheduling command processing logic by himself, and the developer has greater freedom and flexibility.
[0092] Figure 3 A flowchart of a state data management method provided for an exemplary embodiment of the present application is shown.
[0093] The method is applied to a scheduling command processing method interface, as shown in Figure 3 The method comprises the following steps.
[0094] Step S301: receiving the state data scheduling command forwarded by the scheduler.
[0095] The scheduler manage has its particularity, and there can be only one scheduler globally. To avoid the user creating the scheduler multiple times, the singleton pattern can be used to check the scheduler before creation. If it has not been created, the scheduler is mounted to the creation method attribute after creation; if there is a scheduler in the creation method attribute, it means that it has been created before, and the user is given the previously created scheduler, ensuring that the scheduler is globally unique.
[0096] Further, the state data scheduling command includes a command identifier and command data.
[0097] The scheduling command includes two parts: one part is type, which is used for unique marking of the command, i.e., the command identifier; and the other part is data, which is the data required for executing the command, i.e., the command data.
[0098] Step S302: performing business logic processing according to the state data scheduling command.
[0099] The handler, which is a commonly used application programming interface (API) for message transmission, is mainly used for message processing. The handler can be a scheduling command processing method written by the user. When the user writes the handler to process different business logic, the user can call the front-end and back-end programs as needed, obtain resources, execute scripts, etc., to complete the entire business logic processing process, i.e., the handler can serve as a bridge for connecting front-end and back-end data. By abstracting the handler layer, the developer user can write the scheduling command processing logic, giving the developer user greater freedom and flexibility. The state data can include initial state data, temporary state data, intermediate state data, and final state data.
[0100] Step S303: notifying the processed state data to the scheduler to update the data in the state data warehouse, and sending a message to notify the subscriber in the subscriber list that the data in the state data warehouse has been updated after the data is updated.
[0101] The state data warehouse state is used to store all state data and update the state data. By storing all state data in the globally unique state data warehouse, the global sharing of state data is ensured.
[0102] The subscribers in the subscriber list listeners can initiate a request to the dispatcher in advance according to needs and get the setting through the dispatcher. After each state data update is completed, the dispatcher sends a message to the subscribers in the subscriber list to inform all the subscribers that the state data update is completed.
[0103] Specifically, the method for state data management provided by the embodiment of the application can be used for managing global state data of user interaction (js) of a website developed by Django.
[0104] The above embodiment can achieve that the temporary and intermediate state data and other unnecessary state data do not need to be stored in the database, reduce the database redundant data, and also reduce the backend redundant code, so that the backend research and development can focus on the development of business logic and do not need to care about the management of intermediate state data, thereby helping to improve the research and development efficiency; the scheduling command processing method interface is adopted, the developer user can write the scheduling command processing logic by himself, thereby giving the developer user greater freedom and flexibility, the system is highly scalable, and the team cooperation and maintenance are facilitated, and the system is suitable for large project development.
[0105] Further, the method further includes:
[0106] The dispatcher adds or removes the B component from the subscriber list in response to the initiated subscription request or the unsubscription request of the B component in advance.
[0107] The watch method or the unwatch method of the B component can be set in advance to listen to or cancel listening to the state data change, so that the B component enters or exits the subscriber list. Since the subscriber list is managed by the dispatcher, the dispatcher needs to initiate a related request.
[0108] Further, if the B component is included in the subscriber list, the B component obtains the updated data in the state data warehouse to perform page display after receiving the message that the data update in the state data warehouse is completed.
[0109] The B component listens to the state data change by calling the watch method, that is, the B component enters the subscriber list listeners. When the state data update is completed, the dispatcher manage notifies all the subscribers, and the B component receives the message sent by the dispatcher and calls the getState method to obtain the changed state data from the state data warehouse to perform page display.
[0110] In the above embodiment, the B component can obtain the status data update in real time by entering the subscriber list, and then realize real-time update of the page display data, so that the B component is responsible for the interface display more pure, the operation process is more fine and more standardized, and the database redundant data is reduced while the backend redundant code is reduced, which helps to improve the research and development efficiency.
[0111] Further, the status data scheduling command is sent by the A component to the scheduler.
[0112] The A component sends the status data scheduling command to the scheduler manage by the send method to schedule the status data uniformly.
[0113] Hereinafter, the embodiments of the present application are further described by specific examples:
[0114] For example, a page is composed of multiple components, assuming that there is a counter page composed of A component and B component at this time, the A component contains a button, and the B component contains the counting result. It is required to press the button in the A component, the B component counts plus 1, when it reaches 10, a record of the user reaching 10 is stored in the database, and the counting result is cleared.
[0115] The prior art method is to press a button to initiate a request, the request reaches the backend, the backend program adds 1 to the current value, stores the intermediate result data in the database, splices the calculation result to return a new page to the browser, and deletes the previous record of the intermediate result when it reaches 10, records a record of 10, and returns a new page with the value result of 0.
[0116] In the above process, the intermediate calculation results from 1 to 9 need to be stored in the database, which produces redundant data, and the backend program also produces redundant code.
[0117] The method of the embodiment of the present application is that pressing a button in the A component sends an instruction, the user customizes to write a processing process handler of the instruction, it is found that 10 has been added in the processing process, a back-end program is called to store data in a database, the B component only needs to watch the change of data and display on a page, the business logic is put into the processing process handler written by the user, which makes the operation flow granularity finer and more standardized, the component B is responsible for interface display, which is more pure, meanwhile, the intermediate state data back-end program does not need to be perceived, it is shielded to the back-end program before the value is added to 10, and it is stored into the warehouse after being added to 10, which reduces the database redundant data and the back-end redundant code; and the user state data is stored in a global unique state warehouse, which guarantees the global sharing of the state; the global state data is processed by providing send, watch, getState and other methods through the publish / subscribe mode construction, the writing is standardized, easy to understand and convenient for team maintenance; the handler layer is abstracted, the user can write the dispatch command processing logic by himself, which gives the developer greater freedom and flexibility.
[0118] Figure 4 The structural schematic diagram of the state data management device provided for an exemplary embodiment of the present application is shown.
[0119] The device is applied to a dispatcher, as shown in the figure, the device comprises: Figure 4
[0120] The command forwarding unit 401 is used for receiving and forwarding the state data scheduling command to the scheduling command processing method interface, so that the scheduling command processing method interface processes the business logic according to the state data scheduling command, and returns the processed state data to the dispatcher.
[0121] The dispatcher manage has its particularity, and there is only one dispatcher in the whole world. In order to avoid the user creating the dispatcher for many times, the singleton mode can be used to check the dispatcher before creation. If it is not created, the dispatcher is mounted to the creation method attribute after the creation is completed; if there is a dispatcher in the creation method attribute, it means that the dispatcher has been created before, and the dispatcher is not created any more, the user is given the dispatcher created before, which guarantees the global uniqueness of the dispatcher.
[0122] The scheduling command processing method interface handler is a commonly used application programming interface (API) for message transmission, and is mainly used for message processing. The scheduling command processing method interface handler can be a scheduling command processing method written by a user. When the user writes the handler to process different business logics, the user can call front-end and back-end programs as needed, obtain resources, execute scripts, and the like, to complete the entire business logic processing process. That is, the handler can serve as a bridge for connecting front-end and back-end data. By abstracting the scheduling command processing method interface handler layer, a developer user can write scheduling command processing logic by himself / herself, to give the developer user greater freedom and flexibility. The state data can include initial state data, temporary state data, intermediate state data, and final state data, and the like.
[0123] Further, the state data scheduling command includes a command identifier and command data.
[0124] The scheduling command includes two parts: one part is type, which is used for unique marking of the command, that is, the command identifier; and the other part is data, which is data required for executing the command, that is, the command data.
[0125] The data updating unit 402 is configured to receive the processed state data notification, and update the data in the state data repository based on the processed state data notification.
[0126] The state data repository state is used for storing all state data and updating state data. By storing all state data in the globally unique state data repository, global sharing of the state data is ensured.
[0127] The message sending unit 403 is configured to send a message to notify the subscribers in the subscriber list that the data in the state data repository is updated after the data in the state data repository is updated.
[0128] The subscribers in the subscriber list listeners can initiate a request to the dispatcher in advance and obtain the setting through the dispatcher according to a requirement. After the state data is updated each time, the dispatcher sends a message to the subscribers in the subscriber list to notify all the subscribers that the state data is updated.
[0129] Specifically, the state data management method provided in the embodiments of the present application can be used for managing the global state data of user and website interaction (js) when Django is used to develop a website.
[0130] The above embodiment can realize that the unnecessary storage of temporary and intermediate state data does not need to be stored in the database, reduce the database redundant data, and also reduce the backend redundant code, so that the backend research and development can focus on the development of business logic without needing to care about the management of intermediate state data, which helps to improve the research and development efficiency; the scheduling command processing method interface is adopted, the developer user can write the scheduling command processing logic by himself, which gives the developer user greater freedom and flexibility, the system is highly scalable, is convenient for team cooperation and maintenance, and is suitable for large project development.
[0131] Further, the apparatus further comprises:
[0132] The subscription unit is configured to add or remove the B component from the subscriber list in response to the initiation of the subscription request or the unsubscription request of the B component in advance.
[0133] The watch method or the unwatch method can be preset to be called by the B component to listen to or cancel to listen to the state data change, so that the B component enters or exits the subscriber list. Since the subscriber list is managed by the dispatcher, the dispatcher needs to initiate a related request.
[0134] Further, if the B component is included in the subscriber list, the B component receives the message that the data in the state data repository is updated, and obtains the updated data in the state data repository for page display.
[0135] The B component enters the subscriber list listeners by calling the watch method to listen to the state data change. When the state data is updated, the dispatcher manage notifies all the subscribers, and the B component receives the message sent by the dispatcher to call the getState method to obtain the changed state data from the state data repository for page display.
[0136] In the above embodiment, the B component can obtain the state data update in real time by entering the subscriber list, and then realize real-time update of page display data, so that the B component is responsible for interface display is more pure, the operation process granularity is finer and more standardized, and the database redundant data is reduced while the backend redundant code is reduced, which helps to improve the research and development efficiency.
[0137] Further, the state data scheduling command is initiated by the A component.
[0138] The A component sends a state data scheduling command to the scheduler manage through a send method to uniformly schedule the state data.
[0139] The embodiments of the present application are further described below by way of specific examples:
[0140] For example, a page is composed of multiple components. Assuming that the page is composed of an A component and a B component, the A component contains a button, and the B component contains a counting result. The A component needs to press the button to add 1 to the counting result of the B component. When the counting result reaches 10, a record of the user reaching 10 is stored in the database, and the counting result is cleared.
[0141] The prior art method is as follows. When a button is pressed, a request is initiated. After the request reaches the backend, the backend program adds 1 to the current value, stores the intermediate result data in the database, splices the counting result, returns a new page to the browser, and displays the counting result. When the counting result reaches 10, the previous intermediate result is deleted, a record of 10 is recorded, and a new page with a counting result of 0 is returned.
[0142] In the above process, the intermediate counting results from 1 to 9 need to be stored in the database, which produces redundant data and redundant code in the backend program.
[0143] The method of the embodiments of the present application is as follows. When a button in the A component is pressed, a command is sent. The user customizes the processing process handler of the command. In the processing process, it is found that the counting result has reached 10. The backend program is called to store the data in the database. The B component only needs to watch the change of the data and display it on the page. The business logic is placed in the processing process handler written by the user. This makes the operation process more granular and more standardized. The B component is responsible for the interface display, which is more pure. The backend program does not need to perceive the intermediate state data. The backend program is shielded before the counting result reaches 10. The data is stored in the database after reaching 10. This reduces the redundant data in the database and the redundant code in the backend. The user state data is stored in the globally unique state warehouse state, which ensures the global sharing of the state. The publish / subscribe mode is constructed to provide send, watch, and getState methods to process the global state data. The writing method is standardized, easy to understand, and convenient for team maintenance. The handler layer is abstracted. The user can write the scheduling command processing logic to give the developer greater freedom and flexibility.
[0144] Figure 5 The structure diagram of the state data management device provided for an exemplary embodiment of the present application is shown.
[0145] The device is applied to a scheduling command processing method interface, as shown in Figure 5 The device comprises:
[0146] The command receiving unit 501 is configured to receive the state data scheduling command forwarded by the scheduler.
[0147] The scheduler manage has its particularity, and there is only one scheduler in the whole system. To avoid the user creating the scheduler for many times, the singleton mode can be used to check the scheduler before the creation. If there is no created scheduler, the scheduler is mounted to the attribute of the creation method after the creation; if there is a scheduler in the attribute of the creation method, it is indicated that the scheduler has been created before, and the user is given the previously created scheduler, so that the global uniqueness of the scheduler is ensured.
[0148] Further, the state data scheduling command comprises a command identifier and command data.
[0149] The scheduling command comprises two parts: one part is type, which is used for the unique marking of the command, that is, the command identifier; and the other part is data, which is the data required for executing the command, that is, the command data.
[0150] The business processing unit 502 is configured to perform business logic processing according to the state data scheduling command.
[0151] The scheduling command processing method interface handler is a common application programming interface (API) for message transmission, which is mainly used for message processing. The scheduling command processing method interface handler can be a scheduling command processing method written by the user. When the user writes the handler to process different business logics, the user can call the front-end and back-end programs as needed, obtain resources, execute scripts, and the like, to complete the entire business logic processing process, that is, the handler can be used as a bridge for connecting the front-end and back-end data. By abstracting the scheduling command processing method interface handler layer, the developer user can write the scheduling command processing logic by himself, so that the developer user has greater freedom and flexibility. The state data can comprise initial state data, temporary state data, intermediate state data, and final state data.
[0152] The notification sending unit 503 is configured to send the processed state data to the scheduler to update the data in the state data warehouse, and send a message to notify the subscriber in the subscriber list that the data in the state data warehouse has been updated after the data is updated.
[0153] The state data warehouse state is used for storing all state data and updating the state data. By storing all state data in the globally unique state data warehouse, the global sharing of the state data is ensured.
[0154] The subscribers in the subscriber list listeners can initiate a request to the dispatcher in advance according to needs and be set by the dispatcher. After each state data update is completed, the dispatcher sends a message to the subscribers in the subscriber list to inform all the subscribers that the state data update is completed.
[0155] Specifically, the method for state data management provided by the embodiment of the application can be used for managing global state data of user interaction (js) of a website developed by Django.
[0156] The above embodiment can achieve that the temporary and intermediate state data and other unnecessary state data do not need to be stored in the database, reduce the database redundant data, and also reduce the backend redundant code, so that the backend research and development can focus on the development of business logic and do not need to care about the management of intermediate state data, thereby helping to improve the research and development efficiency; the scheduling command processing method interface is adopted, the developer user can write the scheduling command processing logic by himself, thereby giving the developer user greater freedom and flexibility, the system is highly scalable, and team cooperation and maintenance are facilitated, and the system is suitable for large project development.
[0157] Further, the apparatus further includes:
[0158] The subscribing unit is configured to, in response to an initiated subscription request or a canceled subscription request of the B component, add or remove the B component from the subscriber list by the dispatcher in advance.
[0159] The watch method or the unwatch method can be called by the B component to listen to or cancel listening to the state data change, so that the B component enters or exits the subscriber list. Since the subscriber list is managed by the dispatcher, the dispatcher needs to initiate a related request.
[0160] Further, if the B component is included in the subscriber list, the B component receives the message that the data update in the state data warehouse is completed, and obtains the updated data in the state data warehouse for page display.
[0161] The B component listens to the state data change by calling the watch method, that is, the B component enters the subscriber list listeners. When the state data update is completed, the dispatcher manage notifies all the subscribers, and the B component receives the message sent by the dispatcher and calls the getState method to obtain the changed state data from the state data warehouse for page display.
[0162] In the above embodiment, the B component can obtain the status data update in real time by entering the subscriber list, and then realize real-time update of the page display data, so that the B component is responsible for the interface display more pure, the operation process is more fine and more standardized, and the database redundant data is reduced while the backend redundant code is reduced, which is helpful to improve the research and development efficiency.
[0163] Further, the status data scheduling command is sent by the A component to the scheduler.
[0164] The A component sends the status data scheduling command to the scheduler manage by the send method to schedule the status data uniformly.
[0165] Hereinafter, the embodiments of the present application are further described by specific examples:
[0166] For example, a page is composed of multiple components, assuming that there is a counter page composed of A component and B component at this time, the A component contains a button, and the B component contains the counting result. It is required to press the button in the A component, the B component counts plus 1, when it reaches 10, a record of the user reaching 10 is stored in the database, and the counting result is cleared.
[0167] The prior art method is to press a button to initiate a request, the request reaches the backend, the backend program adds 1 to the current value, stores the intermediate result data in the database, splices the calculation result to return a new page to the browser, and deletes the previous record of the intermediate result when it reaches 10, records a record of 10, and returns a new page with the value result of 0.
[0168] In the above process, the intermediate calculation results from 1 to 9 need to be stored in the database, which produces redundant data and redundant code in the backend program.
[0169] The method of the embodiment of the present application is that pressing a button in the A component sends an instruction, a user customizes and writes a processing process handler of the instruction, it is found that 10 has been added in the processing process, a back-end program is called to store in a database, the B component only needs to watch the change of data and display on a page, the business logic is put into the user-written processing process handler, which makes the operation flow granularity finer and more standardized, the component B is responsible for the interface display, which is more pure, meanwhile, the intermediate state data back-end program does not need to be perceived, the back-end program is shielded before the value is added to 10, and after being added to 10, it is stored in the repository, which reduces the database redundant data and the back-end redundant code; and the user state data is stored in a global unique state warehouse state, which guarantees the global sharing of the state; the global state data is processed through the methods such as send, watch and getState provided by the publish-subscribe mode construction, the writing is standardized, easy to understand and convenient for team maintenance; the handler layer is abstracted, the user can write the dispatch command processing logic by himself, and a greater freedom and flexibility are given to the developer.
[0170] Figure 6 A block diagram of an electronic device is provided for an exemplary embodiment of the present application. Figure 6 As shown, the electronic device includes one or more processors 610 and a memory 620.
[0171] The processor 610 can be a central processing unit (CPU) or other form of processing unit that has data processing and / or instruction execution capabilities, and can control other components in the electronic device to perform desired functions.
[0172] The memory 620 can include one or more computer program products that can include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM), cache memory, and / or the like. The non-volatile memory may, for example, include read-only memory (ROM), hard disk, flash memory, and / or the like. One or more computer program instructions can be stored on the computer-readable storage media, and the processor 610 can run the program instructions to implement the state data management method of the software program of each embodiment of the present application described above and / or other desired functions. In one example, the electronic device can further include an input device 630 and an output device 640, which are interconnected through a bus system and / or other forms of connection mechanism (not shown).
[0173] In addition, the input device 630 can also include, for example, a keyboard, a mouse, and the like.
[0174] The output device 640 can output various information to the outside. The output device 640 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0175] Of course, in order to simplify, Figure 6 Only some of the components of the electronic device related to the present application are shown in the middle, and components such as buses, input / output interfaces, and the like are omitted. In addition, the electronic device can further include any other appropriate components according to the specific application.
[0176] In addition to the above-mentioned method and device, the embodiments of the present application can also be a computer program product including computer program instructions, which, when executed by a processor, cause the processor to perform the steps of the state data management method according to various embodiments of the present application described in the above "Example Method" section of the present specification.
[0177] The computer program product can be written in any combination of one or more programming languages, including an object-oriented programming language such as Java, C++, and the like, and conventional procedural programming languages, such as the "C" programming language, or the like. The program code can be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0178] In addition, the embodiments of the present application can also be a computer readable storage medium having stored thereon computer program instructions, which, when executed by a processor, cause the processor to perform the steps of the state data management method according to various embodiments of the present application described in the above "Example Method" section of the present specification.
[0179] The computer readable storage medium can take any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include an electrical connection having one or more wires, a portable 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 appropriate combination of the above.
[0180] The above describes the basic principles of the present application in connection with specific embodiments, but it should be noted that the advantages, benefits, effects and the like mentioned in the present application are only examples and are not intended to be limiting, and these advantages, benefits, effects and the like should not be considered as necessary for each embodiment of the present application. In addition, the above-described specific details are only for the purpose of illustration and understanding, and are not intended to limit the present application to the above-described specific details.
[0181] Each embodiment in the present specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between each embodiment can be understood by referring to each other. For system embodiments, since they basically correspond to the method embodiments, the description is relatively simple, and the relevant parts can be understood by referring to the description of the method embodiments.
[0182] The block diagrams of the devices, apparatuses, equipment, systems involved in the present application are only illustrative examples and are not intended to require or imply the connection, arrangement, configuration shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, equipment, systems can be connected, arranged, configured in any manner. Words such as "include", "contain", "have" and the like are open-ended words, which mean "including but not limited to", and can be used interchangeably. The words "or" and "and" used herein mean the word "and / or", and can be used interchangeably unless the context clearly indicates otherwise. The word "such as" used herein means the phrase "such as but not limited to", and can be used interchangeably.
[0183] The methods and devices of the present application can be implemented in many ways. For example, the methods and devices of the present application can be implemented by software, hardware, firmware, or any combination of software, hardware, firmware. The above-described order of steps for the method is only for illustration, and the steps of the method of the present application are not limited to the above-described order, unless otherwise specifically described. In addition, in some embodiments, the present application can also be implemented as programs recorded in recording media, which include machine-readable instructions for implementing the method according to the present application. Therefore, the present application also covers the recording media storing the programs for executing the method according to the present application.
[0184] It is also important to note that the devices, apparatuses and methods described herein can be capable of further combination and / or rearrangement. Such combinations and / or rearrangements are also contemplated as equivalents of the described embodiments. The above description of the disclosed aspects il lustrates and describes the so-me aspects. Additionally, the description given is intended to be illustrative of the aspects and is not intended to be limiting. Numerous modifications, changes, variations, additions, and improvements can be made to the aspects without departing from the scope of the present disclosure as defined in the following claims. Accordingly, other aspects are within the scope of the following claims.
[0185] The above description has been presented for the purposes of illustration and description. Furthermore, the description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although several example aspects and embodiments have been discussed, those skilled in the art will recognize certain variations, modifications, changes, additions, and sub-combinations thereof.
Claims
1. A state data management method characterized by, The method applied to a scheduler comprises: receiving and forwarding a state data scheduling command to a scheduling command processing method interface, so that the scheduling command processing method interface performs business logic processing according to the state data scheduling command, and returns a processed state data notification to the scheduler; wherein the state data scheduling command is sent by an A component; receiving the processed state data notification, and updating data in a state data warehouse based on the processed state data notification; after the data in the state data warehouse is updated, sending a message to notify a subscriber in a subscriber list that the data in the state data warehouse is updated; wherein the method further comprises: in response to an initiation subscription request or a cancellation subscription request of a B component in advance, adding or removing the B component from the subscriber list; wherein if the B component is included in the subscriber list, the B component acquires updated data in the state data warehouse to perform page display after receiving the message that the data in the state data warehouse is updated.
2. The method of claim 1, wherein, The state data scheduling command comprises a command identifier and command data.
3. A state data management method characterized by, The method applied to a scheduling command processing method interface comprises: receiving a state data scheduling command forwarded by a scheduler; wherein the state data scheduling command is sent to the scheduler by an A component; performing business logic processing according to the state data scheduling command; sending a processed state data notification to the scheduler to update data in a state data warehouse, and sending a message to notify a subscriber in a subscriber list that the data in the state data warehouse is updated after the data is updated; wherein the method further comprises: in response to an initiation subscription request or a cancellation subscription request of a B component in advance, adding or removing the B component from the subscriber list; wherein if the B component is included in the subscriber list, the B component acquires updated data in the state data warehouse to perform page display after receiving the message that the data in the state data warehouse is updated.
4. The method of claim 3, wherein, The state data scheduling command comprises a command identifier and command data.
5. A state data management apparatus characterized by comprising: The device applied to a scheduler comprises: a command forwarding unit configured to receive and forward a state data scheduling command to a scheduling command processing method interface, so that the scheduling command processing method interface performs business logic processing according to the state data scheduling command, and returns a processed state data notification to the scheduler; wherein the state data scheduling command is sent by an A component; a data updating unit configured to receive the processed state data notification, and update data in a state data warehouse based on the processed state data notification; a message sending unit configured to send a message to notify a subscriber in a subscriber list that the data in the state data warehouse is updated after the data in the state data warehouse is updated; wherein the device further comprises a subscription unit configured to: in response to an initiation subscription request or a cancellation subscription request of a B component in advance, add or remove the B component from the subscriber list; If the B component is included in the subscriber list, the B component acquires updated data in the state data repository to perform page display after receiving a message that data in the state data repository is updated.
6. A state data management apparatus characterized by comprising: The device is applied to a scheduling command processing method interface, and includes: a command receiving unit, configured to receive a state data scheduling command forwarded by a scheduler; a service processing unit, configured to perform service logic processing according to the state data scheduling command; a notification sending unit, configured to send processed state data notification to the scheduler to update data in a state data repository, and send a message to notify a subscriber in a subscriber list that data in the state data repository is updated after the data is updated; If the B component is included in the subscriber list, the B component acquires updated data in the state data repository to perform page display after receiving a message that data in the state data repository is updated. The system includes: a scheduler, configured to receive and forward a state data scheduling command to a scheduling command processing method interface, receive processed state data notification returned by the scheduling command processing method interface, update data in a state data repository based on the processed state data notification, and send a message to notify a subscriber in a subscriber list that data in the state data repository is updated after the data is updated; 7. A state data management system, characterized by a scheduling command processing method interface, configured to receive a state data scheduling command, perform service logic processing according to the state data scheduling command, and return processed state data notification to the scheduler; a state data repository, configured to store state data and update the state data based on the processed state data notification; If the B component is included in the subscriber list, the B component acquires updated data in the state data repository to perform page display after receiving a message that data in the state data repository is updated. The state data scheduling command includes a command identifier and command data. The storage medium stores a computer program, and the computer program is used to execute the method in any one of claims 1-2 or the method in any one of claims 3-4.
10. An electronic device, comprising: a processor; 8. The system of claim 7, wherein, a memory for storing instructions executable by the processor; 9. A computer-readable storage medium, characterized in that, The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method of any one of claims 1-2 or the method of any one of claims 3-4.
Citation Information
Patent Citations
Chained processing-based data collecting system and method
CN103150324A
Storage state management method and system, electronic equipment and storage medium
CN111125126A
Data processing method and device, terminal and storage medium
CN113590351A