From 479dd80a8c0a971e5fc5db8679f3677205e44109 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 5 Mar 2016 09:47:24 +0000 Subject: [PATCH] Made memcached config allow mulitple servers --- .env.example | 13 +++++++------ config/cache.php | 21 ++++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index 9d42d7487..5661cda22 100644 --- a/.env.example +++ b/.env.example @@ -17,6 +17,12 @@ SESSION_DRIVER=file #SESSION_DRIVER=memcached QUEUE_DRIVER=sync +# Memcached settings +# If using a UNIX socket path for the host, set the port to 0 +# This follows the following format: HOST:PORT:WEIGHT +# For multiple servers separate with a comma +MEMCACHED_SERVERS=127.0.0.1:11211:100 + # Storage STORAGE_TYPE=local # Amazon S3 Config @@ -56,9 +62,4 @@ MAIL_HOST=localhost MAIL_PORT=1025 MAIL_USERNAME=null MAIL_PASSWORD=null -MAIL_ENCRYPTION=null - -# Memcached settings -#MEMCACHED_HOST=127.0.0.1 -# If using a UNIX socket path for the host, set the port to 0 -#MEMCACHED_PORT=11211 \ No newline at end of file +MAIL_ENCRYPTION=null \ No newline at end of file diff --git a/config/cache.php b/config/cache.php index b00a9989e..076a0299f 100644 --- a/config/cache.php +++ b/config/cache.php @@ -1,5 +1,18 @@ $memcachedServer) { + $memcachedServerDetails = explode(':', $memcachedServer); + $components = count($memcachedServerDetails); + if ($components < 2) $memcachedServerDetails[] = '11211'; + if ($components < 3) $memcachedServerDetails[] = '100'; + $memcachedServers[$index] = array_combine($memcachedServerKeys, $memcachedServerDetails); + } +} + return [ /* @@ -49,13 +62,7 @@ return [ 'memcached' => [ 'driver' => 'memcached', - 'servers' => [ - [ - 'host' => env('MEMCACHED_HOST', '127.0.0.1'), - 'port' => env('MEMCACHED_PORT', 11211), - 'weight' => 100, - ], - ], + 'servers' => env('CACHE_DRIVER') === 'memcached' ? $memcachedServers : [], ], 'redis' => [