CN109617953B - Session processing method and system - Google Patents

Session processing method and system Download PDF

Info

Publication number
CN109617953B
CN109617953B CN201811434590.3A CN201811434590A CN109617953B CN 109617953 B CN109617953 B CN 109617953B CN 201811434590 A CN201811434590 A CN 201811434590A CN 109617953 B CN109617953 B CN 109617953B
Authority
CN
China
Prior art keywords
session object
session
redissession
cached
filter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811434590.3A
Other languages
Chinese (zh)
Other versions
CN109617953A (en
Inventor
张永勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Asiainfo Technology Nanjing Co ltd
Original Assignee
Asiainfo Technology Nanjing Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Asiainfo Technology Nanjing Co ltd filed Critical Asiainfo Technology Nanjing Co ltd
Priority to CN201811434590.3A priority Critical patent/CN109617953B/en
Publication of CN109617953A publication Critical patent/CN109617953A/en
Application granted granted Critical
Publication of CN109617953B publication Critical patent/CN109617953B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management

Abstract

The invention discloses a session processing method and a session processing system, wherein a user request is obtained based on an interface function Filter of a session Filter, whether an original session object corresponding to the user request needs to be replaced by a cache session object is determined, a related function corresponding to a cache Redis assistant class in an operation function of the cache session object is called, and the attribute of the cache session object is stored in a cache Redis cluster. By the method disclosed by the invention, the cache session object returned to the interface function Filter is obtained, and then the attribute of the cache session object is stored in the cache Redis cluster. According to the method and the device, the attributes of the cached session object are stored in the cached Redis cluster, so that the session information can be persisted, and the session information can be quickly read.

Description

Session processing method and system
Technical Field
The present invention relates to the field of mobile service support, and more particularly, to a session processing method and system.
Background
Service Support Systems (BSS) are mainly used in the communication industry, and perform corresponding service operations through the system.
In the mobile service support system in the prior art, session adhesion and middleware weblogic cluster copy session memory are generally used to realize user state retention and session access performance. The session memory is copied through the middleware weblogic cluster, so that the session information cannot be lost when the application is abnormal, and the probability of copying the session memory is reduced to the maximum extent when the sessions are adhered.
In order to meet the requirement of the mobile service support system for evolution to a distributed environment, currently, in the evolution process, a middleware weblogic cluster in the mobile service support system needs to be transferred to a container docker environment.
The weblogic cluster of the middleware can not copy the memory of the session under the container environment, so that the user information is easily lost, and the access performance of the session is reduced.
Disclosure of Invention
In view of this, the present application provides a session processing method and system to achieve the purpose of quickly reading session information and persisting session information.
In order to achieve the above object, the following solutions are proposed:
the first aspect of the present invention discloses a session processing method, which includes:
acquiring a user request HttpServletRequest based on an interface function Filter of a preset session Filter HttpServlet, and transferring the user request HttpServletRequest to a Session management modification type SessionRequestWrapper for processing;
determining whether an original session object corresponding to the user request needs to be replaced by a cached session object RedisSession, if so, replacing the original session object by the cached session object RedisSession by using a session object operation function getSession in the Session request Wrapper of the session management modification class, and returning to the interface function Filter;
executing a corresponding session object operation function based on the cached session object RedisSession, and determining the attribute of the session object returned to the interface function Filter;
and calling a related function corresponding to the cache Redis helper class in the session object operation function, and storing the attribute of the cache session object Redis Session in a cache Redis cluster.
Preferably, the obtaining of the user request http request by the Filter based on the preset session Filter http servlet includes:
specifying the name Filter-name and class name Filter-class of the Session Filter HttpServlet;
configuring the session Filter http servlet based on the name Filter-name and the class name Filter-class in an xml file;
and associating the session Filter http servlet with the uniform resource locator URL, and establishing an interface function Filter of the session Filter http servlet.
Preferably, the determining whether the original session object corresponding to the user request needs to be replaced by a cached session object RedisSession includes:
acquiring an original session object corresponding to the user request;
judging whether the original session object has the sessionId, if so, judging whether the original session object is effective;
if the original session object is valid, determining that the original session object does not need to be replaced;
if the original session object is invalid, determining that the original session object needs to be replaced by a cached session object RedisSession;
and if the original session object does not exist, determining that the original session object needs to be replaced by a cached session object RedisSession.
Preferably, the executing a corresponding session object operation function based on the cached session object RedisSession, and determining the attribute of the session object returned to the interface function Filter includes:
judging whether the attribute of the cache session object RedisSession is empty or not based on the session object operation function in the cache session object RedisSession class;
if the cache session object is empty, returning to an interface function Filter, and if the cache session object is not empty, judging whether the attribute of the cache session object RedisSession exists;
if the attribute value of the cached session object RedisSession is empty, judging whether the attribute value of the cached session object RedisSession is empty, if so, deleting the attribute of the cached session object RedisSession, if not, updating the attribute of the cached session object RedisSession, and returning to an interface function Filter;
if not, judging whether the attribute value of the cache session object RedisSession is empty, if so, returning to an interface function Filter, and if not, establishing the attribute of the cache session object RedisSession and returning to the interface function Filter.
Preferably, the invoking a related function corresponding to a cached Redis helper class in the session object operation function, and storing the attribute of the cached session object RedisSession in a cached Redis cluster includes:
calling a relevant function corresponding to a cache Redis helper class in the session object operation function of the cache session object Redis Session class;
serializing the attribute of the caching session object RedisSession;
and storing the attribute of the serialized cached session object Redis Session in a cached Redis cluster.
The second aspect of the present invention discloses a session processing system, including:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a user request HttpServletRequest by an interface function Filter based on a preset session Filter HttpServlet, and transferring the user request HttpServletRequest to a session management modification type SessionRequestWrapper for processing;
a replacing unit, configured to determine whether an original session object corresponding to the user request needs to be replaced by a cached session object RedisSession, and if so, replace the original session object by the cached session object RedisSession using a session object operation function getSession in the session management modification type SessionRequestWrapper, and return to the interface function Filter;
the execution unit is used for executing a corresponding session object operation function based on the cached session object RedisSession and determining the attribute of the session object returned to the interface function Filter;
and the storage unit is used for calling a related function corresponding to the cache Redis helper class in the session object operation function and storing the attribute of the cache session object Redis Session in a cache Redis cluster.
Preferably, the obtaining unit, configured to obtain the user request http based on the interface function Filter of the preset session Filter http servlet, includes:
the system comprises a specifying module, a setting module and a setting module, wherein the specifying module is used for specifying the name Filter-name and the class name Filter-class of the session Filter HttpServlet;
the configuration module is used for configuring the session Filter HttpServlet based on the name Filter-name and the class name Filter-calls in a web.xml file;
and the association module is used for associating the session Filter http servlet with the uniform resource locator URL and establishing an interface function Filter of the session Filter http servlet.
Preferably, the replacing unit for determining whether it is necessary to replace the original session object corresponding to the user request with the cached session object RedisSession includes:
a request corresponding module, configured to obtain an original session object corresponding to the user request;
the first judging module is used for judging whether the original session object has the Session Id, if so, executing the second judging module, and if not, determining that the original session object needs to be replaced by a cache session object RedisSession;
and the second judgment module is used for judging whether the original session object is valid, if so, determining that the original session object does not need to be replaced, and if not, determining that the original session object needs to be replaced by a cached session object RedisSession.
Preferably, the executing unit, configured to execute the corresponding session object operation function based on the cached session object RedisSession, and determine the attribute of the session object returned to the interface function Filter, includes:
a third judging module, configured to judge, based on a session object operation function in the RedisSession class of the cached session object, whether an attribute of the RedisSession object is null, if so, return to an interface function Filter, and if not, execute a fourth judging module;
the fourth judging module is configured to judge whether an attribute of the cached session object RedisSession exists, if so, execute the fifth judging module, and if not, execute the sixth judging module;
the fifth judging module is configured to judge whether an attribute value of the cached session object RedisSession is null, delete the attribute of the cached session object RedisSession if the attribute value of the cached session object RedisSession is null, update the attribute of the cached session object RedisSession if the attribute value of the cached session object RedisSession is not null, and return to an interface function Filter;
and the sixth judging module is used for judging whether the attribute value of the cached session object RedisSession is null, if so, returning to an interface function Filter, and if not, newly establishing the attribute of the cached session object RedisSession and returning to the interface function Filter.
Preferably, the invoking a related function corresponding to a cached Redis helper class in the session object operation function, and storing the attribute of the cached session object RedisSession in a storage unit in a cached Redis cluster includes:
the calling module is used for calling a related function corresponding to a cache Redis helper class in the session object operation function of the cache session object Redis Session class;
the serialization module is used for serializing the attribute of the cache session object RedisSession;
and the attribute storage module is used for storing the attribute of the serialized cache session object Redis Session in a cache Redis cluster.
In a third aspect, the present invention discloses a storage medium, where the storage medium includes a stored program, and where the program is run to control a device on which the storage medium is located to execute a session processing method as disclosed in the first aspect of the present invention.
In a fourth aspect of the present invention, a processor is disclosed, the processor is configured to run a program, where the program executes a session processing method as disclosed in the first aspect of the present invention.
According to the technical scheme, the invention discloses a session processing method and a system, an interface function Filter based on a session Filter acquires a user request, determines whether an original session object corresponding to the user request needs to be replaced by a cached session object Redis Session, determines a new session object returned to the interface function Filter, calls a related function corresponding to a cached Redis helper class in an operation function of the new session object, and stores the attribute of the new session object in a cached Redis cluster. By the method disclosed by the invention, the cached session object Redis Session returned to the interface function Filter is obtained, and the attribute of the cached session object Redis Session is stored in the cached Redis cluster, wherein the cached Redis cluster not only can realize session information persistence, but also can quickly read session information.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a schematic flow chart of a session processing method disclosed in an embodiment of the present invention;
FIG. 2 is a flow chart illustrating an interface function of a default session filter according to an embodiment of the present invention;
fig. 3 is a schematic flowchart illustrating replacing an original session object with a cached session object according to an embodiment of the present invention;
FIG. 4 is a schematic diagram illustrating an attribute flow of a session object of a return interface function according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a session processing system according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an obtaining unit of a session processing system according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an alternative unit of a session processing system according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of an execution unit structure of a session processing system according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a storage unit of a session processing system according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In this application, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
As can be seen from the background, in the prior art, the user state retention and the session access performance are generally achieved by using the session adhesion and weblogic cluster replication session memory, which are mainly based on the mobile service support system. However, weblogic cluster replication of session memory cannot be realized in a docker environment, so that user information is easily lost, and the access performance of a session is reduced. Therefore, the invention discloses a method for processing a session, which aims to achieve the purposes of obtaining the session information persistence and rapidly reading the session information.
As shown in fig. 1, which is a schematic flow chart of a session processing method disclosed in the embodiment of the present invention, the method includes the following steps:
step S101: the method comprises the steps of obtaining a user request HttpServletRequest based on an interface function Filter of a preset session Filter HttpServlet, and transferring the user request HttpServletRequest to a Session management modification type SessionRequestWrapper for processing.
In the process of executing step S101, the user request is obtained through the interface function Filter of the preset session Filter http servlet.
In a specific implementation, the specific process of executing the interface function Filter of the preset session Filter http servlet in step S101 is as shown in fig. 2, and includes:
step S201: the name Filter-name and class name Filter-class of the session Filter http servlet are specified.
Step S202: xml file, configuring the session Filter http servlet based on the name Filter-name and the class name Filter-class.
Step S203: and associating the session Filter http servlet with the uniform resource locator URL, and establishing an interface function Filter of the session Filter http servlet.
The interface function Filter of the session Filter http servlet is established by executing the above steps S201 to S203. After an interface function Filter of the session Filter http servlet is established, obtaining a user request http request through the interface function Filter, and transferring the user request http request to a session management modification SessionRequestWrapper for processing.
Optionally, when configuring the session filter http servlet in the web.xml file, the embodiment of the present invention may be configured by using the following related program codes:
Figure GDA0003087856090000071
Figure GDA0003087856090000081
it should be noted that the session filter http servlet must be placed in the first of all the filters.
Step S102: and determining whether an original session object corresponding to the user request needs to be replaced by a cached session object RedisSession, if so, executing step S103, and if not, executing step S104.
In a specific implementation, the specific process of step S102 is executed, as shown in fig. 3, and mainly includes the following steps:
step S301: and acquiring an original session object corresponding to the user request.
Step S302: and judging whether the original session object has the SessionId, if so, entering the step S303, and if not, entering the step S305.
Step S303: and judging whether the original session object is valid, if so, entering the step S304, and if not, entering the step S305.
Step S304: determining that the original session object does not need to be replaced.
Step S305: determining that the original session object needs to be replaced with a cached session object RedisSession.
After the original session object corresponding to the user request is judged by executing the steps S301 to S305, it is determined whether the original session object needs to be replaced by a cached session object RedisSession.
Optionally, the present invention configures a session replication method in weblogic.xml, and adds or modifies a relevant code of a persistence store type of session as follows:
Figure GDA0003087856090000091
step S103: replacing the original session object with the cached session object RedisSesion by using a session object operation function getSesion in the Session management modification class SessionRequestWrapper, and returning the cached session object RedisSesion to the interface function Filter as a new session object.
In the process of executing step S103, the original session object is replaced by the cached session object RedisSession by operating the function getSession on the session object.
Step S104: and returning the original session object to the interface function Filter.
Step S105: and executing a corresponding session object operation function based on the cached session object RedisSession, and determining the attribute of the session object returned to the interface function Filter.
In a specific implementation, the specific process of step S105 is executed, as shown in fig. 4, and includes:
step S401: and judging whether the attribute of the cache session object Redis Session is empty or not based on the cache session object Redis Session, if not, executing the step S402, and if so, executing the step S408.
Step S402: and judging whether the attribute of the cache session object RedisSession exists or not, if so, executing the step S405, and if not, executing the step S403.
Step S403: and judging whether the attribute value of the cache session object RedisSession is empty, if so, executing the step S408, and if not, executing the step S404.
Step S404: and establishing the attribute of the caching session object RedisSession, and executing the step S408.
Step S405: and judging whether the attribute value of the cache session object RedisSession is empty, if so, executing step S407, and if not, executing step S406.
Step S406: and updating the attribute of the cached session object RedisSession, and executing the step S408.
Step S407: and deleting the attribute of the cached session object RedisSession.
Step S408: and returning to an interface function Filter.
By performing the above steps S401 to S408 to determine the attribute of the cached session object RedisSession and the attribute value of the cached session object RedisSession, at least one of creating the attribute of the cached session object RedisSession, updating the attribute of the cached session object RedisSession, or deleting the attribute of the cached session object RedisSession is performed.
It should be noted that, when the present invention is deployed and installed, redis _ session. jar is deployed under the WEB-INF/lib/directory of the application.
Step S106: and calling a related function corresponding to the cache Redis helper class in the session object operation function, and storing the attribute of the cache session object Redis Session in a cache Redis cluster.
It should be noted that, in the process of calling the relevant function corresponding to the cached Redis helper class, the attribute of the cached session object RedisSession is serialized, and the serialized attribute of the session object of the interface function Filter is stored in the Redis cluster.
It should be noted that relevant redis cluster configuration information is configured in redis _ config.
The attribute of the cached session object RedisSession is stored in a data structure in the cached Redis cluster, as shown in table 1:
TABLE 1
Session RedisSession
SessionId Session.Id Key value
Creation time Session.createTime .createTime
Last access time Session.lastAccessTime .accessTime
Whether to create a new cached session object Session.isNew isNew()
Application data SessionId.dada(hashtable) Key/value Key value pair
The attribute of the cached session object Redis Session is stored in a Redis cluster in a serialized form, and the attribute of the original session object and the attribute of the cached session object Redis Session are corresponding in a cached Redis data structure.
According to the session processing method disclosed by the embodiment of the invention, the user request is obtained based on the interface function Filter of the session Filter, whether the original session object corresponding to the user request needs to be replaced by the cached session object Redis Session is determined, the cached session object Redis Session of the interface function Filter is returned, the attribute of the session object returned to the interface function Filter is determined, and the attribute of the cached session object Redis Session is stored in the cached Redis cluster. Through the method disclosed by the invention, the cached session object RedisSession returned to the interface function Filter is obtained, and the attribute of the cached session object RedisSession is stored in the cached Redis cluster.
Based on the above method for processing a session disclosed in the embodiment of the present invention, the embodiment of the present invention also correspondingly discloses a session processing system, as shown in fig. 5, the session processing system 500 mainly includes:
an obtaining unit 501, configured to obtain a user request http request based on an interface function Filter of a preset session Filter http servlet, and transfer the user request http request to a session management modification type SessionRequestWrapper for processing;
a replacing unit 502, configured to determine whether an original session object corresponding to the user request needs to be replaced by a cached session object RedisSession, if so, replace the original session object by the cached session object RedisSession using a session object operation function getSession in the session management modified type SessionRequestWrapper, return the cached session object RedisSession as a new session object to the interface function Filter, and if not, return the original session object as the new session object to the interface function Filter;
an executing unit 503, configured to execute a corresponding session object operation function based on the cached session object RedisSession, and determine an attribute of the session object returned to the interface function Filter;
a storage unit 504, configured to invoke a relevant function corresponding to the cached Redis helper class in the session object operation function, and store the attribute of the cached session object RedisSession in a cached Redis cluster.
Further, the obtaining unit 501 of the interface function Filter process of the preset session Filter http servlet, as shown in fig. 6, includes:
a specifying module 601, configured to specify a name Filter-name and a class name Filter-class of the session Filter http servlet;
an xml file, configuring the session Filter http servlet based on the name Filter-name and the class name filters-calls;
the associating module 603 is configured to associate the session Filter http servlet with the URL, and establish an interface function Filter of the session Filter http servlet.
Further, the determining whether the original session object corresponding to the user request needs to be replaced by the replacing unit 502 of the cached session object RedisSession, as shown in fig. 7, includes:
a request corresponding module 701, configured to obtain an original session object corresponding to the user request.
A first determining module 702, configured to determine whether the original session object stores the SessionId, if so, execute a second determining module, and if not, determine that the original session object needs to be replaced by a cached session object ResdisSession.
The second determining module 703 is configured to determine whether the original session object is valid, determine that the original session object does not need to be replaced if the original session object is valid, and determine that the original session object needs to be replaced by a cached session object RedisSession if the original session object is invalid.
Further, the execution unit 503 that executes the corresponding session object operation function by the cached session object RedisSession, and determines the attribute of the session object returned to the interface function Filter, as shown in fig. 8, includes:
a third determining module 801, configured to determine whether an attribute of the cached session object RedisSession is null, if so, return to the interface function Filter, and if not, execute the fourth determining module 802;
the fourth determining module 802 is configured to determine whether an attribute of the cached session object RedisSession exists, if so, execute the fifth determining module 803, and if not, execute the sixth determining module 804;
the fifth determining module 803 is configured to determine whether an attribute value of the cached session object RedisSession is null, and if the attribute value of the cached session object RedisSession is null, execute to delete the attribute of the cached session object RedisSession; if not, executing updating the attribute of the cached session object RedisSession, and returning to an interface function Filter;
the sixth determining module 804 is configured to determine whether an attribute value of the cached session object RedisSession is null, and if the attribute value of the cached session object RedisSession is null, return to an interface function Filter; and if not, executing to newly establish the attribute of the cache session object RedisSession, and returning to an interface function Filter.
Further, the invoking a related function corresponding to the cached Redis helper class in the session object operation function, and storing the attribute of the cached session object RedisSession in the storage unit 504 in the cached Redis cluster, as shown in fig. 9, includes:
a calling module 901, configured to call a relevant function corresponding to a cached Redis helper class in the session object operation function of the cached session object RedisSession class;
a serialization module 902, configured to serialize an attribute of the cached session object RedisSession;
an attribute storage module 903, configured to store the serialized attribute of the cached session object RedisSession in a cached Redis cluster.
The specific principle and the execution process of each unit and each module in the session processing system disclosed in the above embodiment of the present invention are the same as the method for session processing disclosed in the above embodiment of the present invention, and reference may be made to corresponding parts in the session processing method disclosed in the above embodiment of the present invention, which are not described herein again.
Based on the session processing system disclosed in the embodiment of the present invention, the units and modules may be implemented by a hardware device including a processor and a memory. The method specifically comprises the following steps: the above units and modules are stored in a memory as program units, and the processor executes the program units stored in the memory to realize session processing.
The processor comprises a kernel, and the kernel calls a corresponding program unit from the memory. The kernel can set one or more than one kernel parameters to realize the session processing method.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, 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 disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (8)

1. A session processing method, comprising:
acquiring a user request HttpServletRequest based on an interface function Filter of a preset session Filter HttpServlet, and transferring the user request HttpServletRequest to a Session management modification type SessionRequestWrapper for processing;
determining whether an original session object corresponding to the user request needs to be replaced by a cached session object RedisSession, if so, replacing the original session object by the cached session object RedisSession by using a session object operation function getSession in the Session request Wrapper of the session management modification class, and returning to the interface function Filter;
executing a corresponding session object operation function based on the cached session object RedisSession, and determining the attribute of the session object returned to the interface function Filter;
calling a related function corresponding to a cache Redis helper class in the session object operation function, and storing the attribute of the cache session object Redis Session in a cache Redis cluster;
the determining whether the original session object corresponding to the user request needs to be replaced by a cached session object RedisSession includes:
acquiring an original session object corresponding to the user request;
judging whether the original session object has the sessionId, if so, judging whether the original session object is effective;
if the original session object is valid, determining that the original session object does not need to be replaced;
if the original session object is invalid, determining that the original session object needs to be replaced by a cached session object RedisSession;
and if the original session object does not exist, determining that the original session object needs to be replaced by a cached session object RedisSession.
2. The method according to claim 1, wherein the obtaining of the user request http request by the Filter based on the preset session Filter http servlet comprises:
specifying the name Filter-name and class name Filter-class of the Session Filter HttpServlet;
configuring the session Filter http servlet based on the name Filter-name and the class name Filter-class in an xml file;
and associating the session Filter http servlet with the uniform resource locator URL, and establishing an interface function Filter of the session Filter http servlet.
3. The method according to claim 1, wherein said executing the corresponding session object operation function based on the cached session object RedisSession, and determining the attribute of the session object returned to the interface function Filter comprises:
judging whether the attribute of the cache session object RedisSession is empty or not based on the session object operation function in the cache session object RedisSession class;
if the cache session object is empty, returning to an interface function Filter, and if the cache session object is not empty, judging whether the attribute of the cache session object RedisSession exists;
if the attribute value of the cached session object RedisSession is empty, judging whether the attribute value of the cached session object RedisSession is empty, if so, deleting the attribute of the cached session object RedisSession, if not, updating the attribute of the cached session object RedisSession, and returning to an interface function Filter;
if not, judging whether the attribute value of the cache session object RedisSession is empty, if so, returning to an interface function Filter, and if not, establishing the attribute of the cache session object RedisSession and returning to the interface function Filter.
4. The method according to claim 1, wherein the calling a correlation function corresponding to a cached Redis helper class in the session object operation function, and storing the attribute of the cached Redis Session object in a cached Redis cluster, comprises:
calling a relevant function corresponding to a cache Redis helper class in the session object operation function of the cache session object Redis Session class;
serializing the attribute of the caching session object RedisSession;
and storing the attribute of the serialized cached session object Redis Session in a cached Redis cluster.
5. A session processing system, comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a user request HttpServletRequest by an interface function Filter based on a preset session Filter HttpServlet, and transferring the user request HttpServletRequest to a session management modification type SessionRequestWrapper for processing;
a replacing unit, configured to determine whether an original session object corresponding to the user request needs to be replaced by a cached session object RedisSession, and if so, replace the original session object by the cached session object RedisSession using a session object operation function getSession in the session management modification type SessionRequestWrapper, and return to the interface function Filter;
the execution unit is used for executing a corresponding session object operation function based on the cached session object RedisSession and determining the attribute of the session object returned to the interface function Filter;
the storage unit is used for calling a related function corresponding to a cache Redis assistant class in the session object operation function and storing the attribute of the cache session object Redis Session in a cache Redis cluster;
the replacing unit for determining whether the original session object corresponding to the user request needs to be replaced by the cached session object RedisSession includes:
a request corresponding module, configured to obtain an original session object corresponding to the user request;
the first judging module is used for judging whether the original session object has the Session Id, if so, executing the second judging module, and if not, determining that the original session object needs to be replaced by a cache session object RedisSession;
and the second judgment module is used for judging whether the original session object is valid, if so, determining that the original session object does not need to be replaced, and if not, determining that the original session object needs to be replaced by a cached session object RedisSession.
6. The system according to claim 5, wherein the obtaining unit for obtaining the user request http request based on the interface function Filter of the http servlet, comprises:
the system comprises a specifying module, a setting module and a setting module, wherein the specifying module is used for specifying the name Filter-name and the class name Filter-class of the session Filter HttpServlet;
the configuration module is used for configuring the session Filter HttpServlet based on the name Filter-name and the class name Filter-calls in a web.xml file;
and the association module is used for associating the session Filter http servlet with the uniform resource locator URL and establishing an interface function Filter of the session Filter http servlet.
7. The system according to claim 5, wherein the execution unit for determining the attribute of the session object returned to the interface function Filter based on the cached session object RedisSession executing the corresponding session object operation function comprises:
a third judging module, configured to judge, based on a session object operation function in the RedisSession class of the cached session object, whether an attribute of the RedisSession object is null, if so, return to an interface function Filter, and if not, execute a fourth judging module;
the fourth judging module is configured to judge whether an attribute of the cached session object RedisSession exists, if so, execute the fifth judging module, and if not, execute the sixth judging module;
the fifth judging module is configured to judge whether an attribute value of the cached session object RedisSession is null, delete the attribute of the cached session object RedisSession if the attribute value of the cached session object RedisSession is null, update the attribute of the cached session object RedisSession if the attribute value of the cached session object RedisSession is not null, and return to an interface function Filter;
and the sixth judging module is used for judging whether the attribute value of the cached session object RedisSession is null, if so, returning to an interface function Filter, and if not, newly establishing the attribute of the cached session object RedisSession and returning to the interface function Filter.
8. The system according to claim 5, wherein the storage unit for calling a correlation function corresponding to a cached Redis helper class in the session object operation function and storing the attribute of the cached Redis Session object in a cached Redis cluster comprises:
the calling module is used for calling a related function corresponding to a cache Redis helper class in the session object operation function of the cache session object Redis Session class;
the serialization module is used for serializing the attribute of the cache session object RedisSession;
and the attribute storage module is used for storing the attribute of the serialized cache session object Redis Session in a cache Redis cluster.
CN201811434590.3A 2018-11-28 2018-11-28 Session processing method and system Active CN109617953B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811434590.3A CN109617953B (en) 2018-11-28 2018-11-28 Session processing method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811434590.3A CN109617953B (en) 2018-11-28 2018-11-28 Session processing method and system

Publications (2)

Publication Number Publication Date
CN109617953A CN109617953A (en) 2019-04-12
CN109617953B true CN109617953B (en) 2021-08-31

Family

ID=66005720

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811434590.3A Active CN109617953B (en) 2018-11-28 2018-11-28 Session processing method and system

Country Status (1)

Country Link
CN (1) CN109617953B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685304A (en) * 2013-12-25 2014-03-26 Tcl集团股份有限公司 Method and system for sharing session information
CN104580226A (en) * 2015-01-15 2015-04-29 上海瀚之友信息技术服务有限公司 Session data sharing system and method
CN106357778A (en) * 2016-09-27 2017-01-25 山东浪潮商用系统有限公司 Session information sharing method, device and system
CN106789872A (en) * 2016-11-11 2017-05-31 山东浪潮商用系统有限公司 A kind of session shared mechanism design based on cloud service
CN106921721A (en) * 2015-12-28 2017-07-04 华为软件技术有限公司 A kind of server, conversation managing method and system
CN107395711A (en) * 2017-07-17 2017-11-24 中国农业银行股份有限公司 Heterogeneous system session access method and relevant apparatus

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9218428B2 (en) * 2012-10-15 2015-12-22 Dell Products, L.P. Techniques for generating different sessions for multiple tabs of a single browser window
US11050832B2 (en) * 2017-03-29 2021-06-29 Citrix Systems, Inc. Maintaining a session across multiple web applications

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103685304A (en) * 2013-12-25 2014-03-26 Tcl集团股份有限公司 Method and system for sharing session information
CN104580226A (en) * 2015-01-15 2015-04-29 上海瀚之友信息技术服务有限公司 Session data sharing system and method
CN106921721A (en) * 2015-12-28 2017-07-04 华为软件技术有限公司 A kind of server, conversation managing method and system
CN106357778A (en) * 2016-09-27 2017-01-25 山东浪潮商用系统有限公司 Session information sharing method, device and system
CN106789872A (en) * 2016-11-11 2017-05-31 山东浪潮商用系统有限公司 A kind of session shared mechanism design based on cloud service
CN107395711A (en) * 2017-07-17 2017-11-24 中国农业银行股份有限公司 Heterogeneous system session access method and relevant apparatus

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Redis-Based web server cluster session maintaining technology;Songhuan Li;《2017 13th International Conference on Natural Computation,Fuzzy Systems and Knowledge Discovery(ICNC-FSKD)》;20180625;全文 *
基于Redis集群的分布式会话管理系统的设计与实现;蒋亮亮;《中国科技论文在线》;20170104;全文 *

Also Published As

Publication number Publication date
CN109617953A (en) 2019-04-12

Similar Documents

Publication Publication Date Title
US20220188170A1 (en) Multi-Tenant Control Plane Management on Computing Platform
CN109561128B (en) Data transmission method and device
EP3035216A1 (en) Cloud bursting a database
CN108255708B (en) Method, device, storage medium and equipment for accessing production file in test environment
CN107016016B (en) Data processing method and device
CN110968603B (en) Data access method and device
CN111240892A (en) Data backup method and device
CN103647811A (en) A method and an apparatus for application's accessing backstage service
CN109617953B (en) Session processing method and system
US10152490B2 (en) Sequential replication with limited number of objects
CN113077260A (en) Data access method and device based on block chain and electronic equipment
CN110298031B (en) Dictionary service system and model version consistency distribution method
CN110764930A (en) Request or response processing method and device based on message mode
CN111159298A (en) Service request processing method and device, electronic equipment and storage medium
CN112579639A (en) Data processing method and device, electronic equipment and storage medium
CN115934292A (en) Calling method, device and equipment of microservice application
CN115455121A (en) Real-time reliable data synchronous transmission method, equipment and medium
CN110413427B (en) Subscription data pulling method, device, equipment and storage medium
CN110059075B (en) Method, device and equipment for migrating database and computer readable medium
CN113867776A (en) Method and device for publishing middle station application, electronic equipment and storage medium
CN110321133B (en) H5 application deployment method and device
CN112579189A (en) Configuration file updating method and device
CN110868333A (en) Data caching method and system for gateway
CN112527792A (en) Data storage method, device, equipment and storage medium
CN116709280A (en) Bluetooth mesh gateway processing method and device and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant