Method, System, Device, Storage Medium and Electronic Device for Processing Session Information
By storing session information in the first database and the second database, and deleting the session information in the server memory, and calling the corresponding session information from the second database, the problems of large memory usage and low load capacity are solved, and the persistence of session information and sharing between multiple servers are realized.
Patent Information
- Application Number
- CN202111425017.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-26
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2041-11-26
AI Technical Summary
In the prior art, session information is stored in the server's memory, resulting in a large memory footprint and low server load capacity. In the event of server failure or access pressure, session information is easily lost, making it difficult to effectively solve these problems.
Two-layer databases are used to store session information, the first database is used to store active session information, and the second database is used to store session information for a longer period of time. When the session ID is not found in the first database, the second database is searched, and after the session information stored in the second database is called, it is synchronized to the first database. At the same time, delete session information in each database that has expired or has not been called for a long time according to different time periods.
Through this method, the server memory usage is reduced, the server load capacity is improved, the session information is persistent and reliable, and the session sharing effect is achieved between multiple servers.
Smart Images

Figure CN114064780B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of fintech, and more particularly, to a method, system, device, storage medium, and electronic device for processing session information. Background Art
[0002] When using a web application, users use sessions for user account login authentication. However, after the user authenticates and logs in, if there is no interaction with the application for a long time, the server will automatically delete the session information after exceeding the timeout period, resulting in the inability to identify the user's identity and requiring the user to log in again. Usually, the server timeout period is 15 - 30 minutes. The user's session information is usually stored in the server's memory. At the same time, during the interaction between the user's browser and the server, the transmission of the session ID in the session information is required to complete the identity verification of the logged-in user.
[0003] In related technologies, the user's session information often exists in the memory of a single server. Storing session information on a single server will occupy too much memory when there is a large amount of session information. In the case of server failures, there is a problem of session information loss. At the same time, in the case of high access pressure or a large number of servers, there are performance bottlenecks in the memory storage capacity and it is easy to reach the performance ceiling.
[0004] In view of the problem in related technologies that storing session information in the server's memory occupies a large amount of memory and the server has low load capacity, no effective solution has been proposed yet. Summary of the Invention
[0005] This application provides a method, system, device, storage medium, and electronic device for processing session information to solve the problem in related technologies that storing session information in the server's memory occupies a large amount of memory and the server has low load capacity.
[0006] According to an aspect of the present application, a method for processing session information is provided. The method includes: obtaining a session request sent by a client, identifying a session ID from the session request, and detecting whether the session ID is stored in a first database, where the session request is a session request generated after successfully logging in to a target system on the client; in the case where the session ID is stored in the first database, obtaining the session information corresponding to the session ID from the first database, and invoking the session content in the session information, and returning the session content to the client; in the case where the session ID is not stored in the first database, detecting whether the session ID is stored in a second database, where the storage duration of the session information in the second database is longer than that in the first database; in the case where the session ID is stored in the second database, obtaining the session information corresponding to the session ID from the second database, and invoking the session content in the session information, and returning the session content to the client; in the case where the session ID is not stored in the second database, returning the information of the login interface of the target system.
[0007] Optionally, after obtaining the session information corresponding to the session ID from the second database and invoking the session content in the session information, the method further includes: storing the session information in the first database, and updating the call duration corresponding to the session information to an initial value.
[0008] Optionally, the method further includes: deleting, in the first database, session information whose call duration exceeds a first duration threshold according to a first time period, where the call duration is the duration from the time of the last call of the session information to the current time, and the call duration is updated to the initial value each time the session information is called; deleting, in the second database, session information whose call duration exceeds a second duration threshold according to a second time period, where the second duration threshold is greater than the first duration threshold.
[0009] Optionally, the method further includes: sending, according to a third time period, session information in the first database whose call duration is less than or equal to the first duration threshold to the second database, and overwriting the session information with the same session ID in the second database.
[0010] Optionally, before obtaining the session request sent by the client, the method further includes: receiving a login request sent by the client, identifying a user ID from the login request, and detecting whether the user ID is stored in the first database or the second database; in the case where the user ID is stored in the first database or the second database, returning duplicate login information to the client; in the case where the user ID is not stored in either the first database or the second database, creating a session ID corresponding to the user ID and session information corresponding to the session ID, storing the session information in the first database, and synchronizing the session information in the first database to the second database.
[0011] Optionally, after returning the repeated login information to the client, the method further includes: when receiving a request for continued login returned by the client, deleting the session information corresponding to the user ID in the first database, creating a session ID corresponding to the user ID and session information corresponding to the session ID, storing the session information in the first database, and synchronizing the session information in the first database to the second database.
[0012] According to another aspect of the present application, there is provided a session information processing system. The system includes: a client for sending a login request and a session request; a server communicatively connected to the client, with a first database provided in the server. The server is configured to, when receiving a login request, create a session ID corresponding to the user ID and session information corresponding to the session ID, store the session information in the first database, and synchronize the session information in the first database to the second database. The server is further configured to, when receiving a session request, return the session information stored in the first database or the second database to the client, where the storage duration of the session information in the first database is less than that in the second database; a second database provided outside the server and communicatively connected to the server for storing the session information in the first database in the server.
[0013] According to another aspect of the present application, there is provided a session information processing device. The device includes: a first detection unit for obtaining a session request sent by the client, identifying a session ID from the session request, and detecting whether the session ID is stored in the first database, where the session request is a session request generated after successfully logging in to the target system on the client; a first acquisition unit for, when the session ID is stored in the first database, obtaining the session information corresponding to the session ID from the first database, invoking the session content in the session information, and returning the session content to the client; a second detection unit for, when the session ID is not stored in the first database, detecting whether the session ID is stored in the second database, where the storage duration of the session information in the second database is greater than that in the first database; a second acquisition unit for, when the session ID is stored in the second database, obtaining the session information corresponding to the session ID from the second database, invoking the session content in the session information, and returning the session content to the client; a first return unit for, when the session ID is not stored in the second database, returning the information of the login interface of the target system.
[0014] According to another aspect of the embodiments of the present invention, there is further provided a non-volatile storage medium, which includes a stored program. When the program runs, it controls the device where the non-volatile storage medium is located to execute a session information processing method.
[0015] According to another aspect of the embodiments of the present invention, an electronic device is further provided, which includes one or more processors and a memory; computer-readable instructions are stored in the memory, and the processor is configured to run the computer-readable instructions, wherein when the computer-readable instructions run, a method for processing session information is executed.
[0016] Through the present application, the following steps are adopted: obtaining a session request sent by a client, identifying a session ID from the session request, and detecting whether the session ID is stored in a first database, wherein the session request is a session request generated after successfully logging in to a target system on the client; when the session ID is stored in the first database, obtaining the session information corresponding to the session ID from the first database, calling the session content in the session information, and returning the session content to the client; when the session ID is not stored in the first database, detecting whether the session ID is stored in a second database, wherein the storage duration of the session information in the second database is longer than that in the first database; when the session ID is stored in the second database, obtaining the session information corresponding to the session ID from the second database, calling the session content in the session information, and returning the session content to the client; when the session ID is not stored in the second database, returning the information of the login interface of the target system. The problem in the related art that session information is stored in the memory of the server, occupying a large amount of memory and having a low server load capacity is solved. By storing session information in the first database and the second database respectively, and calling the corresponding session information from the second server after the session information is deleted by the first server, the effect of sharing sessions among multiple servers while increasing the storage time and storage amount of session information is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0018] Figure 1 is a flowchart of a method for processing session information provided by an embodiment of the present application;
[0019] Figure 2 is a schematic diagram of a system for processing session information provided by an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of a device for processing session information provided by an embodiment of the present application;
[0021] Figure 4 is a schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0022] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0023] In order to enable those skilled in the art of the present technology to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned accompanying drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such data used in appropriate cases can be interchanged so as to implement the embodiments of the present application described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0025] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in the present disclosure are all information and data authorized by the user or fully authorized by all parties.
[0026] According to an embodiment of the present application, a method for processing session information is provided.
[0027] Figure 1 is a flowchart of the method for processing session information provided according to an embodiment of the present application. As Figure 1 shown, the method includes the following steps:
[0028] Step S101, obtain a session request sent by a client, identify a session ID from the session request, and detect whether the session ID is stored in a first database, where the session request is a session request generated after successfully logging in to a target system on the client.
[0029] Specifically, the first database can be the memory of the server. The user sends a session request to the server through the client. At this time, the session request is the session request after successfully logging in to the system. The session request sent by the user at this time contains the user ID and the session ID. The server first identifies the session ID, then queries the session ID in the memory of the server, and determines whether to store the session ID and the session information corresponding to the session ID. Among them, the session information includes the session ID, the user ID, the session content, and the call time.
[0030] Step S102, when the session ID is stored in the first database, obtain the session information corresponding to the session ID from the first database, call the session content in the session information, and return the session content to the client.
[0031] Specifically, the session content can be the relevant information of the user. For example, the bank card number, permission information, etc. When the server queries the session ID in the memory, it sends the session content corresponding to the session ID to the client. At this time, the user can directly perform corresponding operations without repeating the operation of inputting verification information. For example, when the user wants to query the account balance, the server identifies the session ID by identifying the user's request information, searches for the corresponding session ID in the memory, and after successful search, returns the account permission information in the session content to the client. After the client confirms that the account permission is correct, the user can directly query the account balance.
[0032] Step S103, when the session ID is not stored in the first database, detect whether the session ID is stored in the second database, where the storage duration of the session information in the second database is longer than that in the first database.
[0033] Specifically, the second database can be a memory cluster for storing session information. The memory cluster can store the session information in the memories of multiple servers, and the same session information is stored in the memory cluster for a longer time than in the server memory.
[0034] For example, it is stored in the server memory for 5 minutes and in the memory cluster for 15 minutes. When the server fails to query the user's session ID in the memory, it can search for the session ID in the memory cluster. Through the memory cluster, the sharing of session information between the memory and the server can be realized. For example, after the user logs in on Server 1, the user's session information is stored in the memory and also stored in the memory cluster. At this time, when a crash occurs in the server memory due to excessive stored information, the session information can be obtained through the memory cluster. By this method, the purpose of not affecting the user's use can be achieved.
[0035] Step S104, when the session ID is stored in the second database, obtain the session information corresponding to the session ID from the second database, call the session content in the session information, and return the session content to the client.
[0036] Specifically, when the server finds the session ID corresponding to the user in the memory cluster, it directly sends the session content corresponding to the session ID from the memory cluster to the client. At this time, the user can directly perform corresponding operations without repeating operations such as entering verification information.
[0037] Step S105, when the session ID is not stored in the second database, return the information of the login interface of the target system.
[0038] Specifically, when the server finds the session ID corresponding to the user in the memory cluster, it proves that the session information corresponding to the session ID is not stored in the server memory and the memory cluster. Then it is determined that the user's access has timed out, and information indicating login timeout is fed back to the client. The user needs to log in again.
[0039] The method for processing session information provided by the embodiments of the present application obtains a session request sent by a client, identifies a session ID from the session request, and detects whether the session ID is stored in a first database, where the session request is a session request generated after successfully logging in to a target system on the client; when the session ID is stored in the first database, obtain the session information corresponding to the session ID from the first database, call the session content in the session information, and return the session content to the client; when the session ID is not stored in the first database, detect whether the session ID is stored in a second database, where the storage duration of the session information in the second database is longer than that in the first database; when the session ID is stored in the second database, obtain the session information corresponding to the session ID from the second database, call the session content in the session information, and return the session content to the client; when the session ID is not stored in the second database, return the information of the login interface of the target system, which solves the problem in the related art that session information is stored in the server memory, occupying a large amount of memory and resulting in low server load capacity. By storing session information in the first database and the second database respectively and calling the corresponding session information from the second server after the first server deletes the session information, the effect of sharing sessions among multiple servers while increasing the storage time and storage amount of session information is achieved.
[0040] Optionally, in the method for processing session information provided in the embodiments of the present application, after obtaining the session information corresponding to the session ID from the second database and invoking the session content in the session information, the method further includes: storing the session information in the first database and updating the invocation duration corresponding to the session information to the initial value.
[0041] Specifically, when the server fails to query the session ID of the user in the memory, it is necessary to search for the session ID in the memory cluster. When the session ID is found in the memory cluster, the session information is returned to the server, and the server saves the session information in the server memory. At this time, when the user makes the next session request within a short period of time, the server can directly obtain the session information in the memory without entering the memory cluster for searching and obtaining. In this embodiment, the session information saved in the second database is synchronized to the first database to achieve data synchronization between the first and second databases, and the session information can be directly obtained from the first database when the session information is obtained next time.
[0042] Optionally, in order to prevent excessive session information stored in the first database and the second database from affecting the database performance, in the method for processing session information provided in the embodiments of the present application, the method further includes: deleting, in the first database, the session information whose invocation duration exceeds the first duration threshold according to the first time period, where the invocation duration is the duration from the time of the previous invocation of the session information to the current time, and the invocation duration is updated to the initial value each time the session information is invoked; deleting, in the second database, the session information whose invocation duration exceeds the second duration threshold according to the second time period, where the second duration threshold is greater than the first duration threshold.
[0043] Specifically, the server's memory can clear the session information in the memory according to the first time period to avoid excessive information storage affecting the server performance. For example, the session information is cleared once every 1 minute, and the session information to be cleared can be the session information whose invocation time exceeds the first duration threshold. For example, the first duration threshold can be set to 5 minutes. When the invocation time of the session information exceeds 5 minutes, the session information will be deleted during the next regular deletion.
[0044] It should be noted that the invocation time corresponds to the session ID. When the time for the user corresponding to the session ID to make the next session request is within 5 minutes, the invocation time corresponding to the session ID is changed to the initial value, that is, 0, and the timing is restarted until the user makes a session request again within 5 minutes or is deleted after exceeding 5 minutes.
[0045] Correspondingly, the session information in the memory cluster also needs to be deleted regularly. The session information in the memory cluster can be cleared according to a second time period to avoid excessive information storage from affecting the performance of the memory cluster. The second time period can be the same as or different from the first time period. For example, the session information can be cleared once every 1 minute. The session information to be cleared can be the session information whose call time exceeds the second duration threshold. For example, the second duration threshold can be set to 15 minutes. When the call time of the session information exceeds 15 minutes, the session information will be deleted the next time regular deletion is performed. Through this embodiment, the effects of reducing the memory of the first and second databases and improving the server operation efficiency are achieved.
[0046] Optionally, in order to synchronize the session information in the first database and the second database, in the method for processing session information provided in the embodiments of the present application, the method further includes: sending the session information in the first database with a call duration less than or equal to the first duration threshold to the second database according to a third time period, and overwriting the session information with the same session ID in the second database.
[0047] Specifically, when the call time in the server memory is updated, it is necessary to synchronize the changed session information from the memory to the memory cluster. At this time, it is necessary to send all the session information with a call time less than the first duration threshold to the memory cluster and replace the session information with the same session ID in the memory cluster, so as to complete the information synchronization.
[0048] For example, information synchronization is performed once every 1.5 minutes, and the non-timeout session information in the memory is synchronized to the memory cluster for storage. Through this step, the session information in the memory and the memory cluster is synchronized, so that after the session information in the memory is deleted, a backup is made in the memory cluster. Through this embodiment, the changed session information in the first database is synchronized to the second database, achieving the effect of synchronous change of the session information in the first and second databases.
[0049] Optionally, before the user successfully logs in, it is necessary to check whether the account is logged in repeatedly. In the method for processing session information provided in the embodiments of the present application, before obtaining the session request sent by the client, the method further includes: receiving the login request sent by the client, identifying the user ID in the login request, and detecting whether the user ID is stored in the first database or the second database; in the case where the user ID is stored in the first database or the second database, returning the repeated login information to the client; in the case where the user ID is not stored in both the first database and the second database, creating a session ID corresponding to the user ID and the session information corresponding to the session ID, storing the session information in the first database, and synchronizing the session information in the first database to the second database.
[0050] Specifically, when a user logs in on the client side, it is necessary to determine whether the account used by the user to log in has already been logged in on other servers. At this time, the server determines whether there is a corresponding session ID for the user ID of the user in the memory. When there is no corresponding session ID in the memory, a query is performed in the memory cluster. When there is no corresponding session ID in the memory cluster, it is determined that the account has not been logged in. The server creates a session ID corresponding to the user ID, associates the session ID with the session content, and initializes the call time. Among them, the method for creating the session ID can be to perform a hash calculation based on the combination of the current time, the server IP address, the network card MAC address, and a random number to generate the session ID. Through this method, a non-repeating session ID can be obtained, preventing the situation where multiple user IDs correspond to the same session ID. After generating the session information corresponding to the user ID, the session information is stored in the memory and the memory cluster.
[0051] When the session ID corresponding to the user ID is found in the memory or the memory cluster, it is determined that the account is logging in somewhere. At this time, the login information is returned to the client, and the client determines whether to overwrite the login. Through this embodiment, the effect of preventing the phenomenon of repeated login of the same account is achieved.
[0052] Optionally, in the method for processing session information provided in the embodiment of the present application, after returning the repeated login information to the client, the method further includes: when receiving a request for continued login returned by the client, deleting the session information corresponding to the user ID in the first database, creating a session ID corresponding to the user ID and the session information corresponding to the session ID, storing the session information in the first database, and synchronizing the session information in the first database to the second database.
[0053] Specifically, when the session ID corresponding to the user ID is found in the memory or the memory cluster, it is determined that the account is logging in somewhere. At this time, the login information is returned to the client, and the client determines whether to overwrite the login. After determining to overwrite the login, the server deletes all the session information corresponding to the user ID in the memory, re-creates the session ID corresponding to the user ID, associates the session ID with the session content, and initializes the call time. Among them, the method for creating the session ID can be to perform a hash calculation based on the combination of the current time, the server IP address, the network card MAC address, and a random number to generate the session ID. After generating the session information corresponding to the user ID, the session information is stored in the memory and the memory cluster. Through this embodiment, the effect of backing up the session information in the first database is achieved.
[0054] The embodiment of the present application also provides a processing system for session information. It should be noted that the processing system for session information in the embodiment of the present application can be used to execute the method for processing session information provided in the embodiment of the present application. The following introduces the processing system for session information provided in the embodiment of the present application.
[0055] Figure 2 is a schematic diagram of the processing system for session information provided in the embodiment of the present application, as Figure 2 shown, the system includes:
[0056] A client 201, configured to send a login request and a session request.
[0057] Specifically, the client 201 sends a login request when logging in for the first time, and sends a session request after successful login.
[0058] A server 202, communicatively connected to the client 201. A first database is set in the server 202. The server 202 is configured to, when receiving a login request, create a session ID corresponding to the user ID and session information corresponding to the session ID, store the session information in the first database, and synchronize the session information in the first database to a second database 203. The server 202 is further configured to, when receiving a session request, return the session information stored in the first database or the second database 203 to the client 201, where the storage duration of the session information in the first database is less than that in the second database 203.
[0059] Specifically, when a user logs in on the client 201, it is necessary to determine whether the account logged in by the user has been logged in on other servers 202. At this time, the server 202 determines whether there is a corresponding session ID in the memory for the user ID of the user. When there is no corresponding session ID in the memory, a query is performed in the memory cluster composed of multiple second databases 203. When there is no corresponding session ID in the memory cluster, it is determined that the account is not logged in, and the server 202 creates a session ID corresponding to the user ID, associates the session ID with the session content, and initializes the call time. Among them, the method for creating the session ID can be to perform a hash calculation based on the combination of the current time, the IP address of the server 202, the network card MAC address, and a random number to generate the session ID. Through this method, a non-repeating session ID can be obtained, preventing the situation where multiple user IDs correspond to the same session ID. After generating the session information corresponding to the user ID, the session information is stored in the memory and the memory cluster.
[0060] It should be noted that after successful login, the session information in the memory or the memory cluster is returned to the client 201, and the re-login interface is returned after the corresponding session information is not found.
[0061] The second database 203 is set outside the server 202 and is communicatively connected to the server 202 for storing the session information in the first database in the server 202.
[0062] Specifically, the second database 203 can be a memory cluster only used for storing session information. Multiple session information in the memory of multiple servers 202 can be stored in this memory cluster, and the storage time of the same session information in the memory cluster is longer than that in the memory of the server 202.
[0063] The session information processing system provided by the embodiments of the present application sends a login request and a session request through the client 201; the server 202 is communicatively connected to the client 201. A first database is set in the server 202. The server 202 is used to create a session ID corresponding to the user ID and the session information corresponding to the session ID when receiving the login request, store the session information in the first database, and synchronize the session information in the first database to the second database 203. The server 202 is also used to return the session information stored in the first database or the second database 203 to the client 201 when receiving the session request, where the storage duration of the session information in the first database is less than that in the second database 203; the second database 203 is set outside the server 202 and is communicatively connected to the server 202 for storing the session information in the first database in the server 202. This solves the problem in the related art that storing session information in the memory of the server occupies a large amount of memory and the server has a low load capacity. By setting up a database connected to the server and storing the memory in the server in an external database, and calling the corresponding session information from the external database after the session information is deleted from the server memory, the effect of increasing the storage time and storage amount of session information while enabling session sharing among multiple servers is achieved.
[0064] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0065] The embodiments of the present application also provide a processing device for session information. It should be noted that the processing device for session information in the embodiments of the present application can be used to execute the method for processing session information provided by the embodiments of the present application. The following introduces the processing device for session information provided by the embodiments of the present application.
[0066] Figure 3 It is a schematic diagram of the processing device for session information provided by the embodiments of the present application. As Figure 3 shown, the device includes:
[0067] A first detection unit 301, configured to obtain a session request sent by a client, identify a session ID from the session request, and detect whether the session ID is stored in a first database, where the session request is a session request generated after successfully logging in to a target system on the client;
[0068] A first acquisition unit 302, configured to, when the session ID is stored in the first database, obtain the session information corresponding to the session ID from the first database, call the session content in the session information, and return the session content to the client;
[0069] A second detection unit 303, configured to, when the session ID is not stored in the first database, detect whether the session ID is stored in a second database, where the storage duration of the session information in the second database is longer than that in the first database;
[0070] A second acquisition unit 304, configured to, when the session ID is stored in the second database, obtain the session information corresponding to the session ID from the second database, call the session content in the session information, and return the session content to the client;
[0071] A first return unit 305, configured to, when the session ID is not stored in the second database, return the information of the login interface of the target system.
[0072] The session information processing device provided by the embodiment of the present application obtains a session request sent by a client through the first detection unit 301, identifies the session ID from the session request, and detects whether the session ID is stored in the first database, where the session request is a session request generated after successfully logging in to the target system on the client; the first acquisition unit 302, when the session ID is stored in the first database, acquires the session information corresponding to the session ID from the first database, and invokes the session content in the session information, and returns the session content to the client; the second detection unit 303, when the session ID is not stored in the first database, detects whether the session ID is stored in the second database, where the storage duration of the session information in the second database is longer than that in the first database; the second acquisition unit 304, when the session ID is stored in the second database, acquires the session information corresponding to the session ID from the second database, and invokes the session content in the session information, and returns the session content to the client; the first return unit 305, when the session ID is not stored in the second database, returns the information of the login interface of the target system. This solves the problem in the related art that the session information is stored in the memory of the server, occupying a large amount of memory and resulting in low server load capacity. By storing the session information in the first database and the second database respectively, and invoking the corresponding session information from the second server after the session information is deleted from the first server, the effect of increasing the storage time and storage amount of the session information while enabling session sharing among multiple servers is achieved.
[0073] Optionally, in the session information processing device provided by the embodiment of the present application, it further includes: a first storage unit, configured to store the session information in the first database and update the call duration corresponding to the session information to the initial value.
[0074] Optionally, in the session information processing device provided by the embodiment of the present application, it further includes: a first deletion unit, configured to delete the session information whose call duration exceeds the first duration threshold in the first database according to the first time period, where the call duration is the duration from the time of the last call of the session information to the current time, and the call duration is updated to the initial value after each call of the session information; a second deletion unit, configured to delete the session information whose call duration exceeds the second duration threshold in the second database according to the second time period, where the second duration threshold is greater than the first duration threshold.
[0075] Optionally, in the session information processing device provided by the embodiment of the present application, it further includes: a first sending unit, configured to send the session information in the first database whose call duration is less than or equal to the first duration threshold to the second database according to the third time period, and overwrite the session information with the same session ID in the second database.
[0076] Optionally, in the session information processing device provided in the embodiments of the present application, it further includes: a first receiving unit, configured to receive a login request sent by a client, identify a user ID in the login request, and detect whether the user ID is stored in the first database or the second database; a second returning unit, configured to return duplicate login information to the client when the user ID is stored in the first database or the second database; a first creating unit, configured to create a session ID corresponding to the user ID and session information corresponding to the session ID when the user ID is not stored in both the first database and the second database, store the session information in the first database, and synchronize the session information in the first database to the second database.
[0077] Optionally, in the session information processing device provided in the embodiments of the present application, it further includes: a second creating unit, configured to delete the session information corresponding to the user ID in the first database, create a session ID corresponding to the user ID and session information corresponding to the session ID when receiving a request for continued login returned by the client, store the session information in the first database, and synchronize the session information in the first database to the second database.
[0078] The above session information processing device includes a processor and a memory. The above first detection unit 301, first acquisition unit 302, second detection unit 303, second acquisition unit 304, first return unit 305, etc. are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.
[0079] The processor includes a kernel, and the kernel retrieves the corresponding program units from the memory. One or more kernels can be set, and by adjusting the kernel parameters, the problem in the related art that session information is stored in the memory of the server, occupying a large amount of memory and having a low server load capacity is solved.
[0080] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.
[0081] The embodiments of the present invention provide a computer-readable storage medium, on which a program is stored, and when the program is executed by a processor, the session information processing method is implemented.
[0082] The embodiments of the present invention provide a processor, and the processor is used to run a program, where when the program runs, the session information processing method is executed.
[0083] As Figure 4As shown in the figure, an embodiment of the present invention provides an electronic device. The device 10 includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the following steps are implemented: obtaining a session request sent by a client, identifying a session ID from the session request, and detecting whether the session ID is stored in a first database, where the session request is a session request generated after successfully logging in to a target system on the client; in the case where the session ID is stored in the first database, obtaining the session information corresponding to the session ID from the first database, calling the session content in the session information, and returning the session content to the client; in the case where the session ID is not stored in the first database, detecting whether the session ID is stored in a second database, where the storage duration of the session information in the second database is longer than that in the first database; in the case where the session ID is stored in the second database, obtaining the session information corresponding to the session ID from the second database, calling the session content in the session information, and returning the session content to the client; in the case where the session ID is not stored in the second database, returning the information of the login interface of the target system. The device in this article can be a server, a PC, a PAD, a mobile phone, etc.
[0084] The present application also provides a computer program product, which, when executed on a data processing device, is adapted to execute a program initialized with the following method steps: obtaining a session request sent by a client, identifying a session ID from the session request, and detecting whether the session ID is stored in a first database, where the session request is a session request generated after successfully logging in to a target system on the client; in the case where the session ID is stored in the first database, obtaining the session information corresponding to the session ID from the first database, calling the session content in the session information, and returning the session content to the client; in the case where the session ID is not stored in the first database, detecting whether the session ID is stored in a second database, where the storage duration of the session information in the second database is longer than that in the first database; in the case where the session ID is stored in the second database, obtaining the session information corresponding to the session ID from the second database, calling the session content in the session information, and returning the session content to the client; in the case where the session ID is not stored in the second database, returning the information of the login interface of the target system.
[0085] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0086] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of the flows and / or blocks in the flowchart and / or block diagram can also be implemented. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0087] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0088] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0089] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.
[0090] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory is an example of computer-readable media.
[0091] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0092] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0093] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for processing session information, characterized in that, Including: Obtain a session request sent by a client, identify a session ID from the session request, and detect whether the session ID is stored in a first database, where the session request is a session request generated after successfully logging in to a target system on the client, and the first database is the memory of a server; When the session ID is stored in the first database, obtain session information corresponding to the session ID from the first database, call the session content in the session information, and return the session content to the client; When the session ID is not stored in the first database, detect whether the session ID is stored in a second database, where the storage duration of session information in the second database is longer than that in the first database, and the second database is a memory cluster for storing session information; When the session ID is stored in the second database, obtain session information corresponding to the session ID from the second database, call the session content in the session information, and return the session content to the client; When the session ID is not stored in the second database, return information of the login interface of the target system.
2. The method according to claim 1, wherein After obtaining the session information corresponding to the session ID from the second database and calling the session content in the session information, the method further includes: Store the session information in the first database, and update the call duration corresponding to the session information to an initial value.
3. The method according to claim 1, wherein: Delete session information whose call duration exceeds a first duration threshold in the first database according to a first time period, where the call duration is the duration from the time of the last call of the session information to the current time, and the call duration is updated to the initial value each time the session information is called; Delete session information whose call duration exceeds a second duration threshold in the second database according to a second time period, where the second duration threshold is greater than the first duration threshold.
4. The method according to claim 3, wherein: Send session information in the first database whose call duration is less than or equal to the first duration threshold to the second database according to a third time period, and overwrite session information with the same session ID in the second database.
5. The method according to claim 1, characterized in that Before obtaining the session request sent by the client, the method further includes: Receive a login request sent by the client, identify a user ID from the login request, and detect whether the user ID is stored in the first database or the second database; When the user ID is stored in the first database or the second database, return duplicate login information to the client; In the case where the user ID is not stored in both the first database and the second database, create a session ID corresponding to the user ID and the session information corresponding to the session ID, store the session information in the first database, and synchronize the session information in the first database to the second database.
6. The method according to claim 1, wherein After returning the repeated login information to the client, the method further includes: In the case of receiving a request for continued login returned by the client, delete the session information corresponding to the user ID in the first database, create a session ID corresponding to the user ID and the session information corresponding to the session ID, store the session information in the first database, and synchronize the session information in the first database to the second database.
7. A processing system for session information, characterized in that, The processing system for the session information is applicable to the method for processing session information according to any one of claims 1 to 6, and includes: A client for sending a login request and a session request; A server communicatively connected to the client. A first database is provided in the server. The server is configured to, in the case of receiving the login request, create a session ID corresponding to the user ID and the session information corresponding to the session ID, store the session information in the first database, and synchronize the session information in the first database to a second database. The server is further configured to, in the case of receiving the session request, return the session information stored in the first database or the second database to the client, wherein the storage duration of the session information in the first database is less than that in the second database; The second database is provided outside the server and communicatively connected to the server for storing the session information in the first database in the server.
8. A processing device for session information, characterized in that, Includes: A first detection unit for obtaining a session request sent by the client, identifying the session ID from the session request, and detecting whether the session ID is stored in the first database, wherein the session request is a session request generated after successfully logging in to the target system on the client, and the first database is the memory of the server; A first obtaining unit for, in the case where the session ID is stored in the first database, obtaining the session information corresponding to the session ID from the first database, invoking the session content in the session information, and returning the session content to the client; A second detection unit for, in the case where the session ID is not stored in the first database, detecting whether the session ID is stored in the second database, wherein the storage duration of the session information in the second database is greater than that in the first database, and the second database is a memory cluster for storing session information; A second obtaining unit for, in the case where the session ID is stored in the second database, obtaining the session information corresponding to the session ID from the second database, invoking the session content in the session information, and returning the session content to the client; A first return unit, configured to return information of a login interface of the target system when the session ID is not stored in the second database.
9. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored program, wherein when the program runs, it controls the device where the non-volatile storage medium is located to execute the session information processing method according to any one of claims 1 to 6.
10. An electronic device, characterized in that, Comprising one or more processors and a memory, the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the session information processing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Session information sharing method, device and system
CN106357778A
Account logout processing method, related device, server and medium
CN112839028A