@@ -122,10 +122,7 @@ public RedisText Custom(params object[] cmdWithArgs)
122
122
123
123
public void SetValue ( string key , string value )
124
124
{
125
- var bytesValue = value != null
126
- ? value . ToUtf8Bytes ( )
127
- : null ;
128
-
125
+ var bytesValue = value ? . ToUtf8Bytes ( ) ;
129
126
base . Set ( key , bytesValue ) ;
130
127
}
131
128
@@ -145,9 +142,7 @@ public bool SetValue(byte[] key, byte[] value, TimeSpan expireIn)
145
142
146
143
public void SetValue ( string key , string value , TimeSpan expireIn )
147
144
{
148
- var bytesValue = value != null
149
- ? value . ToUtf8Bytes ( )
150
- : null ;
145
+ var bytesValue = value ? . ToUtf8Bytes ( ) ;
151
146
152
147
if ( AssertServerVersionNumber ( ) >= 2610 )
153
148
{
@@ -164,21 +159,19 @@ public void SetValue(string key, string value, TimeSpan expireIn)
164
159
165
160
public bool SetValueIfExists ( string key , string value )
166
161
{
167
- var bytesValue = value != null ? value . ToUtf8Bytes ( ) : null ;
168
-
162
+ var bytesValue = value ? . ToUtf8Bytes ( ) ;
169
163
return base . Set ( key , bytesValue , exists : true ) ;
170
164
}
171
165
172
166
public bool SetValueIfNotExists ( string key , string value )
173
167
{
174
- var bytesValue = value != null ? value . ToUtf8Bytes ( ) : null ;
175
-
168
+ var bytesValue = value ? . ToUtf8Bytes ( ) ;
176
169
return base . Set ( key , bytesValue , exists : false ) ;
177
170
}
178
171
179
172
public bool SetValueIfExists ( string key , string value , TimeSpan expireIn )
180
173
{
181
- var bytesValue = value != null ? value . ToUtf8Bytes ( ) : null ;
174
+ var bytesValue = value ? . ToUtf8Bytes ( ) ;
182
175
183
176
if ( expireIn . Milliseconds > 0 )
184
177
return base . Set ( key , bytesValue , exists : true , expiryMs : ( long ) expireIn . TotalMilliseconds ) ;
@@ -188,7 +181,7 @@ public bool SetValueIfExists(string key, string value, TimeSpan expireIn)
188
181
189
182
public bool SetValueIfNotExists ( string key , string value , TimeSpan expireIn )
190
183
{
191
- var bytesValue = value != null ? value . ToUtf8Bytes ( ) : null ;
184
+ var bytesValue = value ? . ToUtf8Bytes ( ) ;
192
185
193
186
if ( expireIn . Milliseconds > 0 )
194
187
return base . Set ( key , bytesValue , exists : false , expiryMs : ( long ) expireIn . TotalMilliseconds ) ;
@@ -245,9 +238,7 @@ public void SetAll(Dictionary<string, string> map)
245
238
public string GetValue ( string key )
246
239
{
247
240
var bytes = Get ( key ) ;
248
- return bytes == null
249
- ? null
250
- : bytes . FromUtf8Bytes ( ) ;
241
+ return bytes ? . FromUtf8Bytes ( ) ;
251
242
}
252
243
253
244
public string GetAndSetValue ( string key , string value )
@@ -426,7 +417,7 @@ public List<string> SearchKeys(string pattern)
426
417
427
418
public List < string > GetValues ( List < string > keys )
428
419
{
429
- if ( keys == null ) throw new ArgumentNullException ( " keys" ) ;
420
+ if ( keys == null ) throw new ArgumentNullException ( nameof ( keys ) ) ;
430
421
if ( keys . Count == 0 ) return new List < string > ( ) ;
431
422
432
423
var resultBytesArray = MGet ( keys . ToArray ( ) ) ;
@@ -445,7 +436,7 @@ public List<string> GetValues(List<string> keys)
445
436
446
437
public List < T > GetValues < T > ( List < string > keys )
447
438
{
448
- if ( keys == null ) throw new ArgumentNullException ( " keys" ) ;
439
+ if ( keys == null ) throw new ArgumentNullException ( nameof ( keys ) ) ;
449
440
if ( keys . Count == 0 ) return new List < T > ( ) ;
450
441
451
442
var resultBytesArray = MGet ( keys . ToArray ( ) ) ;
@@ -465,7 +456,7 @@ public List<T> GetValues<T>(List<string> keys)
465
456
466
457
public Dictionary < string , string > GetValuesMap ( List < string > keys )
467
458
{
468
- if ( keys == null ) throw new ArgumentNullException ( " keys" ) ;
459
+ if ( keys == null ) throw new ArgumentNullException ( nameof ( keys ) ) ;
469
460
if ( keys . Count == 0 ) return new Dictionary < string , string > ( ) ;
470
461
471
462
var keysArray = keys . ToArray ( ) ;
@@ -493,7 +484,7 @@ public Dictionary<string, string> GetValuesMap(List<string> keys)
493
484
494
485
public Dictionary < string , T > GetValuesMap < T > ( List < string > keys )
495
486
{
496
- if ( keys == null ) throw new ArgumentNullException ( " keys" ) ;
487
+ if ( keys == null ) throw new ArgumentNullException ( nameof ( keys ) ) ;
497
488
if ( keys . Count == 0 ) return new Dictionary < string , T > ( ) ;
498
489
499
490
var keysArray = keys . ToArray ( ) ;
@@ -532,13 +523,11 @@ public long PublishMessage(string toChannel, string message)
532
523
533
524
#region IBasicPersistenceProvider
534
525
535
-
536
526
Dictionary < string , HashSet < string > > registeredTypeIdsWithinPipelineMap = new Dictionary < string , HashSet < string > > ( ) ;
537
527
538
528
internal HashSet < string > GetRegisteredTypeIdsWithinPipeline ( string typeIdsSet )
539
529
{
540
- HashSet < string > registeredTypeIdsWithinPipeline ;
541
- if ( ! registeredTypeIdsWithinPipelineMap . TryGetValue ( typeIdsSet , out registeredTypeIdsWithinPipeline ) )
530
+ if ( ! registeredTypeIdsWithinPipelineMap . TryGetValue ( typeIdsSet , out var registeredTypeIdsWithinPipeline ) )
542
531
{
543
532
registeredTypeIdsWithinPipeline = new HashSet < string > ( ) ;
544
533
registeredTypeIdsWithinPipelineMap [ typeIdsSet ] = registeredTypeIdsWithinPipeline ;
@@ -664,7 +653,7 @@ public T Store<T>(T entity)
664
653
665
654
public object StoreObject ( object entity )
666
655
{
667
- if ( entity == null ) throw new ArgumentNullException ( " entity" ) ;
656
+ if ( entity == null ) throw new ArgumentNullException ( nameof ( entity ) ) ;
668
657
669
658
var id = entity . GetObjectId ( ) ;
670
659
var entityType = entity . GetType ( ) ;
@@ -799,7 +788,7 @@ public RedisClient CloneClient()
799
788
/// <returns></returns>
800
789
public string UrnKey < T > ( T value )
801
790
{
802
- return String . Concat ( NamespacePrefix , value . CreateUrn ( ) ) ;
791
+ return string . Concat ( NamespacePrefix , value . CreateUrn ( ) ) ;
803
792
}
804
793
805
794
/// <summary>
@@ -809,7 +798,7 @@ public string UrnKey<T>(T value)
809
798
/// <returns></returns>
810
799
public string UrnKey < T > ( object id )
811
800
{
812
- return String . Concat ( NamespacePrefix , IdUtils . CreateUrn < T > ( id ) ) ;
801
+ return string . Concat ( NamespacePrefix , IdUtils . CreateUrn < T > ( id ) ) ;
813
802
}
814
803
815
804
/// <summary>
@@ -820,7 +809,7 @@ public string UrnKey<T>(object id)
820
809
/// <returns></returns>
821
810
public string UrnKey ( Type type , object id )
822
811
{
823
- return String . Concat ( NamespacePrefix , IdUtils . CreateUrn ( type , id ) ) ;
812
+ return string . Concat ( NamespacePrefix , IdUtils . CreateUrn ( type , id ) ) ;
824
813
}
825
814
826
815
@@ -833,8 +822,7 @@ public string UrnKey(Type type, object id)
833
822
834
823
public T ExecCachedLua < T > ( string scriptBody , Func < string , T > scriptSha1 )
835
824
{
836
- string sha1 ;
837
- if ( ! CachedLuaSha1Map . TryGetValue ( scriptBody , out sha1 ) )
825
+ if ( ! CachedLuaSha1Map . TryGetValue ( scriptBody , out var sha1 ) )
838
826
CachedLuaSha1Map [ scriptBody ] = sha1 = LoadLuaScript ( scriptBody ) ;
839
827
840
828
try
@@ -1078,8 +1066,7 @@ public RedisServerRole GetServerRole()
1078
1066
return ToServerRole ( roleName ) ;
1079
1067
}
1080
1068
1081
- string role ;
1082
- this . Info . TryGetValue ( "role" , out role ) ;
1069
+ this . Info . TryGetValue ( "role" , out var role ) ;
1083
1070
return ToServerRole ( role ) ;
1084
1071
}
1085
1072
0 commit comments