Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit e407448

Browse files
committed
Add 1-pass of Rider quick fixes across *Async.cs classes
1 parent b9729dd commit e407448

11 files changed

+53
-54
lines changed

src/ServiceStack.Redis/Generic/RedisClientSet.Generic.Async.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async IAsyncEnumerator<T> IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationTok
5757
List<T> pageResults;
5858
do
5959
{
60-
pageResults = await AsyncClient.GetSortedEntryValuesAsync(this, skip, skip + PageLimit - 1).ConfigureAwait(false);
60+
pageResults = await AsyncClient.GetSortedEntryValuesAsync(this, skip, skip + PageLimit - 1, token).ConfigureAwait(false);
6161
foreach (var result in pageResults)
6262
{
6363
yield return result;

src/ServiceStack.Redis/Generic/RedisClientSortedSet.Generic.Async.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ internal partial class RedisClientSortedSet<T>
2525
IRedisSortedSetAsync<T> AsAsync() => this;
2626

2727
ValueTask IRedisSortedSetAsync<T>.AddAsync(T item, double score, CancellationToken token)
28-
=> AsyncClient.AddItemToSortedSetAsync(this, item, score);
28+
=> AsyncClient.AddItemToSortedSetAsync(this, item, score, token);
2929

3030
ValueTask<int> IRedisSortedSetAsync<T>.CountAsync(CancellationToken token)
3131
=> AsyncClient.GetSortedSetCountAsync(this, token).AsInt32();
3232

3333
ValueTask<List<T>> IRedisSortedSetAsync<T>.GetAllAsync(CancellationToken token)
34-
=> AsyncClient.GetAllItemsFromSortedSetAsync(this);
34+
=> AsyncClient.GetAllItemsFromSortedSetAsync(this, token);
3535

3636
ValueTask<List<T>> IRedisSortedSetAsync<T>.GetAllDescendingAsync(CancellationToken token)
37-
=> AsyncClient.GetAllItemsFromSortedSetDescAsync(this);
37+
=> AsyncClient.GetAllItemsFromSortedSetDescAsync(this, token);
3838

3939
async IAsyncEnumerator<T> IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken token)
4040
{

src/ServiceStack.Redis/Generic/RedisTypedClient.Async.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,20 @@ static void AssertNotNull(object obj, string name = "key")
200200
async ValueTask IRedisTypedClientAsync<T>.SetValueAsync(string key, T entity, TimeSpan expireIn, CancellationToken token)
201201
{
202202
AssertNotNull(key);
203-
await AsyncClient.SetAsync(key, SerializeValue(entity)).ConfigureAwait(false);
203+
await AsyncClient.SetAsync(key, SerializeValue(entity), token).ConfigureAwait(false);
204204
await client.RegisterTypeIdAsync(entity, token).ConfigureAwait(false);
205205
}
206206

207207
async ValueTask<bool> IRedisTypedClientAsync<T>.SetValueIfNotExistsAsync(string key, T entity, CancellationToken token)
208208
{
209-
var success = await AsyncNative.SetNXAsync(key, SerializeValue(entity)).IsSuccessAsync().ConfigureAwait(false);
209+
var success = await AsyncNative.SetNXAsync(key, SerializeValue(entity), token).IsSuccessAsync().ConfigureAwait(false);
210210
if (success) await client.RegisterTypeIdAsync(entity, token).ConfigureAwait(false);
211211
return success;
212212
}
213213

214214
async ValueTask<bool> IRedisTypedClientAsync<T>.SetValueIfExistsAsync(string key, T entity, CancellationToken token)
215215
{
216-
var success = await AsyncNative.SetAsync(key, SerializeValue(entity), exists: true).ConfigureAwait(false);
216+
var success = await AsyncNative.SetAsync(key, SerializeValue(entity), exists: true, token: token).ConfigureAwait(false);
217217
if (success) await client.RegisterTypeIdAsync(entity, token).ConfigureAwait(false);
218218
return success;
219219
}
@@ -365,7 +365,7 @@ ValueTask<long> IRedisTypedClientAsync<T>.GetSetCountAsync(IRedisSetAsync<T> set
365365
=> AsyncNative.SCardAsync(set.Id, token);
366366

367367
ValueTask<bool> IRedisTypedClientAsync<T>.SetContainsItemAsync(IRedisSetAsync<T> set, T item, CancellationToken token)
368-
=> AsyncNative.SIsMemberAsync(set.Id, SerializeValue(item)).IsSuccessAsync();
368+
=> AsyncNative.SIsMemberAsync(set.Id, SerializeValue(item), token).IsSuccessAsync();
369369

370370
async ValueTask<HashSet<T>> IRedisTypedClientAsync<T>.GetIntersectFromSetsAsync(IRedisSetAsync<T>[] sets, CancellationToken token)
371371
{

src/ServiceStack.Redis/RedisClient.Async.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ ValueTask<List<string>> IRedisClientAsync.GetValuesAsync(List<string> keys, Canc
252252
if (keys == null) throw new ArgumentNullException(nameof(keys));
253253
if (keys.Count == 0) return new List<string>().AsValueTaskResult();
254254

255-
return NativeAsync.MGetAsync(keys.ToArray(), token).Await(val => ParseGetValuesResult(val));
255+
return NativeAsync.MGetAsync(keys.ToArray(), token).Await(ParseGetValuesResult);
256256
}
257257

258258
ValueTask<List<T>> IRedisClientAsync.GetValuesAsync<T>(List<string> keys, CancellationToken token)
259259
{
260260
if (keys == null) throw new ArgumentNullException(nameof(keys));
261261
if (keys.Count == 0) return new List<T>().AsValueTaskResult();
262262

263-
return NativeAsync.MGetAsync(keys.ToArray(), token).Await(value => ParseGetValuesResult<T>(value));
263+
return NativeAsync.MGetAsync(keys.ToArray(), token).Await(ParseGetValuesResult<T>);
264264
}
265265

266266
ValueTask<Dictionary<string, string>> IRedisClientAsync.GetValuesMapAsync(List<string> keys, CancellationToken token)
@@ -407,19 +407,21 @@ Task<bool> ICacheClientAsync.SetAsync<T>(string key, T value, DateTime expiresAt
407407
AssertNotInTransaction();
408408
return ExecAsync(async r =>
409409
{
410-
await r.SetAsync(key, value).ConfigureAwait(false);
411-
await r.ExpireEntryAtAsync(key, ConvertToServerDate(expiresAt)).ConfigureAwait(false);
410+
await r.SetAsync(key, value, token).ConfigureAwait(false);
411+
await r.ExpireEntryAtAsync(key, ConvertToServerDate(expiresAt), token).ConfigureAwait(false);
412412
}).AwaitAsTrueTask();
413413
}
414414
Task<bool> ICacheClientAsync.SetAsync<T>(string key, T value, TimeSpan expiresIn, CancellationToken token)
415415
{
416416
if (AssertServerVersionNumber() >= 2600)
417417
{
418-
return ExecAsync(r => ((IRedisNativeClientAsync)r).SetAsync(key, ToBytes(value), 0, expiryMilliseconds: (long)expiresIn.TotalMilliseconds)).AwaitAsTrueTask();
418+
return ExecAsync(r => ((IRedisNativeClientAsync)r)
419+
.SetAsync(key, ToBytes(value), 0, expiryMilliseconds: (long)expiresIn.TotalMilliseconds, token)).AwaitAsTrueTask();
419420
}
420421
else
421422
{
422-
return ExecAsync(r => ((IRedisNativeClientAsync)r).SetExAsync(key, (int)expiresIn.TotalSeconds, ToBytes(value))).AwaitAsTrueTask();
423+
return ExecAsync(r => ((IRedisNativeClientAsync)r)
424+
.SetExAsync(key, (int)expiresIn.TotalSeconds, ToBytes(value), token)).AwaitAsTrueTask();
423425
}
424426
}
425427

@@ -640,7 +642,7 @@ async Task IEntityStoreAsync.DeleteByIdsAsync<T>(ICollection ids, CancellationTo
640642
{
641643
if (ids == null || ids.Count == 0) return;
642644

643-
var idsList = ids.Cast<object>();
645+
var idsList = ids.Cast<object>().ToList();
644646
var urnKeys = idsList.Map(UrnKey<T>);
645647
await AsAsync().RemoveEntryAsync(urnKeys.ToArray(), token).ConfigureAwait(false);
646648
await this.RemoveTypeIdsAsync<T>(idsList.Map(x => x.ToString()).ToArray(), token).ConfigureAwait(false);

src/ServiceStack.Redis/RedisClientList.Async.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ValueTask<int> IRedisListAsync.CountAsync(CancellationToken token)
4040
=> AsyncClient.GetListCountAsync(listId, token).AsInt32();
4141

4242
ValueTask<string> IRedisListAsync.DequeueAsync(CancellationToken token)
43-
=> AsyncClient.DequeueItemFromListAsync(listId);
43+
=> AsyncClient.DequeueItemFromListAsync(listId, token);
4444

4545
ValueTask IRedisListAsync.EnqueueAsync(string value, CancellationToken token)
4646
=> AsyncClient.EnqueueItemOnListAsync(listId, value, token);
@@ -138,7 +138,7 @@ async ValueTask<bool> IRedisListAsync.ContainsAsync(string value, CancellationTo
138138
}
139139

140140
ValueTask IRedisListAsync.ClearAsync(CancellationToken token)
141-
=> AsyncClient.RemoveAllFromListAsync(listId);
141+
=> AsyncClient.RemoveAllFromListAsync(listId, token);
142142

143143
async ValueTask<int> IRedisListAsync.IndexOfAsync(string value, CancellationToken token)
144144
{
@@ -153,9 +153,9 @@ async ValueTask<int> IRedisListAsync.IndexOfAsync(string value, CancellationToke
153153
}
154154

155155
ValueTask<string> IRedisListAsync.ElementAtAsync(int index, CancellationToken token)
156-
=> AsyncClient.GetItemFromListAsync(listId, index);
156+
=> AsyncClient.GetItemFromListAsync(listId, index, token);
157157

158158
ValueTask IRedisListAsync.SetValueAsync(int index, string value, CancellationToken token)
159-
=> AsyncClient.SetItemInListAsync(listId, index, value);
159+
=> AsyncClient.SetItemInListAsync(listId, index, value, token);
160160
}
161161
}

src/ServiceStack.Redis/RedisClientManagerCacheClient.Async.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ async Task<T> ICacheClientAsync.GetAsync<T>(string key, CancellationToken token)
3030
async Task<bool> ICacheClientAsync.SetAsync<T>(string key, T value, CancellationToken token)
3131
{
3232
await using var client = await GetClientAsync(token).ConfigureAwait(false);
33-
return await client.SetAsync<T>(key, value, token).ConfigureAwait(false);
33+
return await client.SetAsync(key, value, token).ConfigureAwait(false);
3434
}
3535

3636
async Task<bool> ICacheClientAsync.SetAsync<T>(string key, T value, DateTime expiresAt, CancellationToken token)
3737
{
3838
await using var client = await GetClientAsync(token).ConfigureAwait(false);
39-
return await client.SetAsync<T>(key, value, expiresAt, token).ConfigureAwait(false);
39+
return await client.SetAsync(key, value, expiresAt, token).ConfigureAwait(false);
4040
}
4141

4242
async Task<bool> ICacheClientAsync.SetAsync<T>(string key, T value, TimeSpan expiresIn, CancellationToken token)
4343
{
4444
await using var client = await GetClientAsync(token).ConfigureAwait(false);
45-
return await client.SetAsync<T>(key, value, expiresIn, token).ConfigureAwait(false);
45+
return await client.SetAsync(key, value, expiresIn, token).ConfigureAwait(false);
4646
}
4747

4848
async Task ICacheClientAsync.FlushAllAsync(CancellationToken token)
@@ -60,7 +60,7 @@ async Task<IDictionary<string, T>> ICacheClientAsync.GetAllAsync<T>(IEnumerable<
6060
async Task ICacheClientAsync.SetAllAsync<T>(IDictionary<string, T> values, CancellationToken token)
6161
{
6262
await using var client = await GetClientAsync(token).ConfigureAwait(false);
63-
await client.SetAllAsync<T>(values, token).ConfigureAwait(false);
63+
await client.SetAllAsync(values, token).ConfigureAwait(false);
6464
}
6565

6666
async Task<bool> ICacheClientAsync.RemoveAsync(string key, CancellationToken token)
@@ -129,37 +129,37 @@ async Task<long> ICacheClientAsync.DecrementAsync(string key, uint amount, Cance
129129
async Task<bool> ICacheClientAsync.AddAsync<T>(string key, T value, CancellationToken token)
130130
{
131131
await using var client = await GetClientAsync(token).ConfigureAwait(false);
132-
return await client.AddAsync<T>(key, value, token).ConfigureAwait(false);
132+
return await client.AddAsync(key, value, token).ConfigureAwait(false);
133133
}
134134

135135
async Task<bool> ICacheClientAsync.ReplaceAsync<T>(string key, T value, CancellationToken token)
136136
{
137137
await using var client = await GetClientAsync(token).ConfigureAwait(false);
138-
return await client.ReplaceAsync<T>(key, value, token).ConfigureAwait(false);
138+
return await client.ReplaceAsync(key, value, token).ConfigureAwait(false);
139139
}
140140

141141
async Task<bool> ICacheClientAsync.AddAsync<T>(string key, T value, DateTime expiresAt, CancellationToken token)
142142
{
143143
await using var client = await GetClientAsync(token).ConfigureAwait(false);
144-
return await client.AddAsync<T>(key, value, expiresAt, token).ConfigureAwait(false);
144+
return await client.AddAsync(key, value, expiresAt, token).ConfigureAwait(false);
145145
}
146146

147147
async Task<bool> ICacheClientAsync.ReplaceAsync<T>(string key, T value, DateTime expiresAt, CancellationToken token)
148148
{
149149
await using var client = await GetClientAsync(token).ConfigureAwait(false);
150-
return await client.ReplaceAsync<T>(key, value, expiresAt, token).ConfigureAwait(false);
150+
return await client.ReplaceAsync(key, value, expiresAt, token).ConfigureAwait(false);
151151
}
152152

153153
async Task<bool> ICacheClientAsync.AddAsync<T>(string key, T value, TimeSpan expiresIn, CancellationToken token)
154154
{
155155
await using var client = await GetClientAsync(token).ConfigureAwait(false);
156-
return await client.AddAsync<T>(key, value, expiresIn, token).ConfigureAwait(false);
156+
return await client.AddAsync(key, value, expiresIn, token).ConfigureAwait(false);
157157
}
158158

159159
async Task<bool> ICacheClientAsync.ReplaceAsync<T>(string key, T value, TimeSpan expiresIn, CancellationToken token)
160160
{
161161
await using var client = await GetClientAsync(token).ConfigureAwait(false);
162-
return await client.ReplaceAsync<T>(key, value, expiresIn, token).ConfigureAwait(false);
162+
return await client.ReplaceAsync(key, value, expiresIn, token).ConfigureAwait(false);
163163
}
164164
}
165165
}

src/ServiceStack.Redis/RedisClientSet.Async.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ValueTask<HashSet<string>> IRedisSetAsync.GetAllAsync(CancellationToken token)
4646
=> AsyncClient.GetAllItemsFromSetAsync(setId, token);
4747

4848
IAsyncEnumerator<string> IAsyncEnumerable<string>.GetAsyncEnumerator(CancellationToken token)
49-
=> AsyncClient.ScanAllSetItemsAsync(setId).GetAsyncEnumerator(token); // uses SSCAN
49+
=> AsyncClient.ScanAllSetItemsAsync(setId, token: token).GetAsyncEnumerator(token); // uses SSCAN
5050

5151
ValueTask<string> IRedisSetAsync.GetRandomEntryAsync(CancellationToken token)
5252
=> AsyncClient.GetRandomItemFromSetAsync(setId, token);

src/ServiceStack.Redis/RedisNativeClient.Async.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ValueTask<bool> IRedisNativeClientAsync.SetAsync(string key, byte[] value, bool
4848
value ??= TypeConstants.EmptyByteArray;
4949

5050
if (value.Length > OneGb)
51-
throw new ArgumentException("value exceeds 1G", "value");
51+
throw new ArgumentException("value exceeds 1G", nameof(value));
5252

5353
var entryExists = exists ? Commands.Xx : Commands.Nx;
5454
byte[][] args;
@@ -73,7 +73,7 @@ ValueTask IRedisNativeClientAsync.SetAsync(string key, byte[] value, long expiry
7373
value ??= TypeConstants.EmptyByteArray;
7474

7575
if (value.Length > OneGb)
76-
throw new ArgumentException("value exceeds 1G", "value");
76+
throw new ArgumentException("value exceeds 1G", nameof(value));
7777

7878
byte[][] args;
7979
if (expiryMilliseconds != 0)
@@ -162,16 +162,16 @@ internal ValueTask<long> HSetAsync(byte[] hashId, byte[] key, byte[] value, Canc
162162
ValueTask<string> IRedisNativeClientAsync.RandomKeyAsync(CancellationToken token)
163163
=> SendExpectDataAsync(token, Commands.RandomKey).FromUtf8BytesAsync();
164164

165-
ValueTask IRedisNativeClientAsync.RenameAsync(string oldKeyname, string newKeyname, CancellationToken token)
165+
ValueTask IRedisNativeClientAsync.RenameAsync(string oldKeyName, string newKeyName, CancellationToken token)
166166
{
167-
CheckRenameKeys(oldKeyname, newKeyname);
168-
return SendExpectSuccessAsync(token, Commands.Rename, oldKeyname.ToUtf8Bytes(), newKeyname.ToUtf8Bytes());
167+
CheckRenameKeys(oldKeyName, newKeyName);
168+
return SendExpectSuccessAsync(token, Commands.Rename, oldKeyName.ToUtf8Bytes(), newKeyName.ToUtf8Bytes());
169169
}
170170

171-
ValueTask<bool> IRedisNativeClientAsync.RenameNxAsync(string oldKeyname, string newKeyname, CancellationToken token)
171+
ValueTask<bool> IRedisNativeClientAsync.RenameNxAsync(string oldKeyName, string newKeyName, CancellationToken token)
172172
{
173-
CheckRenameKeys(oldKeyname, newKeyname);
174-
return SendExpectLongAsync(token, Commands.RenameNx, oldKeyname.ToUtf8Bytes(), newKeyname.ToUtf8Bytes()).IsSuccessAsync();
173+
CheckRenameKeys(oldKeyName, newKeyName);
174+
return SendExpectLongAsync(token, Commands.RenameNx, oldKeyName.ToUtf8Bytes(), newKeyName.ToUtf8Bytes()).IsSuccessAsync();
175175
}
176176

177177
ValueTask IRedisNativeClientAsync.MSetAsync(byte[][] keys, byte[][] values, CancellationToken token)
@@ -308,7 +308,7 @@ ValueTask IRedisNativeClientAsync.SetExAsync(string key, int expireInSeconds, by
308308
value ??= TypeConstants.EmptyByteArray;
309309

310310
if (value.Length > OneGb)
311-
throw new ArgumentException("value exceeds 1G", "value");
311+
throw new ArgumentException("value exceeds 1G", nameof(value));
312312

313313
return SendExpectSuccessAsync(token, Commands.SetEx, key.ToUtf8Bytes(), expireInSeconds.ToUtf8Bytes(), value);
314314
}
@@ -455,7 +455,7 @@ protected ValueTask<RedisData> RawCommandAsync(CancellationToken token, params o
455455
}
456456

457457
ValueTask<Dictionary<string, string>> IRedisNativeClientAsync.InfoAsync(CancellationToken token)
458-
=> SendExpectStringAsync(token, Commands.Info).Await(info => ParseInfoResult(info));
458+
=> SendExpectStringAsync(token, Commands.Info).Await(ParseInfoResult);
459459

460460
ValueTask<byte[][]> IRedisNativeClientAsync.ZRangeByLexAsync(string setId, string min, string max, int? skip, int? take, CancellationToken token)
461461
=> SendExpectMultiDataAsync(token, GetZRangeByLexArgs(setId, min, max, skip, take));

src/ServiceStack.Redis/RedisNativeClient_Utils.Async.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private async ValueTask<T> SendReceiveAsync<T>(byte[][] cmdWithBinaryArgs,
250250
}
251251

252252
Interlocked.Increment(ref RedisState.TotalRetryCount);
253-
await Task.Delay(GetBackOffMultiplier(++i)).ConfigureAwait(false);
253+
await Task.Delay(GetBackOffMultiplier(++i), token).ConfigureAwait(false);
254254
}
255255
}
256256
}

src/ServiceStack.Redis/ServiceStack.Redis.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,5 @@
4242
<!-- note: not needed from netstandard2.1 or netcoreapp3.0 onwards -->
4343
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.0" />
4444
</ItemGroup>
45-
<ItemGroup>
46-
<Folder Include="AsyncInterfaces\ServiceStack.Interfaces\Caching\" />
47-
</ItemGroup>
4845

4946
</Project>

0 commit comments

Comments
 (0)