Campustream 1.0
A social network MQP for WPI
core/lib/memcachemanager.php
Go to the documentation of this file.
00001 <?php
00002 
00003 
00004 class MemcacheManager {
00005   
00006   private static $memcache = null;
00007   
00008   public static function connection() {
00009     if ( self::$memcache === null ) {
00010                 self::$memcache = new Memcached();
00011         self::$memcache->setOption( Memcached::OPT_LIBKETAMA_COMPATIBLE, true );
00012         self::$memcache->setOption( Memcached::OPT_BINARY_PROTOCOL, true );
00013                 self::$memcache->setOption( Memcached::OPT_CONNECT_TIMEOUT, 200 );
00014         
00015         require($GLOBALS['APPROOT'] . 'application/config/memcache.php');
00016         
00017         foreach($config as &$server) {
00018                         $server = array_merge($default, $server);
00019                 }
00020                 unset($server);
00021                 
00022         foreach( $config as $server ) {
00023                 self::$memcache->addServer( $server['host'], $server['port'], $server['weight'] );
00024         }
00025     }
00026     
00027     return self::$memcache;
00028   }
00029 
00030 }