From 4b85638ccfb58e41a5635e16ce0868e58bbc4759 Mon Sep 17 00:00:00 2001 From: lauripiisang Date: Mon, 15 Aug 2016 16:33:18 +0300 Subject: [PATCH 1/2] Add support for unprotected unix socket - You can now provide a unix socket based redis connection: - `Resque::setBackend('unix:///path/to/redis.sock')` - username/password/db in unix socket dsn currently unsupported: - This middle layer for Dsn parsing seemed too clunky for me to introduce user/pass/db parsing for unix sockets. --- lib/Resque/Redis.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Resque/Redis.php b/lib/Resque/Redis.php index e588ded..2805127 100644 --- a/lib/Resque/Redis.php +++ b/lib/Resque/Redis.php @@ -148,6 +148,7 @@ class Resque_Redis * - host:port * - redis://user:pass@host:port/db?option1=val1&option2=val2 * - tcp://user:pass@host:port/db?option1=val1&option2=val2 + * - unix:///path/to/redis.sock * * Note: the 'user' part of the DSN is not used. * @@ -161,6 +162,16 @@ class Resque_Redis // Use a sensible default for an empty DNS string $dsn = 'redis://' . self::DEFAULT_HOST; } + if(substr($dsn, 0, 7) === 'unix://') { + return array( + $dsn, + null, + null, + null, + null, + null, + ); + } $parts = parse_url($dsn); // Check the URI scheme From da9d780db1a016709728790054574632a333cb2b Mon Sep 17 00:00:00 2001 From: lauripiisang Date: Mon, 29 Aug 2016 18:17:04 +0300 Subject: [PATCH 2/2] Return `false` for 'database' section of unix DSNs This seems to be the expected default value --- lib/Resque/Redis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Resque/Redis.php b/lib/Resque/Redis.php index 2805127..5d78f6e 100644 --- a/lib/Resque/Redis.php +++ b/lib/Resque/Redis.php @@ -166,7 +166,7 @@ class Resque_Redis return array( $dsn, null, - null, + false, null, null, null,