configure multiple servers in Illuminate\ Cache\ MemcachedConnector
use addServer
to add to memcached. For more information, please see document
cat config/cache.php
public function get($key, $default = null)
{
//$this->store Illuminate\Cache\MemcachedStore
dump($this->store->getmemcached()->getstats());//config/cache.php memcached servers
$value = $this->store->get($key);
if (is_null($value))
{
$this->fireCacheEvent("missed", [$key]);
$value = value($default);
}
else
{
$this->fireCacheEvent("hit", [$key, $value]);
}
return $value;
}
cat bootstarp/app.php
$app["events"]->listen("cache.write",function($key, $value, $time) use ($app){
dump(app("cache")->store(),app("cache.store")->getStore()->getMemcached()->getstats());
});
Test
echo\ Cache::get ("test");
/ / call the function $this- > store- > getmemcached ()-> getstats () outputs the information of two servers ["127.0.0.1pur11221" = > [], "127.0.0.1Cache::get" = > [],
, how do you know which server to connect to when getting the test cache?