Skip to content

Commit

Permalink
rename some methods and tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
atakavci committed May 17, 2024
1 parent 1ae4d4a commit 7dbb7af
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 133 deletions.
14 changes: 12 additions & 2 deletions src/StackExchange.Redis/Enums/HashFieldFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,18 @@ internal static bool isGETNEW(this HashFieldFlags flags) =>
internal static bool isGETOLD(this HashFieldFlags flags) =>
flags.HasFlag(HashFieldFlags.GETOLD);

internal static List<RedisValue> ToRedisValueList(this HashFieldFlags flags) =>
flags.isNone() ? new List<RedisValue>() : flags.ToString().Split(',').Select(v => (RedisValue)v).ToList();
internal static List<RedisValue> ToRedisValueList(this HashFieldFlags flags)
{
List<RedisValue> values = new();
if (flags.isNone()) return values;
if (flags.isDC()) values.Add(HashFieldFlags.DC.ToString());
if (flags.isDCF()) values.Add(HashFieldFlags.DCF.ToString());
if (flags.isDOF()) values.Add(HashFieldFlags.DOF.ToString());
if (flags.isGETNEW()) values.Add(HashFieldFlags.GETNEW.ToString());
if (flags.isGETOLD()) values.Add(HashFieldFlags.GETOLD.ToString());
return values;

}

}

12 changes: 6 additions & 6 deletions src/StackExchange.Redis/Interfaces/IDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
/// value: value of field
/// nil: if no such field exists
/// </returns>
RedisValue[]? HashGet(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
RedisValue[]? HashGetAndSetExpiry(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);

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

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

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

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

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

/// <summary>
/// Returns all fields and values of the hash stored at key.
Expand Down
12 changes: 6 additions & 6 deletions src/StackExchange.Redis/Interfaces/IDatabaseAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public interface IDatabaseAsync : IRedisAsync
/// value: value of field
/// nil: if no such field exists
/// </returns>
Task<RedisValue[]?> HashGetAsync(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);
Task<RedisValue[]?> HashGetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, TimeSpan expireDuration, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);

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

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

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

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

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

/// <summary>
/// Returns the value associated with field in the hash stored at key.
Expand Down
24 changes: 12 additions & 12 deletions src/StackExchange.Redis/KeyspaceIsolation/KeyPrefixed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ public Task<bool> HashExistsAsync(RedisKey key, RedisValue hashField, CommandFla
public Task<long[]?> HashFieldTimeToLiveAsync(RedisKey key, RedisValue[] hashFields, CommandFlags flags) =>
Inner.HashFieldTimeToLiveAsync(ToInner(key), hashFields, flags);

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

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

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

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

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

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

public Task<HashEntry[]> HashGetAllAsync(RedisKey key, CommandFlags flags = CommandFlags.None) =>
Inner.HashGetAllAsync(ToInner(key), flags);
Expand Down
24 changes: 12 additions & 12 deletions src/StackExchange.Redis/KeyspaceIsolation/KeyPrefixedDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,23 @@ public RedisValue[] HashGet(RedisKey key, RedisValue[] hashFields, CommandFlags
public RedisValue HashGet(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) =>
Inner.HashGet(ToInner(key), hashField, flags);

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

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

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

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

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

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

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

0 comments on commit 7dbb7af

Please sign in to comment.