Skip to content

Commit 7dbb7af

Browse files
committed
rename some methods and tidy up
1 parent 1ae4d4a commit 7dbb7af

File tree

8 files changed

+130
-133
lines changed

8 files changed

+130
-133
lines changed

src/StackExchange.Redis/Enums/HashFieldFlags.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,18 @@ internal static bool isGETNEW(this HashFieldFlags flags) =>
5656
internal static bool isGETOLD(this HashFieldFlags flags) =>
5757
flags.HasFlag(HashFieldFlags.GETOLD);
5858

59-
internal static List<RedisValue> ToRedisValueList(this HashFieldFlags flags) =>
60-
flags.isNone() ? new List<RedisValue>() : flags.ToString().Split(',').Select(v => (RedisValue)v).ToList();
59+
internal static List<RedisValue> ToRedisValueList(this HashFieldFlags flags)
60+
{
61+
List<RedisValue> values = new();
62+
if (flags.isNone()) return values;
63+
if (flags.isDC()) values.Add(HashFieldFlags.DC.ToString());
64+
if (flags.isDCF()) values.Add(HashFieldFlags.DCF.ToString());
65+
if (flags.isDOF()) values.Add(HashFieldFlags.DOF.ToString());
66+
if (flags.isGETNEW()) values.Add(HashFieldFlags.GETNEW.ToString());
67+
if (flags.isGETOLD()) values.Add(HashFieldFlags.GETOLD.ToString());
68+
return values;
69+
70+
}
6171

6272
}
6373

src/StackExchange.Redis/Interfaces/IDatabase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
516516
/// value: value of field
517517
/// nil: if no such field exists
518518
/// </returns>
519-
RedisValue[]? HashGet(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
519+
RedisValue[]? HashGetAndSetExpiry(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
520520

521521
/// <summary>
522522
/// For each specified field, it gets the value and sets the field's expiration timestamp
@@ -530,7 +530,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
530530
/// value: value of field
531531
/// nil: if no such field exists
532532
/// </returns>
533-
RedisValue[]? HashGet(RedisKey key, RedisValue[] hashFields, DateTime expireTime, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
533+
RedisValue[]? HashGetAndSetExpiry(RedisKey key, RedisValue[] hashFields, DateTime expireTime, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
534534

535535
/// <summary>
536536
/// For each specified field, it gets the value and removes the field's expiration
@@ -542,7 +542,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
542542
/// value: value of field
543543
/// nil: if no such field exists
544544
/// </returns>
545-
RedisValue[]? HashGetPersistFields(RedisKey key, RedisValue[] hashFields, CommandFlags flags = CommandFlags.None);
545+
RedisValue[]? HashGetAndPersistFields(RedisKey key, RedisValue[] hashFields, CommandFlags flags = CommandFlags.None);
546546

547547
/// <summary>
548548
/// For each specified field, it sets the value and optionally sets the fields expiration
@@ -566,7 +566,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
566566
/// a: 1 if the field's value was set or 0 if not (DCF/DOF met)
567567
/// b: 2 if the field's expiration time was set/discarded or 0 if not (DCF/DOF met, NX/XX/GT/LT not met)
568568
/// </returns>
569-
RedisValue[]? HashSet(RedisKey key, HashEntry[] hashFields, bool keepExpiry, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
569+
RedisValue[]? HashSetAndSetExpiry(RedisKey key, HashEntry[] hashFields, bool keepExpiry, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
570570

571571
/// <summary>
572572
/// For each specified field, it sets the value and optionally sets the fields expiration
@@ -591,7 +591,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
591591
/// a: 1 if the field's value was set or 0 if not (DCF/DOF met)
592592
/// b: 2 if the field's expiration time was set/discarded or 0 if not (DCF/DOF met, NX/XX/GT/LT not met)
593593
/// </returns>
594-
RedisValue[]? HashSet(RedisKey key, HashEntry[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
594+
RedisValue[]? HashSetAndSetExpiry(RedisKey key, HashEntry[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
595595

596596
/// <summary>
597597
/// For each specified field, it sets the value and optionally sets the fields expiration
@@ -616,7 +616,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
616616
/// a: 1 if the field's value was set or 0 if not (DCF/DOF met)
617617
/// b: 2 if the field's expiration time was set/discarded or 0 if not (DCF/DOF met, NX/XX/GT/LT not met)
618618
/// </returns>
619-
RedisValue[]? HashSet(RedisKey key, HashEntry[] hashFields, DateTime expireTime, ExpireWhen when = ExpireWhen.Always, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
619+
RedisValue[]? HashSetAndSetExpiry(RedisKey key, HashEntry[] hashFields, DateTime expireTime, ExpireWhen when = ExpireWhen.Always, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
620620

621621
/// <summary>
622622
/// Returns all fields and values of the hash stored at key.

src/StackExchange.Redis/Interfaces/IDatabaseAsync.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public interface IDatabaseAsync : IRedisAsync
470470
/// value: value of field
471471
/// nil: if no such field exists
472472
/// </returns>
473-
Task<RedisValue[]?> HashGetAsync(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
473+
Task<RedisValue[]?> HashGetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
474474

475475
/// <summary>
476476
/// For each specified field, it gets the value and sets the field's expiration timestamp
@@ -484,7 +484,7 @@ public interface IDatabaseAsync : IRedisAsync
484484
/// value: value of field
485485
/// nil: if no such field exists
486486
/// </returns>
487-
Task<RedisValue[]?> HashGetAsync(RedisKey key, RedisValue[] hashFields, DateTime expireTime, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
487+
Task<RedisValue[]?> HashGetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, DateTime expireTime, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
488488

489489
/// <summary>
490490
/// For each specified field, it gets the value and removes the field's expiration
@@ -496,7 +496,7 @@ public interface IDatabaseAsync : IRedisAsync
496496
/// value: value of field
497497
/// nil: if no such field exists
498498
/// </returns>
499-
Task<RedisValue[]?> HashGetPersistFieldsAsync(RedisKey key, RedisValue[] hashFields, CommandFlags flags = CommandFlags.None);
499+
Task<RedisValue[]?> HashGetAndPersistFieldsAsync(RedisKey key, RedisValue[] hashFields, CommandFlags flags = CommandFlags.None);
500500

501501
/// <summary>
502502
/// For each specified field, it sets the value and optionally sets the fields expiration
@@ -520,7 +520,7 @@ public interface IDatabaseAsync : IRedisAsync
520520
/// a: 1 if the field's value was set or 0 if not (DCF/DOF met)
521521
/// b: 2 if the field's expiration time was set/discarded or 0 if not (DCF/DOF met, NX/XX/GT/LT not met)
522522
/// </returns>
523-
Task<RedisValue[]?> HashSetAsync(RedisKey key, HashEntry[] hashFields, bool keepExpiry, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
523+
Task<RedisValue[]?> HashSetAndSetExpiryAsync(RedisKey key, HashEntry[] hashFields, bool keepExpiry, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
524524

525525
/// <summary>
526526
/// For each specified field, it sets the value and optionally sets the fields expiration
@@ -545,7 +545,7 @@ public interface IDatabaseAsync : IRedisAsync
545545
/// a: 1 if the field's value was set or 0 if not (DCF/DOF met)
546546
/// b: 2 if the field's expiration time was set/discarded or 0 if not (DCF/DOF met, NX/XX/GT/LT not met)
547547
/// </returns>
548-
Task<RedisValue[]?> HashSetAsync(RedisKey key, HashEntry[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
548+
Task<RedisValue[]?> HashSetAndSetExpiryAsync(RedisKey key, HashEntry[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
549549

550550
/// <summary>
551551
/// For each specified field, it sets the value and optionally sets the fields expiration
@@ -570,7 +570,7 @@ public interface IDatabaseAsync : IRedisAsync
570570
/// a: 1 if the field's value was set or 0 if not (DCF/DOF met)
571571
/// b: 2 if the field's expiration time was set/discarded or 0 if not (DCF/DOF met, NX/XX/GT/LT not met)
572572
/// </returns>
573-
Task<RedisValue[]?> HashSetAsync(RedisKey key, HashEntry[] hashFields, DateTime expireTime, ExpireWhen when = ExpireWhen.Always, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
573+
Task<RedisValue[]?> HashSetAndSetExpiryAsync(RedisKey key, HashEntry[] hashFields, DateTime expireTime, ExpireWhen when = ExpireWhen.Always, HashFieldFlags fieldFlags = HashFieldFlags.None, CommandFlags flags = CommandFlags.None);
574574

575575
/// <summary>
576576
/// Returns the value associated with field in the hash stored at key.

src/StackExchange.Redis/KeyspaceIsolation/KeyPrefixed.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,23 @@ public Task<bool> HashExistsAsync(RedisKey key, RedisValue hashField, CommandFla
114114
public Task<long[]?> HashFieldTimeToLiveAsync(RedisKey key, RedisValue[] hashFields, CommandFlags flags) =>
115115
Inner.HashFieldTimeToLiveAsync(ToInner(key), hashFields, flags);
116116

117-
public Task<RedisValue[]?> HashGetAsync(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when, CommandFlags flags) =>
118-
Inner.HashGetAsync(ToInner(key), hashFields, expireDuration, when, flags);
117+
public Task<RedisValue[]?> HashGetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when, CommandFlags flags) =>
118+
Inner.HashGetAndSetExpiryAsync(ToInner(key), hashFields, expireDuration, when, flags);
119119

120-
public Task<RedisValue[]?> HashGetAsync(RedisKey key, RedisValue[] hashFields, DateTime expireTime, ExpireWhen when, CommandFlags flags) =>
121-
Inner.HashGetAsync(ToInner(key), hashFields, expireTime, when, flags);
120+
public Task<RedisValue[]?> HashGetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, DateTime expireTime, ExpireWhen when, CommandFlags flags) =>
121+
Inner.HashGetAndSetExpiryAsync(ToInner(key), hashFields, expireTime, when, flags);
122122

123-
public Task<RedisValue[]?> HashGetPersistFieldsAsync(RedisKey key, RedisValue[] hashFields, CommandFlags flags) =>
124-
Inner.HashGetPersistFieldsAsync(ToInner(key), hashFields, flags);
123+
public Task<RedisValue[]?> HashGetAndPersistFieldsAsync(RedisKey key, RedisValue[] hashFields, CommandFlags flags) =>
124+
Inner.HashGetAndPersistFieldsAsync(ToInner(key), hashFields, flags);
125125

126-
public Task<RedisValue[]?> HashSetAsync(RedisKey key, HashEntry[] hashFields, bool keepExpiry, HashFieldFlags fieldFlags, CommandFlags flags) =>
127-
Inner.HashSetAsync(ToInner(key), hashFields, keepExpiry, fieldFlags, flags);
126+
public Task<RedisValue[]?> HashSetAndSetExpiryAsync(RedisKey key, HashEntry[] hashFields, bool keepExpiry, HashFieldFlags fieldFlags, CommandFlags flags) =>
127+
Inner.HashSetAndSetExpiryAsync(ToInner(key), hashFields, keepExpiry, fieldFlags, flags);
128128

129-
public Task<RedisValue[]?> HashSetAsync(RedisKey key, HashEntry[] hashFields, TimeSpan expireDuration, ExpireWhen when, HashFieldFlags fieldFlags, CommandFlags flags) =>
130-
Inner.HashSetAsync(ToInner(key), hashFields, expireDuration, when, fieldFlags, flags);
129+
public Task<RedisValue[]?> HashSetAndSetExpiryAsync(RedisKey key, HashEntry[] hashFields, TimeSpan expireDuration, ExpireWhen when, HashFieldFlags fieldFlags, CommandFlags flags) =>
130+
Inner.HashSetAndSetExpiryAsync(ToInner(key), hashFields, expireDuration, when, fieldFlags, flags);
131131

132-
public Task<RedisValue[]?> HashSetAsync(RedisKey key, HashEntry[] hashFields, DateTime expireTime, ExpireWhen when, HashFieldFlags fieldFlags, CommandFlags flags) =>
133-
Inner.HashSetAsync(ToInner(key), hashFields, expireTime, when, fieldFlags, flags);
132+
public Task<RedisValue[]?> HashSetAndSetExpiryAsync(RedisKey key, HashEntry[] hashFields, DateTime expireTime, ExpireWhen when, HashFieldFlags fieldFlags, CommandFlags flags) =>
133+
Inner.HashSetAndSetExpiryAsync(ToInner(key), hashFields, expireTime, when, fieldFlags, flags);
134134

135135
public Task<HashEntry[]> HashGetAllAsync(RedisKey key, CommandFlags flags = CommandFlags.None) =>
136136
Inner.HashGetAllAsync(ToInner(key), flags);

src/StackExchange.Redis/KeyspaceIsolation/KeyPrefixedDatabase.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,23 @@ public RedisValue[] HashGet(RedisKey key, RedisValue[] hashFields, CommandFlags
120120
public RedisValue HashGet(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) =>
121121
Inner.HashGet(ToInner(key), hashField, flags);
122122

123-
public RedisValue[]? HashGet(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when, CommandFlags flags) =>
124-
Inner.HashGet(ToInner(key), hashFields, expireDuration, when, flags);
123+
public RedisValue[]? HashGetAndSetExpiry(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when, CommandFlags flags) =>
124+
Inner.HashGetAndSetExpiry(ToInner(key), hashFields, expireDuration, when, flags);
125125

126-
public RedisValue[]? HashGet(RedisKey key, RedisValue[] hashFields, DateTime expireTime, ExpireWhen when, CommandFlags flags) =>
127-
Inner.HashGet(ToInner(key), hashFields, expireTime, when, flags);
126+
public RedisValue[]? HashGetAndSetExpiry(RedisKey key, RedisValue[] hashFields, DateTime expireTime, ExpireWhen when, CommandFlags flags) =>
127+
Inner.HashGetAndSetExpiry(ToInner(key), hashFields, expireTime, when, flags);
128128

129-
public RedisValue[]? HashGetPersistFields(RedisKey key, RedisValue[] hashFields, CommandFlags flags) =>
130-
Inner.HashGetPersistFields(ToInner(key), hashFields, flags);
129+
public RedisValue[]? HashGetAndPersistFields(RedisKey key, RedisValue[] hashFields, CommandFlags flags) =>
130+
Inner.HashGetAndPersistFields(ToInner(key), hashFields, flags);
131131

132-
public RedisValue[]? HashSet(RedisKey key, HashEntry[] hashFields, bool keepExpiry, HashFieldFlags fieldFlags, CommandFlags flags) =>
133-
Inner.HashSet(ToInner(key), hashFields, keepExpiry, fieldFlags, flags);
132+
public RedisValue[]? HashSetAndSetExpiry(RedisKey key, HashEntry[] hashFields, bool keepExpiry, HashFieldFlags fieldFlags, CommandFlags flags) =>
133+
Inner.HashSetAndSetExpiry(ToInner(key), hashFields, keepExpiry, fieldFlags, flags);
134134

135-
public RedisValue[]? HashSet(RedisKey key, HashEntry[] hashFields, TimeSpan expireDuration, ExpireWhen when, HashFieldFlags fieldFlags, CommandFlags flags) =>
136-
Inner.HashSet(ToInner(key), hashFields, expireDuration, when, fieldFlags, flags);
135+
public RedisValue[]? HashSetAndSetExpiry(RedisKey key, HashEntry[] hashFields, TimeSpan expireDuration, ExpireWhen when, HashFieldFlags fieldFlags, CommandFlags flags) =>
136+
Inner.HashSetAndSetExpiry(ToInner(key), hashFields, expireDuration, when, fieldFlags, flags);
137137

138-
public RedisValue[]? HashSet(RedisKey key, HashEntry[] hashFields, DateTime expireTime, ExpireWhen when, HashFieldFlags fieldFlags, CommandFlags flags) =>
139-
Inner.HashSet(ToInner(key), hashFields, expireTime, when, fieldFlags, flags);
138+
public RedisValue[]? HashSetAndSetExpiry(RedisKey key, HashEntry[] hashFields, DateTime expireTime, ExpireWhen when, HashFieldFlags fieldFlags, CommandFlags flags) =>
139+
Inner.HashSetAndSetExpiry(ToInner(key), hashFields, expireTime, when, fieldFlags, flags);
140140

141141
public Lease<byte>? HashGetLease(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) =>
142142
Inner.HashGetLease(ToInner(key), hashField, flags);

0 commit comments

Comments
 (0)