phpcachingmemcachedfat-free-framework

Unable to use Memcached in PHP Fat free framework


I have been trying to implement memcached in my application built in fat free framework. I have read that it should be explicitly defined as "memcached=192.168.--.---:11211" but no matter how I implement it, it uses "folder=tmp/cache/"

Tried and failed approaches


  1. config.ini
    CACHE="memcached=192.168.--.---:11211"

    index.php
    $f3->config('config/config.ini');
    $f3->run();

    code
    $cache = \Cache::instance();
    var_dump($cache);

    Output
    Object(Cache)#7 (3) {
    ["dsn":protected] => string(17)"folder=tmp/cache/"
    ["prefix":protected] => string(12)"randomString"
    ["ref":protected] => NULL
    }


  2. code
    $cache = \Cache::instance();
    $cache->load("memcached=192.168.--.---:11211");
    var_dump($cache);

    Output
    Object(Cache)#7 (3) {
    ["dsn":protected] => string(17)"folder=tmp/cache/"
    ["prefix":protected] => string(12)"randomString"
    ["ref":protected] => NULL
    }


  3. code
    $cache = new Cache("memcached=192.168.--.---:11211");
    var_dump($cache);

    Output
    Object(Cache)#7 (3) {
    ["dsn":protected] => string(17)"folder=tmp/cache/"
    ["prefix":protected] => string(12)"randomString"
    ["ref":protected] => NULL
    }


  4. index.php
    $f3->config('config/config.ini');
    $f3->set('CACHE',"memcached=192.168.--.---:11211");
    var_dump($f3->get('CACHE'));

    Output
    string(17)"folder=tmp/cache/"

What am I missing?


Solution

  • Do you have installed the proper php extension? Or is the connection secured? Because when there’s an error, the cache engine will just fall back to folder mode.