本文整理汇总了C#中RedisValue.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# RedisValue.ToString方法的具体用法?C# RedisValue.ToString怎么用?C# RedisValue.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedisValue
的用法示例。
在下文中一共展示了RedisValue.ToString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListenForMessage
public void ListenForMessage(RedisChannel channel, RedisValue value)
{
Assert.AreEqual(RedisKey, channel.ToString());
Assert.IsFalse(!value.HasValue || value.IsNullOrEmpty);
Assert.AreEqual("INFO test pub/sub message", value.ToString());
ActionRun = true;
}
示例2: GetMessageUpdates
private static void GetMessageUpdates(RedisChannel channel, RedisValue value)
{
var vals = value.ToString().Split('|');
if (vals.Length != 3 || vals[0] == InstanceId) return;
GlobalHost.ConnectionManager.GetHubContext<ChatHub>().Clients.All.receiveMessage(vals[1], vals[2]);
}
示例3: GetConnectionUpdates
private static void GetConnectionUpdates(RedisChannel channel, RedisValue value)
{
var vals = value.ToString().Split('|');
if (vals.Length != 3 || vals[1] == InstanceId) return;
if (vals[0] == "1")
{
GlobalHost.ConnectionManager.GetHubContext<ChatHub>().Clients.All.clientConnected(vals[2]);
}
else if (vals[0] == "0")
{
GlobalHost.ConnectionManager.GetHubContext<ChatHub>().Clients.All.clientDisconnected(vals[2]);
}
}
示例4: OnInvalidationMessage
private void OnInvalidationMessage(RedisChannel pattern, RedisValue data)
{
if (pattern == Constants.DEFAULT_INVALIDATION_CHANNEL)
{
this.ProcessInvalidationMessage(data.ToString());
}
}
示例5: OnKeySpaceNotificationMessage
private void OnKeySpaceNotificationMessage(RedisChannel pattern, RedisValue data)
{
var prefix = pattern.ToString().Substring(0, 10);
switch (prefix)
{
case "__keyevent":
this.ProcessInvalidationMessage(data.ToString());
break;
default:
//nop
break;
}
}
示例6: onMessage
private void onMessage(RedisChannel channel, RedisValue value)
{
log(Logging.LoggingLevel.Detailed, "Received Message: {0}", value.ToString());
var dict = value.ToString().ToObject<Dictionary<string, string>>();
if (OnMessage != null)
OnMessage(dict["cacheName"], dict["message"]);
}
示例7: onExpireItemCache
private void onExpireItemCache(RedisChannel channel, RedisValue value)
{
log(Logging.LoggingLevel.Detailed, "Received Expire Item: {0}", value.ToJson());
var dict = value.ToString().ToObject<Dictionary<string, string>>();
if (OnExpireItem != null)
OnExpireItem(dict["cacheName"], dict["key"], dict["itemKey"]);
}
示例8: ProcessRedisCacheInstruction
private void ProcessRedisCacheInstruction(RedisChannel channel, RedisValue message )
{
string[] messageParts = message.ToString().Split( ',' );
if (messageParts.Length > 0 )
{
var action = messageParts[0];
switch ( action )
{
case "REMOVE":
{
if (messageParts.Length > 1 )
{
RemoveFromMemoryCache( messageParts[1] );
}
break;
}
case "FLUSH":
{
FlushMemoryCache();
break;
}
case "REFRESH_AUTH_ENTITY":
{
if ( messageParts.Length > 2 )
{
Rock.Security.Authorization.RefreshEntity( messageParts[1].AsInteger(), messageParts[2].AsInteger() );
}
break;
}
case "REFRESH_AUTH_ACTION":
{
if ( messageParts.Length > 3 )
{
Rock.Security.Authorization.RefreshAction( messageParts[1].AsInteger(), messageParts[2].AsInteger(), messageParts[3] );
}
break;
}
case "FLUSH_AUTH":
{
Rock.Security.Authorization.FlushAuth();
break;
}
case "REMOVE_ENTITY_ATTRIBUTES":
{
Rock.Web.Cache.AttributeCache.RemoveEntityAttributes();
break;
}
case "PING":
{
var response = string.Format( "PONG: From {0}: {1}", System.Environment.MachineName, System.AppDomain.CurrentDomain.FriendlyName );
SendRedisCommand( response );
break;
}
}
}
}
示例9: ToString
public override string ToString()
{
if (_params == null)
return base.ToString();
var multi = new RedisValue { Type = RedisValueType.MultiBulk, MultiBulkValues = _params };
return multi.ToString();
}
示例10: MasterWasSwitched
private void MasterWasSwitched(RedisChannel redisChannel, RedisValue redisValue)
{
_connection.ConnectionFailed -= OnConnectionFailed;
_connection.ConnectionRestored -= OnConnectionRestored;
_connection.ErrorMessage -= OnError;
_connection.Close();
if (redisValue.IsNullOrEmpty) return;
var message = redisValue.ToString();
var messageParts = message.Split(' ');
var ip = IPAddress.Parse(messageParts[3]);
var port = int.Parse(messageParts[4]);
EndPoint newMasterEndpoint = new IPEndPoint(ip, port);
if (_options.EndPoints.Any() && newMasterEndpoint == _options.EndPoints[0]) return;
_options.EndPoints.Clear();
_options.EndPoints.Add(newMasterEndpoint);
_connection = ConnectionMultiplexer.Connect(_options);
_connection.ConnectionFailed += OnConnectionFailed;
_connection.ConnectionRestored += OnConnectionRestored;
_connection.ErrorMessage += OnError;
_redisSubscriber = _connection.GetSubscriber();
var handler = ConnectionRestored;
if (handler != null) handler(new ApplicationException("Redis master was switched"));
}
示例11: WaitChannelPulse
private void WaitChannelPulse(RedisChannel redisChannel, RedisValue redisValue)
{
lock (this.waitLock)
{
if (this.wasWaitPulsed)
{
// somehow we got message that we shouldn't get
return;
}
try
{
this.wasWaitPulsed = true;
var pulseType = (PulseType)(int.Parse(redisValue.ToString()));
if (pulseType == PulseType.One)
{
// try get permission to wake
try
{
this.redisStorage.Remove(this.PulseFile);
}
catch (StorageKeyDoesntExistException)
{
// failed - need to sleep longer
return;
}
}
// unsubscribe yourself
this.redisStorage.Unsubscribe(this.WaitChannel, this.WaitChannelPulse);
Monitor.Pulse(this.waitLock);
}
finally
{
this.wasWaitPulsed = false;
}
}
}
示例12: Handler
/// <summary>
/// Handlers the specified redis channel.
/// </summary>
/// <param name="redisChannel">The redis channel.</param>
/// <param name="redisValue">The redis value.</param>
private void Handler(RedisChannel redisChannel, RedisValue redisValue)
{
if (!redisValue.HasValue || _messageId.Id.Value.ToString() != redisValue.ToString())
{
return;
}
_waitHandle.Set();
}
示例13: MasterWasSwitched
private void MasterWasSwitched(RedisChannel redisChannel, RedisValue redisValue)
{
if (redisValue.IsNullOrEmpty) return;
var message = redisValue.ToString();
var messageParts = message.Split(' ');
var ip = IPAddress.Parse(messageParts[3]);
var port = int.Parse(messageParts[4]);
EndPoint newMasterEndpoint = new IPEndPoint(ip, port);
if (_configOption.EndPoints.Any() && newMasterEndpoint == _configOption.EndPoints[0]) return;
_configOption.EndPoints.Clear();
_configOption.EndPoints.Add(newMasterEndpoint);
_redisMultiplexer = LogUtility.logger == null
? ConnectionMultiplexer.Connect(_configOption)
: ConnectionMultiplexer.Connect(_configOption, LogUtility.logger);
_connection = _redisMultiplexer.GetDatabase(_configuration.DatabaseId);
}