mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-12-11 08:56:59 +08:00
3cc6093e4b
Co-authored-by: -LAN- <laipz8200@outlook.com>
24 lines
723 B
Python
24 lines
723 B
Python
import redis
|
|
from redis.connection import Connection, SSLConnection
|
|
|
|
redis_client = redis.Redis()
|
|
|
|
|
|
def init_app(app):
|
|
connection_class = Connection
|
|
if app.config.get('REDIS_USE_SSL'):
|
|
connection_class = SSLConnection
|
|
|
|
redis_client.connection_pool = redis.ConnectionPool(**{
|
|
'host': app.config.get('REDIS_HOST'),
|
|
'port': app.config.get('REDIS_PORT'),
|
|
'username': app.config.get('REDIS_USERNAME'),
|
|
'password': app.config.get('REDIS_PASSWORD'),
|
|
'db': app.config.get('REDIS_DB'),
|
|
'encoding': 'utf-8',
|
|
'encoding_errors': 'strict',
|
|
'decode_responses': False
|
|
}, connection_class=connection_class)
|
|
|
|
app.extensions['redis'] = redis_client
|