Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻ refactor(IDistributedCache): Optimize connections under Isolation and Attempt to reconnect #740

Merged
merged 7 commits into from
Nov 25, 2024

Conversation

wzh425
Copy link
Contributor

@wzh425 wzh425 commented Oct 30, 2024

No description provided.

@wzh425 wzh425 requested review from capdiem and Qinyouzeng October 30, 2024 09:23

namespace Masa.BuildingBlocks.Caching;

internal class DistributedCacheClientCache
Copy link
Contributor

@capdiem capdiem Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DistributedCacheClientCache的后缀Cache是OK的吗?你这是个工厂吧,改成ClientFactory?

{
public static ConcurrentDictionary<string, IManualDistributedCacheClient> CacheClients { get; set; } = new();

public IManualDistributedCacheClient GetCacheClient(IServiceProvider serviceProvider)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IHttpClientFactory用的时CreateClient,要对其它吗?

@wzh425 wzh425 marked this pull request as draft October 31, 2024 02:35
@wzh425 wzh425 marked this pull request as ready for review November 25, 2024 03:57
Comment on lines 58 to 66
if (!_connection.IsConnected && !_connection.IsConnecting)
{
return _connection.GetDatabase();
// Attempt to reconnect
var redisConfiguration = _redisConfigurationOptions.GetAvailableRedisOptions();
_connection = ConnectionMultiplexer.Connect(redisConfiguration);
Subscriber = _connection.GetSubscriber();
}

// Attempt to reconnect
var redisConfiguration = _redisConfigurationOptions.GetAvailableRedisOptions();
_connection = ConnectionMultiplexer.Connect(redisConfiguration);
Subscriber = _connection.GetSubscriber();

if (_connection.IsConnected || _connection.IsConnecting)
{
return _connection.GetDatabase();
}
else
if (!_connection.IsConnected && !_connection.IsConnecting)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个判断条件不是一样的吗?

@wzh425 wzh425 merged commit 433b3eb into main Nov 25, 2024
2 checks passed
@wzh425 wzh425 deleted the feature/distributed-cache branch November 25, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants