Skip to content

Commit

Permalink
added support for MIGRATE command
Browse files Browse the repository at this point in the history
  • Loading branch information
webernir committed Feb 14, 2016
1 parent 6e1b340 commit d4a1533
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Sider/IRedisClient.cs
Expand Up @@ -94,6 +94,7 @@ public interface IRedisClient<T> : IDisposable
T[] MGet(params string[] keys);
IObservable<string> Monitor();
bool Move(string key, int dbIndex);
bool Migrate(string host, int port, string key, int dbIndex, int timeout, bool copy, bool replace);
bool MSet(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, T>> mappings);
bool MSetNX(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, T>> mappings);
bool Multi();
Expand Down
20 changes: 19 additions & 1 deletion src/Sider/RedisClient.API.cs
Expand Up @@ -271,7 +271,25 @@ public bool Move(string key, int dbIndex)
w => { w.WriteArg(key); w.WriteArg(dbIndex); },
r => r.ReadBool());
}


public bool Migrate(string host, int port, string key, int dbIndex, int timeout, bool copy, bool replace)
{
int argCount = 5 + (copy ? 1 : 0) + (replace ? 1 : 0);

return invoke("MIGRATE",
argCount,
w => {
w.WriteArg(host);
w.WriteArg(port);
w.WriteArg(key);
w.WriteArg(dbIndex);
w.WriteArg(timeout);
if (copy) w.WriteArg("COPY");
if (replace) w.WriteArg("REPLACE");
},
r => r.ReadOk());
}

public bool Persist(string key)
{
return invoke("PERSIST", r => r.ReadBool());
Expand Down

0 comments on commit d4a1533

Please sign in to comment.