IDatabase, .
IDatabase
ConnectionMultiplexer multiplexer = ConnectionMultiplexer.Connect("localhost");
IDatabase fullDatabase = multiplexer.GetDatabase();
IDatabase partitioned = fullDatabase.GetKeyspacePartition("my-partition");
:
public bool SetAdd(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None)
{
return this.Inner.SetAdd(this.ToInner(key), value, flags);
}
RedisKey, .
CreateBatch CreateTransaction , - ( IDatabaseAsync).
KeyRandomAsync KeyRandom . NotSupportedException. , @Marc Gravell:
- , , NotSupportedException ( "RANDOMKEY , " ) ( )/p >
ScriptEvaluate ScriptEvaluateAsync, , RedisResult. RedisKey, , script , , () . NotImplementedException...
(Sort, SortAsync, SortAndStore SortAndStoreAsync) by get. , : nosort by # get.
, ITransaction.AddCondition, :
internal static class ConditionHelper
{
public static Condition Rewrite(this Condition outer, Func<RedisKey, RedisKey> rewriteFunc)
{
ThrowIf.ArgNull(outer, "outer");
ThrowIf.ArgNull(rewriteFunc, "rewriteFunc");
Type conditionType = outer.GetType();
object inner = FormatterServices.GetUninitializedObject(conditionType);
foreach (FieldInfo field in conditionType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
{
if (field.FieldType == typeof(RedisKey))
{
field.SetValue(inner, rewriteFunc((RedisKey)field.GetValue(outer)));
}
else
{
field.SetValue(inner, field.GetValue(outer));
}
}
return (Condition)inner;
}
}
:
internal Condition ToInner(Condition outer)
{
if (outer == null)
{
return outer;
}
else
{
return outer.Rewrite(this.ToInner);
}
}
ToInner , RedisKey, :
internal RedisKey ToInner(RedisKey outer)
{
return this.Prefix + outer;
}
:
https://github.com/StackExchange/StackExchange.Redis/pull/92
WithKeyPrefix, , Condition.