Commit 5ec10092 authored by Marc Gravell's avatar Marc Gravell

Minor API break: the longer RandomKey sits there, the longer it gnaws at my...

Minor API break: the longer RandomKey sits there, the longer it gnaws at my soul as an odd exception to the naming rules; best to fix now
parent a6f4ada5
...@@ -28,7 +28,7 @@ or ...@@ -28,7 +28,7 @@ or
Likewise, there are operations that *return* keys as `RedisKey` - and again, it simply works: Likewise, there are operations that *return* keys as `RedisKey` - and again, it simply works:
string someKey = db.RandomKey(); string someKey = db.KeyRandom();
Values Values
--- ---
......
...@@ -35,11 +35,11 @@ public void RandomKey() ...@@ -35,11 +35,11 @@ public void RandomKey()
{ {
var db = conn.GetDatabase(); var db = conn.GetDatabase();
conn.GetServer(PrimaryServer, PrimaryPort).FlushDatabase(); conn.GetServer(PrimaryServer, PrimaryPort).FlushDatabase();
string anyKey = db.RandomKey(); string anyKey = db.KeyRandom();
Assert.IsNull(anyKey); Assert.IsNull(anyKey);
db.StringSet("abc", "def"); db.StringSet("abc", "def");
byte[] keyBytes = db.RandomKey(); byte[] keyBytes = db.KeyRandom();
Assert.AreEqual("abc", Encoding.UTF8.GetString(keyBytes)); Assert.AreEqual("abc", Encoding.UTF8.GetString(keyBytes));
} }
......
...@@ -71,8 +71,8 @@ public void CheckDatabaseMethodsUseKeys(Type type) ...@@ -71,8 +71,8 @@ public void CheckDatabaseMethodsUseKeys(Type type)
switch(method.Name) switch(method.Name)
{ {
case "RandomKey": case "KeyRandom":
case "RandomKeyAsync": case "KeyRandomAsync":
continue; // they're fine, but don't want to widen check to return type continue; // they're fine, but don't want to widen check to return type
} }
......
...@@ -382,8 +382,7 @@ public interface IDatabase : IRedis, IDatabaseAsync ...@@ -382,8 +382,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
/// </summary> /// </summary>
/// <returns>the random key, or nil when the database is empty.</returns> /// <returns>the random key, or nil when the database is empty.</returns>
/// <remarks>http://redis.io/commands/randomkey</remarks> /// <remarks>http://redis.io/commands/randomkey</remarks>
[IgnoreNamePrefix] RedisKey KeyRandom(CommandFlags flags = CommandFlags.None);
RedisKey RandomKey(CommandFlags flags = CommandFlags.None);
/// <summary> /// <summary>
/// Execute a Lua script against the server /// Execute a Lua script against the server
......
...@@ -368,8 +368,7 @@ public interface IDatabaseAsync : IRedisAsync ...@@ -368,8 +368,7 @@ public interface IDatabaseAsync : IRedisAsync
/// </summary> /// </summary>
/// <returns>the random key, or nil when the database is empty.</returns> /// <returns>the random key, or nil when the database is empty.</returns>
/// <remarks>http://redis.io/commands/randomkey</remarks> /// <remarks>http://redis.io/commands/randomkey</remarks>
[IgnoreNamePrefix] Task<RedisKey> KeyRandomAsync(CommandFlags flags = CommandFlags.None);
Task<RedisKey> RandomKeyAsync(CommandFlags flags = CommandFlags.None);
......
...@@ -661,13 +661,13 @@ public Task<bool> LockTakeAsync(RedisKey key, RedisValue value, TimeSpan expiry, ...@@ -661,13 +661,13 @@ public Task<bool> LockTakeAsync(RedisKey key, RedisValue value, TimeSpan expiry,
return StringSetAsync(key, value, expiry, When.NotExists, flags); return StringSetAsync(key, value, expiry, When.NotExists, flags);
} }
public RedisKey RandomKey(CommandFlags flags = CommandFlags.None) public RedisKey KeyRandom(CommandFlags flags = CommandFlags.None)
{ {
var msg = Message.Create(Db, flags, RedisCommand.RANDOMKEY); var msg = Message.Create(Db, flags, RedisCommand.RANDOMKEY);
return ExecuteSync(msg, ResultProcessor.RedisKey); return ExecuteSync(msg, ResultProcessor.RedisKey);
} }
public Task<RedisKey> RandomKeyAsync(CommandFlags flags = CommandFlags.None) public Task<RedisKey> KeyRandomAsync(CommandFlags flags = CommandFlags.None)
{ {
var msg = Message.Create(Db, flags, RedisCommand.RANDOMKEY); var msg = Message.Create(Db, flags, RedisCommand.RANDOMKEY);
return ExecuteAsync(msg, ResultProcessor.RedisKey); return ExecuteAsync(msg, ResultProcessor.RedisKey);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment