No Memcached servers added.


  • | 57 points

    In a Laravel 5.2 application, I cannot get Memcached to work.

    The initial error is the existence of the "Memcached" class. I then included memcached.php and now get "No Memcached servers added."


  • administrators
    | 123643 points

    @prestonwinfrey : Did you start Memcached server? (enable it on Menu/Services and Ports)


  • | 57 points

    Yes, the Memcached server is running.


  • administrators
    | 123643 points

    The problem is: Laravel supports only Memcached
    Developing PHP app with Memcached on Windows seems impossible because the PHP extension only support Memcache (note: without a d) on Windows

    However, Laragon solves the problem. Just put the code below to where you feel convenient and it should work (Tested)

    if (!class_exists('Memcached')) {
        include ("memcached.php");
    }
    

    For more details:
    https://sourceforge.net/p/laragon/tickets/6/


  • | 187 points

    If you want to have available memcached in all your projects in laragon put that code in a php file and include in your php.ini using:
    auto_prepend_file = "C:/your_path_of_choice/enable_memcached.php"
    and if you need flush, add functions edit emcached.php located at your_path_to_laragon\laragon\etc\php\pear\memcached.php and add this functions at the end

    public function flush($delay = 0) {
        $s = $this->writeSocket("flush_all");
        if ($s == true) {
            $this->resultCode = Memcached::RES_SUCCESS;
            $this->resultMessage = '';
            return true;
    
        } else {
            $this->resultCode = Memcached::RES_FAILURE;
            $this->resultMessage = 'Flush failed.';
            return false;
        }
    }
    
    public function add($key, $value, $minutes)
    {
        if(!$this->get($key)) {
            return $this->set($key, $value, $minutes);
        }
        return false;
    }

Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.