2024-05-08 17:00:16 +02:00
|
|
|
<?php
|
2024-05-09 12:01:42 +02:00
|
|
|
/* memcached and php-memcached must be installed */
|
2024-05-08 17:00:16 +02:00
|
|
|
|
2024-05-11 12:39:35 +02:00
|
|
|
// Set to true to enable memcache
|
2024-05-08 17:00:16 +02:00
|
|
|
$enable_memcache = false;
|
|
|
|
|
|
|
|
// Server & port details
|
2024-05-11 12:39:35 +02:00
|
|
|
$memcache_server = '127.0.0.1';
|
|
|
|
$memcache_port = 11211;
|
|
|
|
|
2024-05-10 12:24:13 +02:00
|
|
|
// Log all hits (log file may be large)
|
2024-05-08 23:01:21 +02:00
|
|
|
$enable_memcache_logging = false;
|
|
|
|
|
|
|
|
// Time in seconds to cache data
|
|
|
|
$memcache_ttl = 14400;
|
|
|
|
|
2024-05-08 17:00:16 +02:00
|
|
|
/* PLEASE DO NOT EDIT BELOW THIS LINE */
|
2024-05-11 12:39:35 +02:00
|
|
|
if(!$enable_memcache) {
|
|
|
|
exit;
|
|
|
|
}
|
2024-05-08 17:00:16 +02:00
|
|
|
|
|
|
|
// Initiate a new object of memcache
|
|
|
|
$memcacheD = new Memcached();
|
2024-05-11 12:39:35 +02:00
|
|
|
|
2024-05-08 17:00:16 +02:00
|
|
|
// Add server
|
2024-05-11 12:39:35 +02:00
|
|
|
if ($memcacheD->addServer($memcache_server, $memcache_port)) {
|
|
|
|
if($enable_memcache_logging) {
|
|
|
|
file_put_contents($logdir . '/memcache.log', "\n".format_log_date() . ' Connected memcache ' .$memcache_server . ':' . $memcache_port, FILE_APPEND);
|
|
|
|
}
|
2024-05-08 17:00:16 +02:00
|
|
|
}
|
|
|
|
else {
|
2024-05-11 12:39:35 +02:00
|
|
|
file_put_contents($logdir . '/memcache.log', "\n".format_log_date() . ' Failed to connect memcache ' .$memcache_server . ':' . $memcache_port, FILE_APPEND);
|
2024-05-08 17:00:16 +02:00
|
|
|
}
|