Skip to content
Snippets Groups Projects
memcache.php 394 B
Newer Older
Thomas Flori's avatar
Thomas Flori committed
<?php

// before
//function getMemcache() {
//    static $memcache;
//    if (!$memcache) {
//        $memcache = new Memcached();
//        $memcache->addServer('localhost', 11211);
//    }
//    return $memcache;
//}

// now

use DependencyInjector\DI;

DI::set('memcache', function() {
    $memcache = new Memcached();
    $memcache->addServer('localhost', 11211);
    return $memcache;
});