@@ -10,38 +10,40 @@ internal static class HashEntryArrayExtensions
1010 private const long NotPresent = - 1 ;
1111 private const string SlidingExpirationKey = "sldexp" ;
1212
13- internal static DistributedCacheEntryOptions GetDistributedCacheEntryOptions (
14- this HashEntry [ ] hashEntries )
13+ extension (
14+ HashEntry [ ] hashEntries )
1515 {
16- var distributedCacheEntryOptions = new DistributedCacheEntryOptions ( ) ;
17-
18- var absoluteExpirationHashEntry = hashEntries . FirstOrDefault (
19- hashEntry => hashEntry . Name == AbsoluteExpirationKey ) ;
20- if ( absoluteExpirationHashEntry . Value . HasValue &&
21- absoluteExpirationHashEntry . Value != NotPresent )
16+ internal DistributedCacheEntryOptions GetDistributedCacheEntryOptions ( )
2217 {
23- distributedCacheEntryOptions . AbsoluteExpiration = new DateTimeOffset (
24- ( long ) absoluteExpirationHashEntry . Value , TimeSpan . Zero ) ;
18+ var distributedCacheEntryOptions = new DistributedCacheEntryOptions ( ) ;
19+
20+ var absoluteExpirationHashEntry = hashEntries . FirstOrDefault (
21+ hashEntry => hashEntry . Name == AbsoluteExpirationKey ) ;
22+ if ( absoluteExpirationHashEntry . Value . HasValue &&
23+ absoluteExpirationHashEntry . Value != NotPresent )
24+ {
25+ distributedCacheEntryOptions . AbsoluteExpiration = new DateTimeOffset (
26+ ( long ) absoluteExpirationHashEntry . Value , TimeSpan . Zero ) ;
27+ }
28+
29+ var slidingExpirationHashEntry = hashEntries . FirstOrDefault (
30+ hashEntry => hashEntry . Name == SlidingExpirationKey ) ;
31+ if ( slidingExpirationHashEntry . Value . HasValue &&
32+ slidingExpirationHashEntry . Value != NotPresent )
33+ {
34+ distributedCacheEntryOptions . SlidingExpiration = new TimeSpan (
35+ ( long ) slidingExpirationHashEntry . Value ) ;
36+ }
37+
38+ return distributedCacheEntryOptions ;
2539 }
2640
27- var slidingExpirationHashEntry = hashEntries . FirstOrDefault (
28- hashEntry => hashEntry . Name == SlidingExpirationKey ) ;
29- if ( slidingExpirationHashEntry . Value . HasValue &&
30- slidingExpirationHashEntry . Value != NotPresent )
41+ internal RedisValue GetRedisValue ( )
3142 {
32- distributedCacheEntryOptions . SlidingExpiration = new TimeSpan (
33- ( long ) slidingExpirationHashEntry . Value ) ;
34- }
35-
36- return distributedCacheEntryOptions ;
37- }
43+ var dataHashEntry = hashEntries . FirstOrDefault (
44+ hashEntry => hashEntry . Name == DataKey ) ;
3845
39- internal static RedisValue GetRedisValue (
40- this HashEntry [ ] hashEntries )
41- {
42- var dataHashEntry = hashEntries . FirstOrDefault (
43- hashEntry => hashEntry . Name == DataKey ) ;
44-
45- return dataHashEntry . Value ;
46+ return dataHashEntry . Value ;
47+ }
4648 }
4749}
0 commit comments