Elgg  Version 6.1
Memcached.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cache\Config;
4 
6 
13 class Memcached extends Config {
14 
23  public static function fromElggConfig(string $namespace, \Elgg\Config $config): ?self {
24 
25  if (!$config->memcache || empty($config->memcache_servers)) {
26  return null;
27  }
28 
29  $servers = [];
30  foreach ($config->memcache_servers as $server) {
31  $server_config = [
32  'host' => '127.0.0.1',
33  'port' => 11211,
34  'saslUser' => false,
35  'saslPassword' => false,
36  ];
37 
38  $servers[] = array_merge($server_config, $server);
39  }
40 
41  $opt_prefix = (string) $config->memcache_namespace_prefix;
42  $opt_prefix .= $namespace;
43 
44  return new self([
45  'servers' => $servers,
46  'useStaticItemCaching' => true,
47  'itemDetailedDate' => true,
48  'optPrefix' => $opt_prefix,
49  ]);
50  }
51 }
static fromElggConfig(string $namespace,\Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
Definition: Memcached.php:23
Configuration for memcache(d) fastcache driver.
Definition: Memcached.php:13
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
$servers
Memcache info.
Definition: memcache.php:5