rocksolid-light/Rocksolid_Light/rslight/memcached.inc.php

34 lines
925 B
PHP
Raw Normal View History

<?php
/* memcached and php-memcached must be installed */
// Set to true to enable memcache
$enable_memcache = false;
// Server & port details
$memcache_server = '127.0.0.1';
$memcache_port = 11211;
// 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;
/* PLEASE DO NOT EDIT BELOW THIS LINE */
if(!$enable_memcache) {
exit;
}
// Initiate a new object of memcache
$memcacheD = new Memcached();
// Add server
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);
}
}
else {
file_put_contents($logdir . '/memcache.log', "\n".format_log_date() . ' Failed to connect memcache ' .$memcache_server . ':' . $memcache_port, FILE_APPEND);
}