Skip to content

Commit 4ce032c

Browse files
Be consistent with other providers using camel case in Sql provider. (#83)
1 parent 6654e67 commit 4ce032c

File tree

7 files changed

+35
-34
lines changed

7 files changed

+35
-34
lines changed

Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ The specific settings available for the new session state module and providers a
4242
>
4343
> The most logical partition field for session state is the session ID. The CosmosDB provider has been updated to alway use `"/id"` as the partition key path with the full session ID as the partition value. Pre-existing containers that use a different partition key path (which is any that opted into using partitions previously) will need to migrate to a container that uses `"/id"` as the partition key path. The data is all still good - although, the old partition key path can be dropped when migrating. There is unfortunately no way to simply update the partition key path on an existing container right now. [This blog post](https://devblogs.microsoft.com/cosmosdb/how-to-change-your-partition-key/) is a guide for migrating to a new container with the correct partition key path.
4444
* :warning: ***Potential Breaking Change*** - Added `managedHandler` precondition to module configuration. The old in-box session module used this and it is a reasonable default for avoiding traffic jams. It can be removed from web.config if session is required for non-managed handlers as well.
45-
* :warning: ***Action Required*** Sql provider `RepositoryType` - This new setting provides a little more flexibility for repository configuration beyond a single boolean for in-memory optimized tables. Possible values are `SqlServer|InMemory|InMemoryDurable|FrameworkCompat`. Read about what each configuration is at our [SqlSessionStateProviderAsync](docs/SqlSessionStateProviderAsync.md) doc page.
45+
* :warning: ***Action Required*** Sql provider `repositoryType` - This new setting provides a little more flexibility for repository configuration beyond a single boolean for in-memory optimized tables. Possible values are `SqlServer|InMemory|InMemoryDurable|FrameworkCompat`. Read about what each configuration is at our [SqlSessionStateProviderAsync](docs/SqlSessionStateProviderAsync.md) doc page.
4646

47-
> The mechanics of nuget package upgrade results in removing old elements and re-adding the boiler-plate elements in configuration. To restore In-Memory functionality, set 'RepositoryType' to `InMemory`. To continue using an existing non-memory-optimized table without stored procedures, set 'RespositoryType' to `FrameworkCompat`. The recommendation is to update to the new table schema and use stored procedures with `SqlServer`, but this will ignore existing sessions in previously existing tables.
47+
> The mechanics of nuget package upgrade results in removing old elements and re-adding the boiler-plate elements in configuration. To restore In-Memory functionality, set 'repositoryType' to `InMemory`. To continue using an existing non-memory-optimized table without stored procedures, set 'RespositoryType' to `FrameworkCompat`. The recommendation is to update to the new table schema and use stored procedures with `SqlServer`, but this will ignore existing sessions in previously existing tables.
4848
* Moved to use `Microsoft.Data.SqlClient` instead of old `System.Data.SqlClient`. This allows for more modern features such as Token Authorization.
4949
* Added `skipKeepAliveWhenUnused` to all providers. This setting will skip the call to update expiration time on requests that did not read or write session state. This is setting is used at the module level, and is thus exists on all providers. The default is "false" to maintain compatibility. But certain applications (like MVC) where there can be an abundance of requests processed that never even look at session state could benefit from setting this to "true" to reduce the use of and contention within the session state store. Setting this to "true" does mean that a session needs to be used (not necessarily updated, but at least requested/queried) to stay alive.
50-
* The Sql provider's `UseInMemoryTable` is deprecated. It will continue to be respected in the absence of `RepositoryType`, but is overridden by that setting if given.
51-
* Sql provider `SessionTableName` - A new setting that allows users to target a specific table in their database rather than being forced to use the default table names.
50+
* The Sql provider's `useInMemoryTable` is deprecated. It will continue to be respected in the absence of `repositoryType`, but is overridden by that setting if given.
51+
* Sql provider `sessionTableName` - A new setting that allows users to target a specific table in their database rather than being forced to use the default table names.
5252
* CosmosDB `collectionId` is now `containerId` in keeping with the updated terminology from the CosmosDB offering. Please use the updated parameter name when configuring your provider. (The old name will continue to work just the same.)
5353
* Added CosmosDB `consistencyLevel` to allow using a different [Consistency Level](https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels) with the CosmosClient.
5454
* CosmosDB `connectionProtocol` is obsolete. It will not cause errors to have it in configuration, but it is ignored. The current [CosmosDB SDK chooses the protocol based on connection mode](https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/sdk-connection-modes).

docs/SqlSessionStateProviderAsync.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Then, register your new provider like so:
77
```xml
88
<sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="SqlSessionStateProviderAsync">
99
<providers>
10-
<add name="SqlSessionStateProviderAsync" connectionStringName="DefaultConnection" SessionTableName="[string]"
11-
RepositoryType="[SqlServer|InMemory|InMemoryDurable|FrameworkCompat]"
12-
MaxRetryNumber="[int]" RetryInterval="[int]" skipKeepAliveWhenUnused="false"
10+
<add name="SqlSessionStateProviderAsync" connectionStringName="DefaultConnection" sessionTableName="[string]"
11+
repositoryType="[SqlServer|InMemory|InMemoryDurable|FrameworkCompat]"
12+
maxRetryNumber="[int]" retryInterval="[int]" skipKeepAliveWhenUnused="false"
1313
type="Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync, Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
1414
</providers>
1515
</sessionState>
@@ -21,12 +21,12 @@ The old in-box SQL provider allowed for applications to choose between three dat
2121
* With the temporary option, session state would be stored in a hard-coded well-known table name in the "tempdb" database on the SQL Server specified in the connection string. The "tempdb" database gets cleared upon SQL server reboot, so the data is not kept. The table schema and stored procedures are also cleared in this scenario, but there is a startup procedure that gets registered to re-create session state tables and stored procedures.
2222
* With the custom option, session state would be stored in a table name given by the developer/administrator. The stored procedures created in the database work against that custom table name.
2323

24-
With this new provider, `aspnet_regsql.exe` is no longer required. (Although, compatibility with stores created by 'aspnet_regsql.exe' can be found when using 'RepositoryType=FrameworkCompat'.) When using a `SqlServer` 'RepositoryType' the provider will automatically create tables and stored procedures if they don't already exist. By default, that table name is "hard-coded and well-known" - though it has changed from previous versions to avoid inadvertent compatibility problems. You can change that table name by using the 'SessionTableName' attribute on the provider. Whether or not data is 'temporary' or 'permanent' in this type of repository depends entirely on the connection string used. If the connection string indicates using "tempdb", then the data will be temporary. If it indicates a non-temporary initial database, then the data will survive SQL reboots.
24+
With this new provider, `aspnet_regsql.exe` is no longer required. (Although, compatibility with stores created by 'aspnet_regsql.exe' can be found when using 'repositoryType=FrameworkCompat'.) When using a `SqlServer` 'repositoryType' the provider will automatically create tables and stored procedures if they don't already exist. By default, that table name is "hard-coded and well-known" - though it has changed from previous versions to avoid inadvertent compatibility problems. You can change that table name by using the 'sessionTableName' attribute on the provider. Whether or not data is 'temporary' or 'permanent' in this type of repository depends entirely on the connection string used. If the connection string indicates using "tempdb", then the data will be temporary. If it indicates a non-temporary initial database, then the data will survive SQL reboots.
2525

26-
When using a Memory-Optimized 'RepositoryType' however, data durability is determined by the optimized table schema. Thus, the provider needs to know what settings to apply to any table it creates. If you want permanent data that survives SQL Server reboots, you must use `InMemoryDurable`.
26+
When using a Memory-Optimized 'repositoryType' however, data durability is determined by the optimized table schema. Thus, the provider needs to know what settings to apply to any table it creates. If you want permanent data that survives SQL Server reboots, you must use `InMemoryDurable`.
2727

2828
## Settings for Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync
29-
1. *RepositoryType* - One of four values. The default is 'FrameworkCompat' for compatibility reasons - unless the deprecated 'UseInMemoryTable' is also set to true, then the default repository type becomes 'InMemory'.
29+
1. *repositoryType* - One of four values. The default is 'FrameworkCompat' for compatibility reasons - unless the deprecated 'useInMemoryTable' is also set to true, then the default repository type becomes 'InMemory'.
3030
* `SqlServer` - Use this option to use a regular SQL server configuration for a fresh deployment. This configuration will create a session table and associated stored procedures if they don't already exist. (*Note* - the session table expected/created in by this repository type uses a different data type for storing state, and is thus incompatible with the 1.1 release of this provider.)
3131
* `InMemory` - Use this option to leverage "[In-Memory Optimized Tables](https://learn.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/introduction-to-memory-optimized-tables?view=sql-server-ver16)" with "[Natively Compiled Stored Procedures](https://learn.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/a-guide-to-query-processing-for-memory-optimized-tables?view=sql-server-ver16)". New in version 2.0, we create natively compiled stored procedures to go along with the memory-optimized table for an additional performance boost. (V1.1 did not use stored procedures at all.) Tables are durable, but the data is not (`SCHEMA_ONLY`) and will be lost on SQL Server restarts.
3232
* `InMemoryDurable` - The same as above, except with a `SCHEMA_AND_DATA` durable table so session data survives a SQL Server restart.
@@ -36,12 +36,12 @@ The old in-box SQL provider allowed for applications to choose between three dat
3636

3737
The provider automatically decides between Framework and V1.1 compat modes in this configuration.
3838

39-
2. *SessionTableName* - The provider now allows the flexibility to use a particular table name for storing session instead of always using the hard-coded default.
39+
2. *sessionTableName* - The provider now allows the flexibility to use a particular table name for storing session instead of always using the hard-coded default.
4040

41-
3. *MaxRetryNumber* - The maximum number of retrying executing sql query to read/write sessionstate data from/to Sql server. The default value is 10.
41+
3. *maxRetryNumber* - The maximum number of retrying executing sql query to read/write sessionstate data from/to Sql server. The default value is 10.
4242

43-
4. *RetryInterval* - The interval between the retry of executing sql query. The default value is 0.001 sec for in-memorytable mode. Otherwise the default value is 1 sec.
43+
4. *retryInterval* - The interval between the retry of executing sql query. The default value is 0.001 sec for in-memorytable mode. Otherwise the default value is 1 sec.
4444

4545
5. *skipKeepAliveWhenUnused* - This setting will skip the call to update expiration time on requests that did not read or write session state. The default is "false" to maintain compatibility with previous behavior. But certain applications (like MVC) where there can be an abundance of requests processed that never even look at session state could benefit from setting this to "true" to reduce the use of and contention within the session state store. Setting this to "true" does mean that a session needs to be used (not necessarily updated, but at least requested/queried) to stay alive.
4646

47-
6. **[Deprecated]** *UseInMemoryTable* - In the absence of a value for `RepositoryType`, this setting will be used to determine whether to use Sql server 2016 In-Memory OLTP for sessionstate. However, if `RepositoryType` is specified, that setting takes priority. You can find more details about using In-memory table for sessionstate [on this blog](https://blogs.msdn.microsoft.com/sqlcat/2016/10/26/how-bwin-is-using-sql-server-2016-in-memory-oltp-to-achieve-unprecedented-performance-and-scale/).
47+
6. **[Deprecated]** *useInMemoryTable* - In the absence of a value for `repositoryType`, this setting will be used to determine whether to use Sql server 2016 In-Memory OLTP for sessionstate. However, if `repositoryType` is specified, that setting takes priority. You can find more details about using In-memory table for sessionstate [on this blog](https://blogs.msdn.microsoft.com/sqlcat/2016/10/26/how-bwin-is-using-sql-server-2016-in-memory-oltp-to-achieve-unprecedented-performance-and-scale/).

src/SqlSessionStateProviderAsync/Resources/SR.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SqlSessionStateProviderAsync/Resources/SR.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<value>Attribute not recognized '{0}'</value>
137137
</data>
138138
<data name="SessionTable_current" xml:space="preserve">
139-
<value>The table '{0}' is compatible with current repositories. Use the '{1}' repositoryType instead with the 'SessionTableName' attribute if applicable.</value>
139+
<value>The table '{0}' is compatible with current repositories. Use the '{1}' repositoryType instead with the 'sessionTableName' attribute if applicable.</value>
140140
</data>
141141
<data name="SessionTable_not_found" xml:space="preserve">
142142
<value>The table '{0}' was not found in the database. The repositoryType '{1}' cannot create session state tables.</value>

src/SqlSessionStateProviderAsync/SqlSessionStateProviderAsync.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ namespace Microsoft.AspNet.SessionState
2323
/// </summary>
2424
public class SqlSessionStateProviderAsync : SessionStateStoreProviderAsyncBase
2525
{
26-
private const string REPOSITORY_TYPE_CONFIGURATION_NAME = "RepositoryType";
27-
private const string INMEMORY_TABLE_CONFIGURATION_NAME = "UseInMemoryTable";
28-
private const string MAX_RETRY_NUMBER_CONFIGURATION_NAME = "MaxRetryNumber";
29-
private const string RETRY_INTERVAL_CONFIGURATION_NAME = "RetryInterval";
26+
private const string REPOSITORY_TYPE_CONFIGURATION_NAME = "repositoryType";
27+
private const string INMEMORY_TABLE_CONFIGURATION_NAME = "useInMemoryTable";
28+
private const string MAX_RETRY_NUMBER_CONFIGURATION_NAME = "maxRetryNumber";
29+
private const string RETRY_INTERVAL_CONFIGURATION_NAME = "retryInterval";
3030
private const string CONNECTIONSTRING_NAME_CONFIGURATION_NAME = "connectionStringName";
31-
private const string SESSION_TABLE_CONFIGURATION_NAME = "SessionTableName";
31+
private const string SESSION_TABLE_CONFIGURATION_NAME = "sessionTableName";
3232
private const string SESSIONSTATE_SECTION_PATH = "system.web/sessionState";
3333
private const double SessionExpiresFrequencyCheckIntervalTicks = 30 * TimeSpan.TicksPerSecond;
3434
private static long s_lastSessionPurgeTicks;
@@ -76,10 +76,10 @@ internal void Initialize(string name, NameValueCollection config, SessionStateSe
7676
{
7777
if (!s_oneTimeInited)
7878
{
79-
// CompressionEnabled
79+
// compressionEnabled
8080
s_compressionEnabled = ssc.CompressionEnabled;
8181

82-
// RepositoryType
82+
// repositoryType
8383
var rType = config[REPOSITORY_TYPE_CONFIGURATION_NAME];
8484
if (rType != null)
8585
{
@@ -88,9 +88,9 @@ internal void Initialize(string name, NameValueCollection config, SessionStateSe
8888
}
8989
else
9090
{
91-
// 'RepositoryType' was not specified. Ideally we would default to 'SqlServer', but changing from
91+
// 'repositoryType' was not specified. Ideally we would default to 'SqlServer', but changing from
9292
// 'image' to 'varbinary' for the SessionItemLong column is a compat issue. So not specifying
93-
// a repository type gets you the compat repository, unless 'UseInMemoryTable' indicates to use
93+
// a repository type gets you the compat repository, unless 'useInMemoryTable' indicates to use
9494
// the in-memory optimized provider instead which is still compatible with the old one.
9595
var val = config[INMEMORY_TABLE_CONFIGURATION_NAME];
9696
if (val != null && bool.TryParse(val, out bool useInMemoryTable) && useInMemoryTable)

src/packages/SqlSessionStateProviderAsync.nupkg/content/Net462/web.config.install.xdt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
<!--
1313
Please change the connection string named "DefaultConnection" to connect to an instance
1414
of SQL Server which you will use as the data store.
15-
UseInMemoryTable = [True|False] whether to use InMemory table, default is faluse
16-
MaxRetryNumber = [integer] the number of retry when DB operation fails
17-
RetryInterval = [integer] intervel(milliseconds) between retries
15+
repositoryType = [SqlServer|InMemory|InMemoryDurable|FrameworkCompat] what type of SQL repository to use
16+
- for compat reasons, default is 'FrameworkCompat'
17+
maxRetryNumber = [integer] the number of retry when DB operation fails
18+
retryInterval = [integer] intervel(milliseconds) between retries
1819
-->
19-
<add name="SqlSessionStateProviderAsync" connectionStringName="DefaultConnection" RepositoryType="SqlServer"
20+
<add name="SqlSessionStateProviderAsync" connectionStringName="DefaultConnection" repositoryType="SqlServer"
2021
type="Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync, Microsoft.AspNet.SessionState.SqlSessionStateProviderAsync, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
2122
xdt:Transform="InsertIfMissing" />
2223
</providers>

0 commit comments

Comments
 (0)