feat: add redis cluster support and redis_client is not none #4520
+43
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change add redis cluster support . redis-py should use latest version which has
redis.cluster
First, add variable in config to set redis cluster if enabled
Second, add variable to environment so that some class in util such as model_provider_cache.py can get a redis_client instance which not none, do not add to environment and init redis_client in
init_app(app)
with got such errorFile "/home/service/app/dify/api/core/helper/model_provider_cache.py", line 24, in get cached_provider_credentials = redis_client.get(self.cache_key) AttributeError: 'NoneType' object has no attribute 'get'
Fixes # (issue)
Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Set
REDIS_CLUSTER_ENABLED
inconfig
and create admin account successSuggested Checklist:
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods