Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New-Cache parameters for AppFabric Cache when storing ASP.NET Session State

What are the "optimal" parameters for creating an AppFabric cache when you will be storing session state in the cache? MSDN Cache-Related Commands

Powershell command line:

New-Cache [-CacheName] <String> [-Eviction <String>] [-Expirable <String>] [-Force [<SwitchParameter>]] [-NotificationsEnabled <String>] [-Secondaries <Int32>] [-TimeToLive <Int64>]
  • CacheName: < application name >-session-state
  • Secondaries: 1 (High Availability turned on in case of server failure)
  • Eviction: ?
  • Expireable: ?
  • TimeToLive: ?
  • Force: ?
  • NotificationsEnabled: ?

Since I don't want my sessions to be removed unless the session has been abandoned either via code or Session Timeout...

For eviction, I would think "None" and for expireable, I would think False.

I have tested and calling Session.Abandon does remove the object from the cache. I have also tested to see if by extending my session, the session object in cache is also extended. This does seem to work the "correct" way.

like image 273
Mike Schall Avatar asked Jul 28 '10 17:07

Mike Schall


1 Answers

A post from a MS employee confirms my findings.

2) Since your question is in the context of session state, when you use the session state provider, the session object is stored in the cache with a timeout equal to the ASP.Net session timeout. Each time the session is accessed, the timeout of the session object in the cache is also reset to the session timeout. It is made sure that the session object expires from the cache only when the ASP.Net session times-out.session times-out.

I still need to create a named cache to get High Availability, but looks like I can leave the other settings to default.

New-Cache projectname-session-state -Secondaries 1
like image 126
Mike Schall Avatar answered Sep 30 '22 11:09

Mike Schall