@ -85,7 +85,7 @@ namespace LINGYUN.Abp.Features.LimitValidation.Redis
var result = await _ redis . ScriptEvaluateAsync ( luaSha1 , keys , values ) ;
var result = await _ redis . ScriptEvaluateAsync ( luaSha1 , keys , values ) ;
if ( result . Type = = ResultType . Error )
if ( result . Type = = ResultType . Error )
{
{
throw new AbpException ( $"脚本执行错误: {result}" ) ;
throw new AbpException ( $"Script evaluate error: {result}" ) ;
}
}
return ( int ) result ;
return ( int ) result ;
}
}
@ -95,20 +95,6 @@ namespace LINGYUN.Abp.Features.LimitValidation.Redis
return _f eatureNamingNormalizer . NormalizeFeatureName ( _ instance , context ) ;
return _f eatureNamingNormalizer . NormalizeFeatureName ( _ instance , context ) ;
}
}
private void RegistenConnectionEvent ( ConnectionMultiplexer connection )
{
if ( connection ! = null )
{
connection . ConnectionFailed + = OnConnectionFailed ;
connection . ConnectionRestored + = OnConnectionRestored ;
connection . ErrorMessage + = OnErrorMessage ;
connection . ConfigurationChanged + = OnConfigurationChanged ;
connection . HashSlotMoved + = OnHashSlotMoved ;
connection . InternalError + = OnInternalError ;
connection . ConfigurationChangedBroadcast + = OnConfigurationChangedBroadcast ;
}
}
private async Task ConnectAsync ( CancellationToken token = default ( CancellationToken ) )
private async Task ConnectAsync ( CancellationToken token = default ( CancellationToken ) )
{
{
token . ThrowIfCancellationRequested ( ) ;
token . ThrowIfCancellationRequested ( ) ;
@ -134,7 +120,7 @@ namespace LINGYUN.Abp.Features.LimitValidation.Redis
_ redisConfig . AllowAdmin = true ;
_ redisConfig . AllowAdmin = true ;
_ redisConfig . SetDefaultPorts ( ) ;
_ redisConfig . SetDefaultPorts ( ) ;
_ connection = await ConnectionMultiplexer . ConnectAsync ( _ redisConfig ) ;
_ connection = await ConnectionMultiplexer . ConnectAsync ( _ redisConfig ) ;
RegistenConnectionEvent ( _ connection ) ;
// fix: 无需关注redis连接事件
_ redis = _ connection . GetDatabase ( ) ;
_ redis = _ connection . GetDatabase ( ) ;
_ server = _ connection . GetServer ( _ redisConfig . EndPoints [ 0 ] ) ;
_ server = _ connection . GetServer ( _ redisConfig . EndPoints [ 0 ] ) ;
}
}
@ -144,46 +130,5 @@ namespace LINGYUN.Abp.Features.LimitValidation.Redis
_ connectionLock . Release ( ) ;
_ connectionLock . Release ( ) ;
}
}
}
}
private void OnConfigurationChangedBroadcast ( object sender , EndPointEventArgs e )
{
Logger . LogInformation ( "Redis server master/slave changes" ) ;
}
private void OnInternalError ( object sender , InternalErrorEventArgs e )
{
Logger . LogError ( "Redis internal error, origin:{0}, connectionType:{1}" ,
e . Origin , e . ConnectionType ) ;
Logger . LogError ( e . Exception , "Redis internal error" ) ;
}
private void OnHashSlotMoved ( object sender , HashSlotMovedEventArgs e )
{
Logger . LogInformation ( "Redis configuration changed" ) ;
}
private void OnConfigurationChanged ( object sender , EndPointEventArgs e )
{
Logger . LogInformation ( "Redis configuration changed" ) ;
}
private void OnErrorMessage ( object sender , RedisErrorEventArgs e )
{
Logger . LogWarning ( "Redis error, message:{0}" , e . Message ) ;
}
private void OnConnectionRestored ( object sender , ConnectionFailedEventArgs e )
{
Logger . LogWarning ( "Redis connection restored, failureType:{0}, connectionType:{1}" ,
e . FailureType , e . ConnectionType ) ;
}
private void OnConnectionFailed ( object sender , ConnectionFailedEventArgs e )
{
Logger . LogError ( "Redis connection failed, failureType:{0}, connectionType:{1}" ,
e . FailureType , e . ConnectionType ) ;
Logger . LogError ( e . Exception , "Redis lock connection failed" ) ;
}
}
}
}
}