Dynamic management method and device of business object, equipment and medium
By integrating an object-oriented library to manage in-memory key-value databases, the method simplifies operations and enhances scalability and stability by eliminating serialization and deserialization requirements, addressing key duplication risks.
Patent Information
- Application Number
- CN202410990719.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-07-23
Smart Images

Figure CN119127868A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and medium for dynamic management of business objects. Background Art
[0002] In-memory key-value database is a database management system that stores data in memory and stores and retrieves it in the form of key-value pairs. It uses a hash table, and the key in the table is used to locate the value, that is, to store and retrieve specific values.
[0003] The traditional method of using an in-memory key-value database to save object data includes: 1) the business system creates an object as needed, fills in attributes, generates a unique non-repeating key (Key), serializes the object into a value (Value), and calls the database's set API; 2) the business system deletes an object as needed, needs to find the key (Key) of the original object, and calls the database's remove API; 3) the business system searches for an object as needed, needs to find the key (Key) of the original object, calls the database's getAPI to obtain the value (Value), and deserializes it into a business object; 4) the business system updates an object as needed, needs to find the key (Key) of the original object, calls the database getAPI to obtain the value (Value), and deserializes the value (Value) into the object old_object, assigns the attributes to be updated to old_object, serializes it into a value (Value), and then calls the database's setAPI to complete the update.
[0004] In the above method, although the in-memory key-value database improves the data processing speed, the hash table used in it uses the key to locate the value, and cannot directly index and query the value, which requires the business system to implement the serialization and deserialization process by itself, resulting in complicated code and poor user experience; furthermore, there is a risk of duplication of keys in different business systems, which can easily cause failure to insert into the database. In order to allow the business system to focus more on the content of the object itself without over-relying on related operations of the database. Therefore, an effective method is urgently needed to solve the above problems. Summary of the invention
[0005] In view of the above problems, the present invention is proposed to provide a method, apparatus, device and medium for dynamic management of business objects that overcome the above problems or at least partially solve the above problems.
[0006] To achieve the above objectives and other related objectives, the present invention provides a method for dynamic management of business objects, the method comprising:
[0007] Receive an operation request for a business object in an in-memory key-value database, create an object to be processed corresponding to the operation request in the business system, and fill in key attributes of the object to be processed;
[0008] Calling a target API corresponding to the operation request from an object-oriented library, passing the object to be processed and its parent class reference into the target API, and converting the parent class reference into a subclass reference of the object to be processed by using reflection through the target API;
[0009] Through the target API, the target name and key attribute of the object to be processed are queried from the name table and key attribute table of the business system, and the key value of the in-memory key-value database is generated by using the target name and the key attribute;
[0010] The operation corresponding to the operation request is performed on the in-memory key-value database according to the key value through the target API.
[0011] Optionally, before the step of receiving an operation request for a business object in the memory-type key-value database, the step further includes:
[0012] When the business system is initialized, multiple globally unique names are registered in a name table, and multiple different key attributes are registered in a key attribute table; wherein the name table is used to distinguish different businesses; and the key attribute table is used to distinguish different objects of the same business.
[0013] Optionally, performing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API includes:
[0014] When the operation request is a request to create a business object in the in-memory key-value database, traverse the attributes of the object to be processed by using the target API and serialize them into a string type value;
[0015] The key value and the value are saved in the in-memory key-value database.
[0016] Optionally, performing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API includes:
[0017] When the operation request is a request to delete a business object in the in-memory key-value database, querying a value corresponding to the key value from the in-memory key-value database using the target API;
[0018] The key value and the value are deleted from the in-memory key-value database.
[0019] Optionally, performing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API includes:
[0020] When the operation request is a request to query a business object in the in-memory key-value database, querying a value corresponding to the key value from the in-memory key-value database using the target API;
[0021] The value is deserialized into a business subclass object, and the business subclass object is returned to the business system.
[0022] Optionally, performing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API includes:
[0023] When the operation request is a request to update a business object in the in-memory key-value database, querying a value corresponding to the key value from the in-memory key-value database using the target API, and deserializing the value into a business subclass object;
[0024] Traversing the attributes of the object to be processed, obtaining the attributes and attribute values that need to be updated, and filling the attributes and attribute values that need to be updated into the business subclass object;
[0025] The business subclass object is reserialized into a second value, and the key value and the second value are saved in the in-memory key-value database.
[0026] Optionally, the method further comprises:
[0027] Receive a request for obtaining a list of objects in a memory-type key-value database, create a temporary object array corresponding to the request in a business system, and fill in key attributes of each temporary object; wherein the temporary object array contains one or more temporary objects;
[0028] Calling the target API corresponding to the acquisition request from the object-oriented library, and passing each temporary object and its parent class reference into the target API, and converting the parent class reference into a subclass reference of each temporary object through the target API using reflection;
[0029] Through the target API, query the target name of each temporary object from the name table of the business system, and query the target data corresponding to the target name in the in-memory key-value database according to the target name;
[0030] The target data is deserialized into subclass objects, and the subclass objects are added to a preset object list. After each subclass object is added to the object list, the object list is returned to the business system.
[0031] In a second aspect, the present invention further provides a dynamic management device for a business object, the device comprising:
[0032] A receiving module, used to receive an operation request for a business object in an in-memory key-value database, create an object to be processed corresponding to the operation request in the business system, and fill in key attributes of the object to be processed;
[0033] A calling module, used to call the target API corresponding to the operation request from the object-oriented library, and pass the object to be processed and its parent class reference to the target API, and through the target API, use reflection to convert the parent class reference into a subclass reference of the object to be processed;
[0034] A generating module, used to query the target name and key attribute of the object to be processed from the name table and key attribute table of the business system through the target API, and generate the key value of the memory-type key-value database by using the target name and the key attribute;
[0035] An execution module is used to execute the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API.
[0036] In a third aspect, the present invention provides an electronic device, comprising: a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program stored in the memory, so that the electronic device performs the steps of the dynamic management method of business objects as described above.
[0037] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by an electronic device, implements the steps of the method for dynamic management of business objects as described above.
[0038] The above one or more technical solutions provided by the present invention may have the following advantages or at least achieve the following technical effects:
[0039] The present invention discloses a method, apparatus, device and medium for dynamic management of business objects. The method comprises: receiving an operation request for a business object in a memory-type key-value database, creating an object to be processed corresponding to the operation request in a business system, and filling key attributes of the object to be processed; calling a target API corresponding to the operation request from an object-oriented library, and passing the object to be processed and its parent class reference into the target API, and using reflection to convert the parent class reference into a subclass reference of the object to be processed through the target API; querying the target name and key attributes of the object to be processed from the name table and key attribute table of the business system through the target API, and generating a key value of the memory-type key-value database using the target name and the key attribute; and performing the operation corresponding to the operation request on the memory-type key-value database according to the key value through the target API.
[0040] Therefore, the present invention introduces an object-oriented library between the business system and the in-memory key-value database, and can use the API in the object-oriented library to implement specific operations on the in-memory key-value database (such as creation, query, update, and deletion). This can effectively solve the technical problem of the business system's over-reliance on the in-memory key-value database, and improve the scalability and stability of the system, and the business system does not need to perceive the serialization and deserialization process of the business object. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 Shown is a schematic diagram of an application scenario of a conventional method of using a memory database to store objects in an embodiment of the present invention;
[0042] Figure 2 Shown is a schematic diagram of an application scenario of a method for dynamic management of business objects in one embodiment of the present invention;
[0043] Figure 3 Shown is a flow chart of a method for dynamic management of business objects in one embodiment of the present invention;
[0044] Figure 4 Shown is a schematic diagram of a process of creating an object in one embodiment of the present invention;
[0045] Figure 5 Shown is a schematic diagram of a process for updating an object in one embodiment of the present invention;
[0046] Figure 6 Shown is a schematic diagram of functional modules of a dynamic management device for business objects in one embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0048] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0049] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0050] The terms "first", "second", etc. in the specification and claims of the disclosed embodiments and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so that the embodiments of the disclosed embodiments described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.
[0051] Unless otherwise stated, the term "plurality" means two or more.
[0052] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.
[0053] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.
[0054] For ease of understanding, the following first explains the relevant nouns or terms used in the embodiments of the present invention:
[0055] <1> , In-memory database is a data management system that stores data in memory. Since the access speed of memory is much faster than that of disk, in-memory database can provide extremely high data reading and writing speed.
[0056] Common memory databases include: Redis, MemSQL, Menmcached, SAP HANA, SQLite, and Oracle Time Ten.
[0057] <2> , Relational Database, is a database created based on the relational model, using tables to represent data, and tables can be related to each other through relationships (keys). It supports complex query operations, transaction processing, data integrity and consistency, and is suitable for applications that need to process structured data.
[0058] Currently common relational databases include Oracle, MySQL, Microsoft SQL Server, DB2, etc. Each database has its own syntax, functions, and features.
[0059] <3> , Key-Value database, is a non-relational database that organizes, indexes and stores data in the form of key-value pairs. Through key-value (Key), the corresponding value (Value) can be found. It has the characteristics of fast query speed, large storage volume, and high concurrency support. Key-value record is the corresponding relationship between the key value and the value of the data. Key-value record is generated when new data is written.
[0060] <4> , Name Table, which is used to store various names used in the business, such as user names, product names, department names, etc. This table can be used to ensure the uniqueness of names and provide a unified name management mechanism. In different businesses, the name table can help distinguish and identify different businesses.
[0061] <5> , KeyAttribute Table, which is used to store the key attributes of business objects. The key attribute table can help distinguish different objects or instances of the same business.
[0062] Key attributes are attributes that are closely related to business logic, functions, or behaviors. These attributes are the core of business object identification, function implementation, and data storage. For example, they can be the unique identifier (ID) and creation time used to identify and define business objects when designing business objects.
[0063] <6> , Object-Oriented Database (OODB), usually contains a set of classes and interfaces; the API (application programming interface) of the object-oriented library can be designed to interact with the database.
[0064] The API provides methods to create (create), query (get), update (update), and delete (delete) object instances in the database. Specific subclasses are implemented according to different data types or operations.
[0065] <7> , parent class reference, in object-oriented programming, refers to a reference that directly points to a parent class object or any child class object. The use of this reference is based on the concepts of inheritance and polymorphism.
[0066] Inheritance can be used to define a class (subclass) in object-oriented programming to inherit the properties and methods of another class (parent class).
[0067] Polymorphism means that the same method can have different behaviors on different objects.
[0068] <8> , subclass reference, in object-oriented programming, refers to a reference directly pointing to a subclass object. This reference can be used to call all methods or properties defined in the subclass, including those inherited from the parent class and those specific to the subclass.
[0069] A subclass is a class that inherits from a parent class and can extend or modify the behavior of the parent class.
[0070] <9> , serialization is the process of converting the state information of an object into a format that can be stored or transmitted (usually a string or binary format).
[0071] <10> , Deserialization is the reverse process of serialization, which converts serialized data into the original object.
[0072] The technical solutions in the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0073] See also Figure 1 , Figure 1 This is a schematic diagram of the application scenario of the traditional method of using an in-memory database to save objects; refer to Figure 1 As shown, in the traditional method of using an in-memory database to save object data, the business system needs to save the relationship between existing objects and key values, as well as the business system's own serialization and deserialization process, which can easily lead to problems such as redundant code and poor user experience; furthermore, there is a risk of duplication of key values in different business systems, which can easily cause failure in inserting into the database.
[0074] See also Figure 2 , Figure 2 A schematic diagram of an application scenario of a dynamic management method for a business object is provided for an embodiment of the present invention; Figure 2 As shown, a specific scenario involved in a dynamic management method of a business object provided by an embodiment of the present invention is described. The application scenario may include a business system, an object-oriented library and an in-memory key-value database; wherein, an object-oriented library is introduced between the business system and the in-memory key-value database, and then the API in the object-oriented library can be used to implement specific operations on the in-memory key-value database (such as creation, query, update, and deletion), which can effectively solve the problem of business system dependence on the in-memory database and improve the scalability and stability of the system.
[0075] See also Figure 3 An embodiment of the present invention provides a method for dynamic management of business objects, which may include the following steps S10 to S40:
[0076] Step S10: receiving an operation request for a business object in an in-memory key-value database, creating an object to be processed corresponding to the operation request in a business system, and filling in key attributes of the object to be processed.
[0077] The operation request may include one or more of the requests for creating, deleting, querying, and updating business objects in the memory-type key-value database.
[0078] The object to be processed may be a business object created in the business system according to an operation request.
[0079] The key attribute may be an attribute that can be used as a unique identifier of the object to be processed when the object to be processed is created in the business system.
[0080] As an example, when the operation request is a request to create, delete, or query an object, the key attribute may include a key attribute of the object to be processed.
[0081] As another example, when the operation request is a request to update an object, the key attributes may include the key attributes of the object to be processed and the attributes that need to be updated.
[0082] The attributes that need to be updated may be key attributes that need to be updated for the object to be processed.
[0083] In a specific implementation, an operation request for a business object in an in-memory key-value database may be received; then the business system may create a to-be-processed object in the business system according to the operation request, and fill in key attributes of the to-be-processed object.
[0084] Step S20, calling the target API corresponding to the operation request from the object-oriented library, and passing the object to be processed and its parent class reference into the target API, and through the target API, using reflection to convert the parent class reference into the subclass reference of the object to be processed.
[0085] Object-oriented databases usually contain a set of classes and interfaces, where each class should be responsible for only one task. Specific subclasses can be implemented according to different data types or operations.
[0086] The target API may be an API that executes corresponding operations of the in-memory key-value database for the operation request; it may include but is not limited to: one or more of createAPI, deleteAPI, getAPI, updateAPI, and dumpAPI.
[0087] As an example, when the operation request is a request to delete an object, the delete API provided by the object-oriented library can be used to perform the delete operation of the in-memory key-value database; wherein the target API can be expressed as deleteAPI.
[0088] The parent class reference refers to a variable of the object to be processed, and its type is the parent class type inherited by the object to be processed. The target API needs to make different runtime decisions based on the actual type of the object to be processed (that is, the parent class type).
[0089] In a specific implementation, the target API corresponding to the operation request can be called from the object-oriented library; the object to be processed can be passed into the target API as an input parameter for further processing or operation by the target API, and the parent class reference of the object to be processed can be passed into the target API; the parent class reference can be converted into a subclass reference of the object to be processed by using reflection through the target API.
[0090] Step S30, through the target API, query the target name and key attribute of the object to be processed from the name table and key attribute table of the business system, and use the target name and the key attribute to generate the key value of the in-memory key-value database.
[0091] The name table may be a table formed by registering multiple globally unique names when the business system is initialized; it may be used to distinguish different businesses.
[0092] The key attribute table may be a table formed by registering multiple different key attributes when the business system is initialized; it may be used to distinguish different objects of the same business.
[0093] Target name, which can be the name of the object to be processed.
[0094] The key value (Key) can be a unique identifier of the object to be processed in the memory key-value database. Specifically, it is a unique string generated by the name and key attributes of the business object to be processed.
[0095] In a specific implementation, the target API can query the target name and key attributes of the object to be processed from the name table and key attribute table of the business system according to the type of the object to be processed; then, the target name and key attributes can be used to generate key values of an in-memory key-value database for the target API to perform further processing or operation based on the key values.
[0096] Step S40: executing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API.
[0097] In a specific implementation, after the key value is obtained, the operation corresponding to the operation request can be performed on the memory-type key-value database according to the key value through the target API.
[0098] As an example, when the operation request is a request to create an object, the object to be processed can be serialized into a string type value (Value) through the target API, and then the key (Key) and value (Value) are saved to an in-memory key-value database.
[0099] As another example, when the operation request is a request to delete an object, the key value can be used through the target API to query the in-memory key-value database to obtain string type data (that is, value Value), and then delete the value (Value) from the in-memory key-value database.
[0100] As another example, when the operation request is a request for a query object, the key value can be used through the target API to query in the in-memory key-value database to obtain string type data (that is, value); then the value can be deserialized into a business object and the business object can be returned to the business system.
[0101] Furthermore, in one embodiment, before step S10, the method may further include the following step P10:
[0102] Step P10, when the business system is initialized, multiple globally unique names are registered in a name table, and multiple different key attributes are registered in a key attribute table; wherein the name table is used to distinguish different businesses; and the key attribute table is used to distinguish different objects of the same business.
[0103] The name table may refer to a table containing multiple globally unique names in a business system, which can be used to distinguish different businesses. For example, it may include one or more of the businesses of creating an object, deleting an object, querying an object, or updating an object.
[0104] A key attribute table may refer to a table containing multiple different key attributes in a business system; it can be used to distinguish different objects of the same business.
[0105] In a specific implementation, when the business system is initialized, multiple globally unique names (Name) can be registered in the name table (Name Table), and multiple different key attributes can be registered in the key attribute table, so that when the business objects in the memory key-value database are subsequently created, deleted, queried, and updated, reflection can be used to query the names and key attributes of the objects to be processed from the name table and the key attribute table.
[0106] In this embodiment, the target API corresponding to the operation request is called from the object-oriented library, and the object to be processed and its parent class reference are passed into the target API, and through the target API, the parent class reference is converted into a subclass reference of the object to be processed by using reflection; through the target API, the target name and key attribute of the object to be processed are queried from the name table and key attribute table of the business system, and the key value of the memory key-value database is generated by using the target name and the key attribute; through the target API, the operation corresponding to the operation request is performed on the memory key-value database according to the key value. The present invention can introduce an object-oriented library between the business system and the memory key-value database, and then the API in the object-oriented library can be used to implement specific operations on the memory key-value database (such as creation, query, update, and deletion), which can effectively solve the technical problem that the business system is overly dependent on the memory key-value database, and improve the scalability and stability of the system, and the business system does not need to perceive the serialization and deserialization process of the business object.
[0107] Based on the above embodiments, a second embodiment of a dynamic management method for business objects of the present invention is proposed. Figure 4 In this embodiment, step S40 may include the following sub-steps A10 to A20:
[0108] Sub-step A10, when the operation request is a request to create a business object in the in-memory key-value database, traverse the attributes of the object to be processed using the target API and serialize them into a string type value.
[0109] Among them, attributes refer to variables defined in object-oriented programming and used to store business data and describe the characteristics of business objects; they reflect the status information of business objects.
[0110] In a specific implementation, when the operation request is a request to create a business object in an in-memory key-value database, the target API (ie, createAPI) can be used to traverse the properties of the object to be processed, and then all properties of the object to be processed can be serialized into a string type value (Value).
[0111] Sub-step A20, saving the key value and the value to the in-memory key-value database.
[0112] In a specific implementation, after obtaining the value of the object to be processed, the key value and value of the object to be processed can be saved into an in-memory key-value database through a target API (createAPI).
[0113] In this embodiment, when the operation request is a request to create a business object in the in-memory key-value database, the target API is used to traverse the attributes of the object to be processed and serialize them into string type values; the key value and the value are saved in the in-memory key-value database. Thus, the in-memory key-value database creation operation is implemented through the target API.
[0114] Based on the above embodiments, a third embodiment of a dynamic management method for business objects of the present invention is proposed. In this embodiment, step S40 may further include the following sub-steps B10 to B20:
[0115] Sub-step B10, when the operation request is a request to delete a business object in the in-memory key-value database, querying the value corresponding to the key value from the in-memory key-value database using the target API.
[0116] In a specific implementation, when the operation request is a request to delete a business object in an in-memory key-value database, the value corresponding to the key value can be queried from the in-memory key-value database using the target API (ie, deleteAPI) based on the key value of the object to be processed.
[0117] Sub-step B20, deleting the key value and the value from the memory-type key-value database.
[0118] In a specific implementation, after the value corresponding to the key value is queried, the key value and value of the object to be processed can be deleted from the memory-type key-value database using the target API (deleteAPI).
[0119] In this embodiment, when the operation request is a request to delete a business object in the memory-type key-value database, the target API is used to query the value corresponding to the key value from the memory-type key-value database; and the key value and the value are deleted from the memory-type key-value database. Thus, the deletion operation of the memory-type key-value database is realized through the target API.
[0120] Based on the above embodiments, a fourth embodiment of a dynamic management method for business objects of the present invention is proposed. In this embodiment, step S40 may further include the following sub-steps C10 to C20:
[0121] Sub-step C10, when the operation request is a request to query the business object in the in-memory key-value database, query the value corresponding to the key value from the in-memory key-value database using the target API.
[0122] In a specific implementation, when the operation request is a request to query a business object in an in-memory key-value database, the value corresponding to the key value can be queried from the in-memory key-value database using the target API (ie, getAPI) based on the key value of the object to be processed.
[0123] Sub-step C20, deserialize the value into a business subclass object, and return the business subclass object to the business system.
[0124] In a specific implementation, after the value corresponding to the key value is queried, the target API (getAPI) can be used to deserialize the value into a business subclass object; and then the target API (getAPI) can be used to return the business subclass object to the business system.
[0125] In this embodiment, when the operation request is a request to query a business object in the in-memory key-value database, the target API is used to query the value corresponding to the key value from the in-memory key-value database; the value is deserialized into a business subclass object, and the business subclass object is returned to the business system. Thus, the query operation of the in-memory key-value database is realized through the target API.
[0126] Based on the above embodiments, a fifth embodiment of a dynamic management method for business objects of the present invention is proposed. Figure 5 In this embodiment, step S40 may further include the following sub-steps D10 to D30:
[0127] Sub-step D10, when the operation request is a request to update a business object in the in-memory key-value database, query the value corresponding to the key value from the in-memory key-value database using the target API, and deserialize the value into a business subclass object.
[0128] The subclass business object (old_object) can be obtained by deserializing the value of the object to be processed by the target API (ie, update API).
[0129] In a specific implementation, when the operation request is a request to update a business object in an in-memory key-value database, the target API (updateAPI) can be used to query the value corresponding to the key value from the in-memory key-value database; and then the value can be deserialized into a business subclass object.
[0130] Sub-step D20, traversing the attributes of the object to be processed, obtaining the attributes and attribute values that need to be updated, and filling the attributes and attribute values that need to be updated into the business subclass object.
[0131] The attributes that need to be updated may be key attributes that need to be updated for the object to be processed.
[0132] Attribute value, which can be a specific numerical value assigned to a business object attribute. It is part of the business object state.
[0133] In a specific implementation, the target API (updateAPI) can be used to traverse the attributes of the object to be processed to obtain the attributes and attribute values that need to be updated; and then the attributes and attribute values that need to be updated can be filled into the business subclass object (old_object).
[0134] Sub-step D30, re-serialize the business subclass object into a second value, and save the key value and the second value to the in-memory key-value database.
[0135] The second value may be a value obtained by reserializing the business subclass object (old_object) after the attributes and attribute values to be updated are filled into the business subclass object (old_object).
[0136] In a specific implementation, after obtaining the second value, the key value and the second value of the business subclass object can be saved to the in-memory key-value database using the target API (update API).
[0137] In this embodiment, when the operation request is a request to update a business object in the in-memory key-value database, the target API is used to query the value corresponding to the key value from the in-memory key-value database, and the value is deserialized into a business subclass object; the attributes of the object to be processed are traversed to obtain the attributes and attribute values that need to be updated, and the updated attributes and the attribute values are filled into the business subclass object; the business subclass object is reserialized into a second value, and the key value and the second value are saved to the in-memory key-value database; thereby, the update operation of the in-memory key-value database is implemented through the target API.
[0138] Based on the above embodiments, a sixth embodiment of a method for dynamic management of business objects of the present invention is proposed. The method may further include the following steps S50 to S80:
[0139] Step S50, receiving a request for obtaining a list of objects in an in-memory key-value database, creating a temporary object array corresponding to the request in the business system, and filling in key attributes of each temporary object; wherein the temporary object array contains one or more temporary objects.
[0140] The temporary object array may be an object array created in the business system according to a request for obtaining an object list, and may include one or more temporary objects.
[0141] In a specific implementation, a request for obtaining a list of objects in an in-memory key-value database may be received; then the business system may create a temporary object array in the business system according to the request, and fill in the key attributes of each temporary object in the temporary object array.
[0142] Step S60, calling the target API corresponding to the acquisition request from the object-oriented library, and passing each temporary object and its parent class reference into the target API, and through the target API, using reflection to convert the parent class reference into the subclass reference of each temporary object.
[0143] In a specific implementation, the target API (i.e., dumpAPI) corresponding to the acquisition request can be called from the object-oriented library; then, each temporary object can be passed into the target API (dumpAPI) as an input parameter for further processing or operation by the target API (dumpAPI), and the key attributes of each temporary object can be passed into the target API (dumpAPI); then, the parent class reference can be converted into a subclass reference of the temporary object through reflection through the target API.
[0144] Step S70, querying the target name of each temporary object from the name table of the business system through the target API, and querying the target data corresponding to the target name in the in-memory key-value database according to the target name.
[0145] In the specific implementation, the target name of each temporary object can be queried from the name table of the business system according to the type of temporary object through the target API (dumpAPI); and then the target data corresponding to each target name can be queried in the memory key-value database through fuzzy query.
[0146] Step S80, deserialize the target data into subclass objects, and add the subclass objects to a preset object list, and after adding each subclass object to the object list, return the object list to the business system.
[0147] The object list may be a list pre-built in the memory key-value database, so that the target API can add subclass objects to the object list.
[0148] It should be noted that after the in-memory key-value data completes data retrieval, the target API can be used to return the populated object list to the business system.
[0149] In a specific implementation, the target data can be deserialized into subclass objects through the target API (dump API), and the subclass objects can be added to a preset object list; after the object list is filled, the object list can be returned to the business system through the target API (dump API).
[0150] In this embodiment, by receiving an acquisition request for an object list in an in-memory key-value database, a temporary object array corresponding to the acquisition request is created in the business system, and key attributes of each temporary object are filled; wherein the temporary object array contains one or more temporary objects; a target API corresponding to the acquisition request is called from an object-oriented library, and each temporary object and its parent class reference is passed into the target API, and through the target API, the parent class reference is converted into a subclass reference of each temporary object using reflection; through the target API, the target name of each temporary object is queried from the name table of the business system, and according to the target name, the target data corresponding to the target name is queried in the in-memory key-value database; the target data is deserialized into a subclass object, and the subclass object is added to a preset object list, and after each subclass object is added to the object list, the object list is returned to the business system. The present invention can introduce an object-oriented library between the business system and the in-memory key-value database, and then use the API in the object-oriented library to implement the operation of obtaining an object list from the in-memory key-value database, which can effectively solve the technical problem of the business system's over-reliance on the in-memory key-value database, and improve the scalability and stability of the system, and the business system does not need to perceive the serialization and deserialization process of the business object.
[0151] Based on the same inventive concept, the seventh embodiment of the present invention also provides a dynamic management device for business objects corresponding to the dynamic management method for business objects in the previous embodiment. Since the principle of solving the problem by the device in the seventh embodiment of the present invention is similar to the dynamic management method for business objects in the previous embodiment of the present invention, the implementation of the system can refer to the implementation of the method, and the repeated parts will not be repeated. Figure 6 The dynamic management device of the business object of the present invention may include:
[0152] The receiving module 10 is used to receive an operation request for a business object in the memory-type key-value database, create an object to be processed corresponding to the operation request in the business system, and fill in key attributes of the object to be processed;
[0153] A calling module 20 is used to call a target API corresponding to the operation request from an object-oriented library, and pass the object to be processed and its parent class reference to the target API, and based on the target API, use reflection to convert the parent class reference into a subclass reference of the object to be processed;
[0154] A generating module 30 is used to query the target name and key attribute of the object to be processed from the name table and key attribute table of the business system based on the target API, and generate a key value of the memory-based key-value database using the target name and the key attribute;
[0155] The execution module 40 is used to execute the operation corresponding to the operation request on the in-memory key-value database according to the key value based on the target API.
[0156] In addition, the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned dynamic management method of business objects is implemented.
[0157] This embodiment provides an electronic device. Specifically, the electronic device includes at least: a memory and a processor connected via a bus, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to execute all or part of the steps in the aforementioned method embodiment.
[0158] In summary, the present invention introduces an object-oriented library between the business system and the in-memory key-value database, and can use the API in the object-oriented library to implement specific operations on the in-memory key-value database (such as creation, query, update, and deletion). This can effectively solve the technical problem that the business system is overly dependent on the in-memory key-value database, and improve the scalability and stability of the system, and the business system does not need to perceive the serialization and deserialization process of the business object.
[0159] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A dynamic management method for business objects, characterized in that: The method comprises: Receive an operation request for a business object in an in-memory key-value database, create an object to be processed corresponding to the operation request in the business system, and fill in key attributes of the object to be processed; Calling a target API corresponding to the operation request from an object-oriented library, passing the object to be processed and its parent class reference into the target API, and converting the parent class reference into a subclass reference of the object to be processed by using reflection through the target API; Through the target API, the target name and key attribute of the object to be processed are queried from the name table and key attribute table of the business system, and the key value of the in-memory key-value database is generated by using the target name and the key attribute; The operation corresponding to the operation request is performed on the in-memory key-value database according to the key value through the target API.
2. The method according to claim 1, characterized in that Before the step of receiving an operation request for a business object in the memory-type key-value database, the method further includes: When the business system is initialized, multiple globally unique names are registered in a name table, and multiple different key attributes are registered in a key attribute table; wherein the name table is used to distinguish different businesses; and the key attribute table is used to distinguish different objects of the same business.
3. The method according to claim 1, characterized in that The step of performing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API includes: When the operation request is a request to create a business object in the in-memory key-value database, traverse the attributes of the object to be processed by using the target API and serialize them into a string type value; The key value and the value are saved in the in-memory key-value database.
4. The method according to claim 1, characterized in that: The step of performing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API includes: When the operation request is a request to delete a business object in the in-memory key-value database, querying a value corresponding to the key value from the in-memory key-value database using the target API; The key value and the value are deleted from the in-memory key-value database.
5. The method according to claim 1, characterized in that The step of performing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API includes: When the operation request is a request to query a business object in the in-memory key-value database, querying a value corresponding to the key value from the in-memory key-value database using the target API; The value is deserialized into a business subclass object, and the business subclass object is returned to the business system.
6. The method according to claim 1, characterized in that The step of performing the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API includes: When the operation request is a request to update a business object in the in-memory key-value database, querying a value corresponding to the key value from the in-memory key-value database using the target API, and deserializing the value into a business subclass object; Traversing the attributes of the object to be processed, obtaining the attributes and attribute values that need to be updated, and filling the attributes and attribute values that need to be updated into the business subclass object; The business subclass object is reserialized into a second value, and the key value and the second value are saved in the in-memory key-value database.
7. The method according to claim 1, characterized in that Also includes: Receive a request for obtaining a list of objects in a memory-type key-value database, create a temporary object array corresponding to the request in a business system, and fill in key attributes of each temporary object; wherein the temporary object array contains one or more temporary objects; Calling the target API corresponding to the acquisition request from the object-oriented library, and passing each temporary object and its parent class reference into the target API, and converting the parent class reference into a subclass reference of each temporary object through the target API using reflection; Through the target API, query the target name of each temporary object from the name table of the business system, and query the target data corresponding to the target name in the in-memory key-value database according to the target name; The target data is deserialized into subclass objects, and the subclass objects are added to a preset object list. After each subclass object is added to the object list, the object list is returned to the business system.
8. A dynamic management device for business objects, characterized in that: The device comprises: A receiving module, used to receive an operation request for a business object in an in-memory key-value database, create an object to be processed corresponding to the operation request in the business system, and fill in key attributes of the object to be processed; A calling module, used to call the target API corresponding to the operation request from the object-oriented library, and pass the object to be processed and its parent class reference to the target API, and through the target API, use reflection to convert the parent class reference into a subclass reference of the object to be processed; A generating module, used to query the target name and key attribute of the object to be processed from the name table and key attribute table of the business system through the target API, and generate the key value of the memory-type key-value database by using the target name and the key attribute; An execution module is used to execute the operation corresponding to the operation request on the in-memory key-value database according to the key value through the target API.
9. An electronic device, characterized in that: The electronic device comprises: a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device performs the steps of the method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and when the program is run, it is used to implement the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Request processing method and system, storage medium and electronic equipment
CN115374131A
Remote procedure call processing method and device based on API gateway
CN116074337A
Systems and methods for associative analysis of data
WO2024028652A1
