You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.8 KiB

  1. # Copyright 2020 The Matrix.org Foundation C.I.C.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from synapse.config._base import Config
  15. from synapse.python_dependencies import check_requirements
  16. class RedisConfig(Config):
  17. section = "redis"
  18. def read_config(self, config, **kwargs):
  19. redis_config = config.get("redis") or {}
  20. self.redis_enabled = redis_config.get("enabled", False)
  21. if not self.redis_enabled:
  22. return
  23. check_requirements("redis")
  24. self.redis_host = redis_config.get("host", "localhost")
  25. self.redis_port = redis_config.get("port", 6379)
  26. self.redis_password = redis_config.get("password")
  27. def generate_config_section(self, config_dir_path, server_name, **kwargs):
  28. return """\
  29. # Configuration for Redis when using workers. This *must* be enabled when
  30. # using workers (unless using old style direct TCP configuration).
  31. #
  32. redis:
  33. # Uncomment the below to enable Redis support.
  34. #
  35. #enabled: true
  36. # Optional host and port to use to connect to redis. Defaults to
  37. # localhost and 6379
  38. #
  39. #host: localhost
  40. #port: 6379
  41. # Optional password if configured on the Redis instance
  42. #
  43. #password: <secret_password>
  44. """