diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-11-21 12:29:18 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-21 12:29:18 -0500 |
| commit | f80cc1bbd4145a682234d4d1d286c70f562f36bd (patch) | |
| tree | 2ecc0e11aa1f394295f6269069da5ed6b9ed0667 /Emby.Server.Implementations/Security | |
| parent | b2ea3272e70a0f520133ee6a74d958e044d4392e (diff) | |
| parent | 1acebd992229ee9bd6e7677f68174672fae53622 (diff) | |
Merge pull request #2299 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Security')
| -rw-r--r-- | Emby.Server.Implementations/Security/AuthenticationRepository.cs | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index a9141f153..dad05718c 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -30,9 +30,16 @@ namespace Emby.Server.Implementations.Security { using (var connection = CreateConnection()) { + connection.ExecuteAll(string.Join(";", new[] + { + "PRAGMA page_size=4096", + "pragma default_temp_store = memory", + "pragma temp_store = memory" + })); + string[] queries = { - "create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, AppVersion TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)", + "create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, AppVersion TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)", "create index if not exists idx_AccessTokens on AccessTokens(Id)" }; @@ -63,9 +70,9 @@ namespace Emby.Server.Implementations.Security cancellationToken.ThrowIfCancellationRequested(); - using (WriteLock.Write()) + using (var connection = CreateConnection()) { - using (var connection = CreateConnection()) + using (WriteLock.Write()) { connection.RunInTransaction(db => { @@ -200,28 +207,31 @@ namespace Emby.Server.Implementations.Security var list = new List<AuthenticationInfo>(); - using (var statement = connection.PrepareStatement(commandText)) + using (WriteLock.Read()) { - BindAuthenticationQueryParams(query, statement); - - foreach (var row in statement.ExecuteQuery()) - { - list.Add(Get(row)); - } - - using (var totalCountStatement = connection.PrepareStatement("select count (Id) from AccessTokens" + whereTextWithoutPaging)) + using (var statement = connection.PrepareStatement(commandText)) { - BindAuthenticationQueryParams(query, totalCountStatement); + BindAuthenticationQueryParams(query, statement); - var count = totalCountStatement.ExecuteQuery() - .SelectScalarInt() - .First(); + foreach (var row in statement.ExecuteQuery()) + { + list.Add(Get(row)); + } - return new QueryResult<AuthenticationInfo>() + using (var totalCountStatement = connection.PrepareStatement("select count (Id) from AccessTokens" + whereTextWithoutPaging)) { - Items = list.ToArray(), - TotalRecordCount = count - }; + BindAuthenticationQueryParams(query, totalCountStatement); + + var count = totalCountStatement.ExecuteQuery() + .SelectScalarInt() + .First(); + + return new QueryResult<AuthenticationInfo>() + { + Items = list.ToArray(), + TotalRecordCount = count + }; + } } } } @@ -234,9 +244,9 @@ namespace Emby.Server.Implementations.Security throw new ArgumentNullException("id"); } - using (WriteLock.Read()) + using (var connection = CreateConnection(true)) { - using (var connection = CreateConnection(true)) + using (WriteLock.Read()) { var commandText = BaseSelectText + " where Id=@Id"; |
