-
Notifications
You must be signed in to change notification settings - Fork 38
Session management
Alexey Yakovlev edited this page May 21, 2018
·
2 revisions
Zyan Framework supports complex and flexible session management. Session manager carries the following:
- Ensures authentication through the entire call chain
- Caches session variables
Zyan is shipped with two built-in session managers. Both classes reside in Zyan.Communication.SessionMgmt
namespace.
Class name | Description |
---|---|
InProcSessionManager (Default) | Session data is stored in the server's process memory. This option is highly effective, but is not suitable for multi-server cluster. This is the best choice for small and mid-size projects. |
SqlSessionManager | Session data is stored in SQL database. It allows to share session data between several servers. This option is somewhat slower because session data has to be received from server. |
You can choose the desired session management strategy by passing session manager instance to ZyanComponentHost
constructor. By default (for example, if you supply NULL), InProcSessionManager
class will be used.
var protocol = new TcpBinaryServerProtocolSetup() { TcpPort = 8080 };
// SQL Server connection string
var connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;";
// Set up SQL session manager. Sessions table name: "Session", variables table name: "SessionVar", schema: "dbo"
var sessionManager = new SqlSessionManager(connectionString, "dbo", "Session", "SessionVar");
// Run host with SQL session manager
var host = new ZyanHost("ExampleHost", protocol, sessionManager);
You can write your own session manager by implementing ISessionManager interface.