|
9 | 9 | define('ENABLE_REALPATH', function_exists('realpath_cache_size')); |
10 | 10 | define('ENABLE_MEMCACHE', extension_loaded('memcache') || extension_loaded('memcached')); |
11 | 11 |
|
| 12 | + // Memcache configuration |
| 13 | + define('MEMCACHE_HOST', getenv('MEMCACHE_HOST') ?: '127.0.0.1'); |
| 14 | + define('MEMCACHE_PORT', getenv('MEMCACHE_PORT') ?: 11211); |
| 15 | + define('MEMCACHE_USER', getenv('MEMCACHE_USER') ?: null); |
| 16 | + define('MEMCACHE_PASSWORD', getenv('MEMCACHE_PASSWORD') ?: null); |
| 17 | + |
12 | 18 | if (ENABLE_APC) { |
13 | 19 | if (!extension_loaded('apcu')) { |
14 | 20 | function apcu_cache_info($limited = false) { return apc_cache_info('user', $limited); } |
@@ -44,12 +50,15 @@ function __construct($search = null) { parent::__construct('user', $search); } |
44 | 50 | if (extension_loaded('memcached')) { |
45 | 51 | $memcache = new \Memcached(); |
46 | 52 | $memcacheVersion = 'memcached'; |
47 | | - $memcache->addServer('127.0.0.1', 11211); |
| 53 | + $memcache->addServer(MEMCACHE_HOST, MEMCACHE_PORT); |
| 54 | + if (!empty(MEMCACHE_USER) && !empty(MEMCACHE_PASSWORD)) |
| 55 | + $memcache->setSaslAuthData(MEMCACHE_USER, MEMCACHE_PASSWORD); |
48 | 56 | $memcache_stats = $memcache->getStats(); |
49 | 57 | } else if (extension_loaded('memcache')) { |
| 58 | + // This extension does not support SASL authentication |
50 | 59 | $memcache = new \Memcache(); |
51 | 60 | $memcacheVersion = 'memcache'; |
52 | | - $memcache->addServer('127.0.0.1', 11211); |
| 61 | + $memcache->addServer(MEMCACHE_HOST, MEMCACHE_PORT); |
53 | 62 | $memcache_stats = $memcache->getExtendedStats(); |
54 | 63 | } |
55 | 64 |
|
|
0 commit comments