A method, device, equipment and medium for data processing
By storing active session information of the online customer service system in memory and looking for target information from the database when obtaining exceptions, the problem of delay in ES storage sessions is solved, and timely access and efficient processing of session information is achieved.
Patent Information
- Application Number
- CN202311747569.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-18
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2043-12-18
AI Technical Summary
In the existing online customer service system, when ES is used to store user sessions, there is a delay in adding or updating operations, resulting in session status or unread messages that cannot be read in time, affecting the efficiency of the user session process.
By storing active session information in memory and finding the corresponding target session information from the database when the session information is acquired exception, ensuring timely access and low latency of session information.
It realizes timely access and low latency of user session information, improves the efficiency of user session process, and avoids data query exceptions caused by ES delay.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of Internet online customer service, and specifically to a method, device, equipment and medium for data processing. Background Art
[0002] Online customer service systems are an important tool for current Internet customers to communicate with enterprises. They are widely used in business scenarios such as insurance and e-commerce. Session management is particularly important in online customer service systems. In related technologies, ES (Elasticsearch, a distributed, highly scalable, and highly real-time search and data analysis engine) is generally used to store user sessions. However, during the application of ES, there is a delay when adding or updating data, resulting in the inability to read session status or unread messages in a timely manner.
[0003] Therefore, how to improve the efficiency of the user session process becomes a problem that needs to be solved. Summary of the invention
[0004] Embodiments of the present application provide a method, apparatus, device and medium for data processing. Through some embodiments of the present application, it is at least possible to ensure that user session information is accessed in a timely manner with low latency, thereby improving the efficiency of the user session process.
[0005] In a first aspect, the present application provides a method for data processing, the method comprising: confirming that at least one component of a user's session information in a memory has changed, extracting an ID of the session information, and sending the change information to a database for storage via the ID; in the event that the session information in the memory is acquired abnormally, searching the database for target session information corresponding to the ID, wherein the memory is used to store active session information in a communication process, and the database is used to store historical session information of completed communications and the change information.
[0006] Therefore, unlike the method of using ES to store user sessions in related technologies, the embodiment of the present application can ensure timely access to user session information with low latency by searching the database for target session information corresponding to the ID when abnormalities occur in obtaining memory session information, thereby improving the efficiency of the user session process.
[0007] In combination with the first aspect, in one embodiment of the present application, before confirming that there is a change in at least one component of the user's session information in the memory, the method also includes: when the user's session information is established for the first time, storing the user's session information in the memory in a data structure of a hash value, wherein the components include the ID value of the session information, the user ID, the agent ID, and the message content.
[0008] Therefore, the embodiment of the present application stores the active session in the memory when the user session is first established, so that it can be directly obtained from the memory during the reading process, thereby improving the efficiency of extracting session information.
[0009] In combination with the first aspect, in an implementation of the present application, the method further includes: determining that the session information of the user is the historical session information, storing the historical session information in the database, and storing the historical session information in the database in the dimension of the user.
[0010] Therefore, the embodiment of the present application can ensure that conversations that have not been communicated for a long time can be quickly extracted by storing historical conversation information in a database, without occupying memory space and improving the operating speed.
[0011] In combination with the first aspect, in one embodiment of the present application, after determining that the session information of the user is the historical session information, storing the historical session information in the database, and storing it in the database in the dimension of the user, the method also includes: deleting the key value corresponding to the session information in the customer service active session list in the memory, wherein the customer service active session list is used to store the correspondence between session information and corresponding customer service; deleting the session information in the memory.
[0012] Therefore, the embodiment of the present application can prevent duplicate storage between the memory and the database by deleting the content in the memory.
[0013] In combination with the first aspect, in one embodiment of the present application, after deleting the key value corresponding to the session information in the customer service active session list in the memory, the method further includes: if there are unread messages in the session information, retaining the session information in the memory.
[0014] Therefore, the embodiment of the present application can prevent the loss of unread messages by retaining the session information in the memory when there are unread messages.
[0015] In a second aspect, the present application provides a data processing device, comprising: a data storage module, configured to confirm that there is a change in at least one component of a user's session information in a memory, extract the ID of the session information, and send the change information to a database for storage through the ID; a data search module, configured to search the database for target session information corresponding to the ID when an abnormality occurs in obtaining the session information in the memory, wherein the memory is used to store active session information in a communication process, and the database is used to store historical session information of completed communications and the change information.
[0016] In combination with the second aspect, in one embodiment of the present application, the data storage module is also configured to: when the user's session information is established for the first time, store the user's session information in the memory in a data structure of a hash value, wherein the components include the ID value of the session information, user ID, agent ID and message content.
[0017] In combination with the second aspect, in one implementation of the present application, the device is further configured to: determine that the session information of the user is the historical session information, store the historical session information in the database, and store it in the database in the dimension of the user.
[0018] In combination with the second aspect, in one embodiment of the present application, the data storage module is further configured to: delete the key value corresponding to the session information in the customer service active session list in the memory, wherein the customer service active session list is used to store the correspondence between the session information and the corresponding customer service; delete the session information in the memory.
[0019] In combination with the second aspect, in one implementation of the present application, the data storage module is further configured to: retain the session information in the memory when there are unread messages in the session information.
[0020] In a third aspect, the present application provides an electronic device comprising: a processor, a memory and a bus; the processor is connected to the memory via the bus, the memory stores a computer program, and when the computer program is executed by the processor, it can implement the method described in any embodiment of the first aspect.
[0021] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed, can implement the method described in any embodiment of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A schematic diagram of a data processing scenario composition shown in an embodiment of the present application;
[0023] Figure 2 This is one of the flow charts of a data processing method shown in an embodiment of the present application;
[0024] Figure 3 A schematic diagram of a data processing device composition shown in an embodiment of the present application;
[0025] Figure 4 A schematic diagram of the composition of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0027] In related technologies, a session refers to a unit or channel for message transmission between the two ends of a communication (for example, users and customer service in an online customer service system). High-quality session management methods are the basis for ensuring stable, timely, and fast message transmission in online customer service systems. ES is called near real-time. Due to ES's own refresh mechanism, when adding or updating data in ES, there is a query delay of about one second, which means that when a piece of data is added or updated, the updated content cannot be queried within one second. When ES is used to manage sessions, the session status or the number of unread messages cannot be retrieved immediately, which has a great impact on the timeliness of the message. In addition, the session information is stored in the business database, and a redundant copy is required in ES. The consistency of the data needs to be maintained, which increases the operation and maintenance costs of the company's basic services.
[0028] Based on this, this application is mainly used to replace the use of ES, to avoid data query anomalies caused by ES delays, to ensure timely session access, low latency, and high availability in the session management of the online customer service system, and to provide maintenance and query of active sessions, historical sessions, and related session information.
[0029] The embodiments of the present application can be applied to the scenario of processing session information in an online customer service system. In order to improve the problems in the background technology, in some embodiments of the present application, active session information and historical session information are stored separately, and when at least one component of the session information changes, the session information ID is extracted, and the change information is sent to the database for storage through the ID. In the case of abnormal acquisition of session information, it can be extracted from the database in a timely manner, thereby ensuring the timeliness of data acquisition and improving session efficiency.
[0030] The method steps in the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0031] Figure 1A schematic diagram of a data processing scenario composition in some embodiments of the present application is provided, and the scenario includes: a user 110 and a client 120. Specifically, the user 110 enters a session in the client 120, and then the client 120 processes the session information by combining memory and database (for example, combining redis and MySQL) after receiving the session information, wherein redis mainly stores the current active session information, and MySQL is mainly used for persistent backup of data, archiving of historical session information, and maintenance of various components of the session information.
[0032] The following uses the client as an example to illustrate a data processing method provided by some embodiments of the present application. It is understandable that the execution subject of the data processing method of the present application can be any device that can execute the method, and the client is only an example, and the present application does not limit this.
[0033] At least to solve the problems in the background technology, such as Figure 2 As shown, some embodiments of the present application provide a method for data processing, the method comprising:
[0034] S210, confirm that at least one component of the user's session information in the memory has changed, extract the ID of the session information, and send the change information to the database for storage through the ID. S220, in the case of abnormal acquisition of the session information in the memory, search for the target session information corresponding to the ID in the database.
[0035] It should be noted that memory storage can be implemented based on redis. Redis is a key-value non-relational (NoSQL) database based on memory. Due to its memory-based nature, it has extremely high performance. At the same time, redis supports multiple data structures, which provides convenience for storing session information and maintaining the relationship between customers and sessions.
[0036] There are two types of session information: active session information and historical session information. The main scenario for active session information is that there are still messages, that is, the user and customer service are still in a session of sending messages. Historical session information is a session that has ended, so that customer service or supervisors can query chat information with users. The memory is used to store active session information in the communication process, and the database is used to store historical session information and change information of completed communications. When the session ends, the database stores historical session information in the dimension of the customer.
[0037] It should be noted that the components of active session information include: the content of the last message in the session, the number of unread customer service messages in the session, the session ID, etc., as well as the relationship between the logged-in agent and the session (i.e. the correspondence between customer service and the session), which is used to check the user who is currently asking questions at any time after logging into the customer service system.
[0038] In one embodiment of the present application, due to possible unknown anomalies, the data stored in redis is lost. When any component of the session information changes, the ID of the session information is pushed into a queue. This queue pulls the change information corresponding to the ID every 30 seconds and stores the change information in the database. When pushing the queue, first check whether the ID exists in the queue. If it exists, the current ID does not enter the queue. If it does not exist, the current ID is stored in the queue, thereby ensuring the efficiency of the update and avoiding repeated updates.
[0039] When users or agents query session information, they can use active session information or historical session information to obtain the user's session information ID, and then obtain user avatar, user nickname and other information. If the obtained session information is abnormal, since the above steps have backed up the changes in the session information in the database, the data can be obtained from the backup data of the database, that is, the data is no longer read from the memory.
[0040] Therefore, in order to achieve high availability of sessions, improve system stability, and prevent data loss caused by redis downtime, or active session query failure caused by redis's own network and other reasons, this application implements scheduled backup of active session attributes in addition to redis's own data persistence solution.
[0041] In one embodiment of the present application, when the user's session information is first established, the user's session information is stored in the memory in a hash value data structure, wherein the components include the session information ID value, user ID, seat ID and message content.
[0042] That is to say, after the user's session message is accessed, the session information is initialized first, and then the various components of the session information need to be stored, such as the customer's avatar, nickname, IP address, etc. At this time, the session is an active session, and the session information needs to be stored in redis. Specifically, first, the attribute information of the session is stored in redis in a Hash data structure, including the session information ID, customer ID, message content, time, type (for example, pictures, text, videos, etc.), and the assigned customer service ID, etc. Then, the key value of this redis is stored in the corresponding customer service active session list in a Set data structure, where the customer service active session list is used to store the corresponding relationship between session information and the corresponding customer service.
[0043] Therefore, the embodiment of the present application stores the active session in the memory when the user session is first established, so that it can be directly obtained from the memory during the reading process, thereby improving the efficiency of extracting session information.
[0044] In one implementation of the present application, the steps for processing historical session information are as follows:
[0045] First, it is determined that the user's session information is historical session information, and the historical session information is stored in a database, and is stored in the database in a user dimension.
[0046] That is to say, after the chat session between the user and the customer service ends (it can be manually ended by the customer service, or automatically determined as the chat session ends after a preset time), the session information is stored in the MySQL historical session data table, where the correspondence between the session information ID and the session information content is stored in the historical session data table. At this time, since the user may have had a conversation with the customer service before, it is necessary to delete the previous session in the customer dimension (the session ID, nickname, content and other components are not deleted, only the correspondence between the customer service and the session information is deleted), and the latest session is set to an available state.
[0047] Therefore, the embodiment of the present application can ensure that conversations that have not been communicated for a long time can be quickly extracted by storing historical conversation information in a database, without occupying memory space and improving the operating speed.
[0048] Then, the key value corresponding to the session information in the customer service active session list in the memory is deleted, wherein the customer service active session list is used to store the corresponding relationship between the session information and the corresponding customer service.
[0049] Therefore, the embodiment of the present application can prevent duplicate storage between the memory and the database by deleting the content in the memory.
[0050] Finally, in one case, the session information in memory is retained in the event that there are unread messages in the session information.
[0051] In another case, when there is no unread message in the session information, the session information in the memory is deleted.
[0052] That is to say, in order to ensure that the unread messages in the session information are not lost when the session information is read again, the present application needs to first determine whether there are unread messages in the current session information during the process of cleaning the contents in the memory. If the number of unread messages is greater than 0, it means that there are unfinished communications in the current session information, so it cannot be deleted from the memory. If the number of unread messages is equal to 0, it means that there are no unfinished communications in the current session information, so the session information can be deleted from the memory.
[0053] Specifically, after the maintenance of the user's historical session information is completed, the data stored in redis will be processed. First, the key value of the session will be deleted from the customer service active session list stored in the Set structure. Since the key value in the customer service active session list is the agent ID and the user's session information ID, and the correspondence between the agent and the session information, then since the current session has been completed, the correspondence between the agent and the session information can be deleted. Then, it is determined whether the session information can be deleted based on whether there are unread messages in the current user's session information. Specifically, verify whether the number of unread messages of the customer service at this time is 0. If it is greater than 0, the session information will not be deleted. If it is equal to 0, the session information stored in the Hash data structure will be deleted.
[0054] Therefore, the embodiment of the present application can prevent the loss of unread messages by retaining the session information in the memory when there are unread messages.
[0055] Therefore, the key protection points of this application include: the structure of redis storage, the coordination of storage between redis and mysql. The overall session information storage mode realizes the separation of cold and hot data. With data security as the priority principle, all data will eventually be stored in the mysql database with higher stability.
[0056] Therefore, unlike the method of using ES to store user sessions in related technologies, the embodiment of the present application can ensure timely access to user session information with low latency by searching the database for target session information corresponding to the ID when abnormalities occur in obtaining memory session information, thereby improving the efficiency of the user session process.
[0057] A specific embodiment of a data processing method is described above, and a data processing device will be described below.
[0058] like Figure 3As shown, some embodiments of the present application provide a data processing device 300 , which includes: a data storage module 310 and a data search module 320 .
[0059] The data storage module 310 is configured to confirm that at least one component of the user's session information in the memory has changed, extract the ID of the session information, and send the change information to the database for storage through the ID; the data search module 320 is configured to search the database for target session information corresponding to the ID when the session information in the memory is abnormally obtained, wherein the memory is used to store active session information in the communication process, and the database is used to store historical session information of completed communication and the change information.
[0060] In one embodiment of the present application, the data storage module 310 is also configured to: when the user's session information is established for the first time, store the user's session information in the memory in a data structure of a hash value, wherein the components include the ID value of the session information, the user ID, the agent ID and the message content.
[0061] In one implementation of the present application, the device is further configured to: determine that the session information of the user is the historical session information, store the historical session information in the database, and store it in the database in the dimension of the user.
[0062] In one embodiment of the present application, the data storage module 310 is also configured to: delete the key value corresponding to the session information in the customer service active session list in the memory, wherein the customer service active session list is used to store the correspondence between the session information and the corresponding customer service; delete the session information in the memory.
[0063] In an implementation manner of the present application, the data storage module 310 is further configured to: when there are unread messages in the session information, retain the session information in the memory.
[0064] In the embodiments of the present application, Figure 3 The modules shown can achieve Figure 1 , Figure 2 Each process in the method embodiment. Figure 3 The operations and / or functions of each module in Figure 1 , Figure 2 For details, please refer to the description in the above method embodiment. To avoid repetition, detailed description is appropriately omitted here.
[0065] like Figure 4As shown, an embodiment of the present application provides an electronic device 400, including: a processor 410, a memory 420 and a bus 430, wherein the processor is connected to the memory via the bus, and the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, they are used to implement a method as described in any one of the above embodiments. For details, please refer to the description in the above method embodiments. To avoid repetition, the detailed description is appropriately omitted here.
[0066] Among them, the bus is used to realize the direct connection and communication of these components. Among them, the processor in the embodiment of the present application can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0067] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the method described in the above embodiment may be executed.
[0068] Understandably, Figure 4 The structure shown is for illustration only and may also include Figure 4 More or fewer components as shown, or with Figure 4 Different configurations are shown. Figure 4 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0069] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a server, any method described in any of the above-mentioned embodiments is implemented. For details, please refer to the description in the above-mentioned method embodiments. To avoid repetition, the detailed description is appropriately omitted here.
[0070] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0071] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for data processing, characterized in that: The method comprises: Confirm that at least one component of the user's session information in the memory has changed, extract the ID of the session information, and send the change information to the database for storage through the ID; In the case where the acquisition of the session information in the memory is abnormal, the target session information corresponding to the ID is searched in the database, wherein the memory is used to store active session information in the communication process, and the database is used to store historical session information of completed communication and the change information, and the components of the active session information include: the content of the last message of the session, the number of unread messages of the customer service of the session, and the session ID.
2. The method according to claim 1, characterized in that Before confirming that at least one component of the user's session information in the memory has been changed, the method further includes: When the user's session information is first established, the user's session information is stored in the memory in a data structure of a hash value, wherein the components include an ID value of the session information, a user ID, an agent ID, and message content.
3. The method according to claim 1, characterized in that The method further comprises: The session information of the user is determined to be the historical session information, and the historical session information is stored in the database, and is stored in the database in the dimension of the user.
4. The method according to claim 3, characterized in that After determining that the session information of the user is the historical session information, storing the historical session information in the database, and storing the historical session information in the database in the dimension of the user, the method further includes: Deleting the key value corresponding to the session information in the customer service active session list in the memory, wherein the customer service active session list is used to store the corresponding relationship between the session information and the corresponding customer service; The session information in the memory is deleted.
5. The method according to claim 4, characterized in that After deleting the key value corresponding to the session information in the customer service active session list in the memory, the method further includes: In the case where there are unread messages in the session information, the session information in the memory is retained.
6. A data processing device, characterized in that: The device comprises: a data storage module configured to confirm that at least one component of the user's session information in the memory has changed, extract the ID of the session information, and send the change information to the database for storage through the ID; The data search module is configured to search the database for target session information corresponding to the ID when the acquisition of the session information in the memory is abnormal, wherein the memory is used to store active session information in the communication process, and the database is used to store historical session information of completed communication and the change information, and the components of the active session information include: the content of the last message of the session, the number of unread customer service messages of the session, and the session ID.
7. The device according to claim 6, characterized in that The data storage module is further configured as: When the user's session information is first established, the user's session information is stored in the memory in a data structure of a hash value, wherein the components include an ID value of the session information, a user ID, an agent ID, and message content.
8. The device according to claim 6, characterized in that The device is also configured to: The session information of the user is determined to be the historical session information, and the historical session information is stored in the database, and is stored in the database in the dimension of the user.
9. An electronic device, characterized in that: include: processor, memory, and bus; The processor is connected to the memory via the bus, the memory stores a computer program, and the computer program, when executed by the processor, can implement the method as claimed in any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed, can implement the method as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Session information processing method, system and device, storage medium and electronic equipment
CN114064780A