prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Support unix socket Redis connections in parse_redis_connection
  ### As ...
  
  Isabella - Infrastructure Owner
  
  ### I want ...
  
  to be able to use Redis cache via a unix socket connection that than a TCP connection
  
  ### So that ...
  
  I can share sockets between docker containers rather than exposing ports (which is tricky to corporate environment)
  
  ### I know this is done when...
  
  - I am able to start and run Nautobot with configuration for a unix socket and the application fully functions
  
  ### Optional - Feature groups this request pertains to.
  
  - [ ] Automation
  - [ ] Circuits
  - [ ] DCIM
  - [ ] IPAM
  - [ ] Misc (including Data Sources)
  - [ ] Organization
  - [ ] Plugins (and other Extensibility)
  - [ ] Security (Secrets, etc)
  - [ ] Image Management
  - [ ] UI/UX
  - [ ] Documentation
  - [ ] Other (not directly a platform feature)
  
  ### Database Changes
  
  None
  
  ### External Dependencies
  
  None
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `nautobot/core/settings_funcs.py`
  Content:
  ```
  1 """Helper functions to detect settings after app initialization (AKA 'dynamic settings')."""
  2 
  3 from django.conf import settings
  4 from distutils.util import strtobool
  5 from functools import lru_cache
  6 import os
  7 
  8 
  9 #
  10 # X_auth_enabled checks to see if a backend has been specified, thus assuming it is enabled.
  11 # Leverages `lru_cache` since these are called per user session.  The wrappers are a
  12 # workaround to pass `lru_cache` a hashable data structure.
  13 #
  14 
  15 
  16 def remote_auth_enabled(auth_backends):
  17     return _remote_auth_enabled(tuple(auth_backends))
  18 
  19 
  20 @lru_cache(maxsize=5)
  21 def _remote_auth_enabled(auth_backends):
  22     return "nautobot.core.authentication.RemoteUserBackend" in auth_backends
  23 
  24 
  25 def sso_auth_enabled(auth_backends):
  26     return _sso_auth_enabled(tuple(auth_backends))
  27 
  28 
  29 @lru_cache(maxsize=5)
  30 def _sso_auth_enabled(auth_backends):
  31     for backend in auth_backends:
  32         if backend.startswith(settings.SOCIAL_AUTH_BACKEND_PREFIX):
  33             return True
  34     return False
  35 
  36 
  37 def ldap_auth_enabled(auth_backends):
  38     return _ldap_auth_enabled(tuple(auth_backends))
  39 
  40 
  41 @lru_cache(maxsize=5)
  42 def _ldap_auth_enabled(auth_backends):
  43     return "django_auth_ldap.backend.LDAPBackend" in auth_backends
  44 
  45 
  46 def is_truthy(arg):
  47     """
  48     Convert "truthy" strings into Booleans.
  49 
  50     Examples:
  51         >>> is_truthy('yes')
  52         True
  53 
  54     Args:
  55         arg (str): Truthy string (True values are y, yes, t, true, on and 1; false values are n, no,
  56         f, false, off and 0. Raises ValueError if val is anything else.
  57     """
  58     if isinstance(arg, bool):
  59         return arg
  60     return bool(strtobool(str(arg)))
  61 
  62 
  63 def parse_redis_connection(redis_database):
  64     """
  65     Parse environment variables to emit a Redis connection URL.
  66 
  67     Args:
  68         redis_database (int): Redis database number to use for the connection
  69 
  70     Returns:
  71         Redis connection URL (str)
  72     """
  73     # The following `_redis_*` variables are used to generate settings based on
  74     # environment variables.
  75     redis_scheme = "rediss" if is_truthy(os.getenv("NAUTOBOT_REDIS_SSL", "false")) else "redis"
  76     redis_host = os.getenv("NAUTOBOT_REDIS_HOST", "localhost")
  77     redis_port = int(os.getenv("NAUTOBOT_REDIS_PORT", "6379"))
  78     redis_username = os.getenv("NAUTOBOT_REDIS_USERNAME", "")
  79     redis_password = os.getenv("NAUTOBOT_REDIS_PASSWORD", "")
  80 
  81     # Default Redis credentials to being empty unless a username or password is
  82     # provided. Then map it to "username:password@". We're not URL-encoding the
  83     # password because the Redis Python client already does this.
  84     redis_creds = ""
  85     if redis_username or redis_password:
  86         redis_creds = f"{redis_username}:{redis_password}@"
  87 
  88     return f"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}"
  89
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/nautobot/core/settings_funcs.py b/nautobot/core/settings_funcs.py
  --- a/nautobot/core/settings_funcs.py
  +++ b/nautobot/core/settings_funcs.py
  @@ -72,7 +72,9 @@
       """
       # The following `_redis_*` variables are used to generate settings based on
       # environment variables.
  -    redis_scheme = "rediss" if is_truthy(os.getenv("NAUTOBOT_REDIS_SSL", "false")) else "redis"
  +    redis_scheme = os.getenv("NAUTOBOT_REDIS_SCHEME")
  +    if redis_scheme is None:
  +        redis_scheme = "rediss" if is_truthy(os.getenv("NAUTOBOT_REDIS_SSL", "false")) else "redis"
       redis_host = os.getenv("NAUTOBOT_REDIS_HOST", "localhost")
       redis_port = int(os.getenv("NAUTOBOT_REDIS_PORT", "6379"))
       redis_username = os.getenv("NAUTOBOT_REDIS_USERNAME", "")
  @@ -85,4 +87,7 @@
       if redis_username or redis_password:
           redis_creds = f"{redis_username}:{redis_password}@"
   
  -    return f"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}"
  +    if redis_scheme == "unix":
  +        return f"{redis_scheme}://{redis_creds}{redis_host}?db={redis_database}"
  +    else:
  +        return f"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}"
  
verification_info: {"golden_diff": "diff --git a/nautobot/core/settings_funcs.py b/nautobot/core/settings_funcs.py\n--- a/nautobot/core/settings_funcs.py\n+++ b/nautobot/core/settings_funcs.py\n@@ -72,7 +72,9 @@\n     \"\"\"\n     # The following `_redis_*` variables are used to generate settings based on\n     # environment variables.\n-    redis_scheme = \"rediss\" if is_truthy(os.getenv(\"NAUTOBOT_REDIS_SSL\", \"false\")) else \"redis\"\n+    redis_scheme = os.getenv(\"NAUTOBOT_REDIS_SCHEME\")\n+    if redis_scheme is None:\n+        redis_scheme = \"rediss\" if is_truthy(os.getenv(\"NAUTOBOT_REDIS_SSL\", \"false\")) else \"redis\"\n     redis_host = os.getenv(\"NAUTOBOT_REDIS_HOST\", \"localhost\")\n     redis_port = int(os.getenv(\"NAUTOBOT_REDIS_PORT\", \"6379\"))\n     redis_username = os.getenv(\"NAUTOBOT_REDIS_USERNAME\", \"\")\n@@ -85,4 +87,7 @@\n     if redis_username or redis_password:\n         redis_creds = f\"{redis_username}:{redis_password}@\"\n \n-    return f\"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}\"\n+    if redis_scheme == \"unix\":\n+        return f\"{redis_scheme}://{redis_creds}{redis_host}?db={redis_database}\"\n+    else:\n+        return f\"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}\"\n", "issue": "Support unix socket Redis connections in parse_redis_connection\n### As ...\n\nIsabella - Infrastructure Owner\n\n### I want ...\n\nto be able to use Redis cache via a unix socket connection that than a TCP connection\n\n### So that ...\n\nI can share sockets between docker containers rather than exposing ports (which is tricky to corporate environment)\n\n### I know this is done when...\n\n- I am able to start and run Nautobot with configuration for a unix socket and the application fully functions\n\n### Optional - Feature groups this request pertains to.\n\n- [ ] Automation\n- [ ] Circuits\n- [ ] DCIM\n- [ ] IPAM\n- [ ] Misc (including Data Sources)\n- [ ] Organization\n- [ ] Plugins (and other Extensibility)\n- [ ] Security (Secrets, etc)\n- [ ] Image Management\n- [ ] UI/UX\n- [ ] Documentation\n- [ ] Other (not directly a platform feature)\n\n### Database Changes\n\nNone\n\n### External Dependencies\n\nNone\n", "before_files": [{"content": "\"\"\"Helper functions to detect settings after app initialization (AKA 'dynamic settings').\"\"\"\n\nfrom django.conf import settings\nfrom distutils.util import strtobool\nfrom functools import lru_cache\nimport os\n\n\n#\n# X_auth_enabled checks to see if a backend has been specified, thus assuming it is enabled.\n# Leverages `lru_cache` since these are called per user session.  The wrappers are a\n# workaround to pass `lru_cache` a hashable data structure.\n#\n\n\ndef remote_auth_enabled(auth_backends):\n    return _remote_auth_enabled(tuple(auth_backends))\n\n\n@lru_cache(maxsize=5)\ndef _remote_auth_enabled(auth_backends):\n    return \"nautobot.core.authentication.RemoteUserBackend\" in auth_backends\n\n\ndef sso_auth_enabled(auth_backends):\n    return _sso_auth_enabled(tuple(auth_backends))\n\n\n@lru_cache(maxsize=5)\ndef _sso_auth_enabled(auth_backends):\n    for backend in auth_backends:\n        if backend.startswith(settings.SOCIAL_AUTH_BACKEND_PREFIX):\n            return True\n    return False\n\n\ndef ldap_auth_enabled(auth_backends):\n    return _ldap_auth_enabled(tuple(auth_backends))\n\n\n@lru_cache(maxsize=5)\ndef _ldap_auth_enabled(auth_backends):\n    return \"django_auth_ldap.backend.LDAPBackend\" in auth_backends\n\n\ndef is_truthy(arg):\n    \"\"\"\n    Convert \"truthy\" strings into Booleans.\n\n    Examples:\n        >>> is_truthy('yes')\n        True\n\n    Args:\n        arg (str): Truthy string (True values are y, yes, t, true, on and 1; false values are n, no,\n        f, false, off and 0. Raises ValueError if val is anything else.\n    \"\"\"\n    if isinstance(arg, bool):\n        return arg\n    return bool(strtobool(str(arg)))\n\n\ndef parse_redis_connection(redis_database):\n    \"\"\"\n    Parse environment variables to emit a Redis connection URL.\n\n    Args:\n        redis_database (int): Redis database number to use for the connection\n\n    Returns:\n        Redis connection URL (str)\n    \"\"\"\n    # The following `_redis_*` variables are used to generate settings based on\n    # environment variables.\n    redis_scheme = \"rediss\" if is_truthy(os.getenv(\"NAUTOBOT_REDIS_SSL\", \"false\")) else \"redis\"\n    redis_host = os.getenv(\"NAUTOBOT_REDIS_HOST\", \"localhost\")\n    redis_port = int(os.getenv(\"NAUTOBOT_REDIS_PORT\", \"6379\"))\n    redis_username = os.getenv(\"NAUTOBOT_REDIS_USERNAME\", \"\")\n    redis_password = os.getenv(\"NAUTOBOT_REDIS_PASSWORD\", \"\")\n\n    # Default Redis credentials to being empty unless a username or password is\n    # provided. Then map it to \"username:password@\". We're not URL-encoding the\n    # password because the Redis Python client already does this.\n    redis_creds = \"\"\n    if redis_username or redis_password:\n        redis_creds = f\"{redis_username}:{redis_password}@\"\n\n    return f\"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}\"\n", "path": "nautobot/core/settings_funcs.py"}], "after_files": [{"content": "\"\"\"Helper functions to detect settings after app initialization (AKA 'dynamic settings').\"\"\"\n\nfrom django.conf import settings\nfrom distutils.util import strtobool\nfrom functools import lru_cache\nimport os\n\n\n#\n# X_auth_enabled checks to see if a backend has been specified, thus assuming it is enabled.\n# Leverages `lru_cache` since these are called per user session.  The wrappers are a\n# workaround to pass `lru_cache` a hashable data structure.\n#\n\n\ndef remote_auth_enabled(auth_backends):\n    return _remote_auth_enabled(tuple(auth_backends))\n\n\n@lru_cache(maxsize=5)\ndef _remote_auth_enabled(auth_backends):\n    return \"nautobot.core.authentication.RemoteUserBackend\" in auth_backends\n\n\ndef sso_auth_enabled(auth_backends):\n    return _sso_auth_enabled(tuple(auth_backends))\n\n\n@lru_cache(maxsize=5)\ndef _sso_auth_enabled(auth_backends):\n    for backend in auth_backends:\n        if backend.startswith(settings.SOCIAL_AUTH_BACKEND_PREFIX):\n            return True\n    return False\n\n\ndef ldap_auth_enabled(auth_backends):\n    return _ldap_auth_enabled(tuple(auth_backends))\n\n\n@lru_cache(maxsize=5)\ndef _ldap_auth_enabled(auth_backends):\n    return \"django_auth_ldap.backend.LDAPBackend\" in auth_backends\n\n\ndef is_truthy(arg):\n    \"\"\"\n    Convert \"truthy\" strings into Booleans.\n\n    Examples:\n        >>> is_truthy('yes')\n        True\n\n    Args:\n        arg (str): Truthy string (True values are y, yes, t, true, on and 1; false values are n, no,\n        f, false, off and 0. Raises ValueError if val is anything else.\n    \"\"\"\n    if isinstance(arg, bool):\n        return arg\n    return bool(strtobool(str(arg)))\n\n\ndef parse_redis_connection(redis_database):\n    \"\"\"\n    Parse environment variables to emit a Redis connection URL.\n\n    Args:\n        redis_database (int): Redis database number to use for the connection\n\n    Returns:\n        Redis connection URL (str)\n    \"\"\"\n    # The following `_redis_*` variables are used to generate settings based on\n    # environment variables.\n    redis_scheme = os.getenv(\"NAUTOBOT_REDIS_SCHEME\")\n    if redis_scheme is None:\n        redis_scheme = \"rediss\" if is_truthy(os.getenv(\"NAUTOBOT_REDIS_SSL\", \"false\")) else \"redis\"\n    redis_host = os.getenv(\"NAUTOBOT_REDIS_HOST\", \"localhost\")\n    redis_port = int(os.getenv(\"NAUTOBOT_REDIS_PORT\", \"6379\"))\n    redis_username = os.getenv(\"NAUTOBOT_REDIS_USERNAME\", \"\")\n    redis_password = os.getenv(\"NAUTOBOT_REDIS_PASSWORD\", \"\")\n\n    # Default Redis credentials to being empty unless a username or password is\n    # provided. Then map it to \"username:password@\". We're not URL-encoding the\n    # password because the Redis Python client already does this.\n    redis_creds = \"\"\n    if redis_username or redis_password:\n        redis_creds = f\"{redis_username}:{redis_password}@\"\n\n    if redis_scheme == \"unix\":\n        return f\"{redis_scheme}://{redis_creds}{redis_host}?db={redis_database}\"\n    else:\n        return f\"{redis_scheme}://{redis_creds}{redis_host}:{redis_port}/{redis_database}\"\n", "path": "nautobot/core/settings_funcs.py"}]}