Which server is laravel memcached connected to?

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?

Aug.12,2021

The memcached client used by

laravel is php-memcached this client is implemented in C, and the underlying layer encapsulates libmemcached .

We can directly look at how the C source code obtains the value on a server. After searching, the get source code is implemented in the file libmemcached/get.c as follows:

  

if the client does not provide it, there is no way to know. After passing key through hash, memcached selects instances with parameters such as weight, and the hash functions of different clients may be different. I don't know why you need to know which instance it comes from

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e47c7f-44c75.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e47c7f-44c75.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?