diff --git a/cache/stores/redis/addinstanceform.php b/cache/stores/redis/addinstanceform.php index cdd9ed653a3..e480918bcc4 100644 --- a/cache/stores/redis/addinstanceform.php +++ b/cache/stores/redis/addinstanceform.php @@ -43,6 +43,7 @@ class cachestore_redis_addinstance_form extends cachestore_addinstance_form { $form->setType('server', PARAM_TEXT); $form->addHelpButton('server', 'server', 'cachestore_redis'); $form->addRule('server', get_string('required'), 'required'); + $form->addElement('static', 'server_desc', '', get_string('server_desc', 'cachestore_redis')); $form->addElement('advcheckbox', 'encryption', get_string('encrypt_connection', 'cachestore_redis')); $form->setType('encryption', PARAM_BOOL); diff --git a/cache/stores/redis/lang/en/cachestore_redis.php b/cache/stores/redis/lang/en/cachestore_redis.php index 7b6cddb30c9..5d4fa37ef1e 100644 --- a/cache/stores/redis/lang/en/cachestore_redis.php +++ b/cache/stores/redis/lang/en/cachestore_redis.php @@ -42,12 +42,13 @@ $string['privacy:metadata:redis:data'] = 'The various data stored in the cache'; $string['serializer_igbinary'] = 'The igbinary serializer.'; $string['serializer_php'] = 'The default PHP serializer.'; $string['server'] = 'Server'; -$string['server_help'] = 'This sets the hostname or IP address of the Redis server to use.'; +$string['server_desc'] = 'For Unix socket usage, use the format /var/redis.sock or unix:///var/redis.sock'; +$string['server_help'] = 'This sets the hostname, IP address or Unix socket path of the Redis server to use.'; $string['password'] = 'Password'; $string['password_help'] = 'This sets the password of the Redis server.'; $string['task_ttl'] = 'Free up memory used by expired entries in Redis caches'; $string['test_server'] = 'Test server'; -$string['test_server_desc'] = 'Redis server to use for testing.'; +$string['test_server_desc'] = 'Redis server to use for testing.
For Unix socket usage, use the format /var/redis.sock or unix:///var/redis.sock'; $string['test_password'] = 'Test server password'; $string['test_password_desc'] = 'Redis test server password.'; $string['test_serializer'] = 'Serializer'; diff --git a/cache/stores/redis/lib.php b/cache/stores/redis/lib.php index 3c72c7d7e0e..3b3229302bb 100644 --- a/cache/stores/redis/lib.php +++ b/cache/stores/redis/lib.php @@ -217,7 +217,8 @@ class cachestore_redis extends cache_store implements cache_is_key_aware, cache_ // Check if it isn't a Unix socket to set default port. $port = null; $opts = []; - if ($server[0] === '/') { + // Unix sockets can start with / or with unix://. + if ($server[0] === '/' || strpos($server, 'unix://') === 0) { $port = 0; } else { $port = 6379; // No Unix socket so set default port.