title: Right way to update Memcached value Yii2
body: <p>What is the right way to update my key/value when the database is updated ? First i am finding all of the boots but later i am adding 10 more boots. How should i update the value of my key/value pair when my <code>if statement</code> is <code>!result</code>. After the first time i will always have <code>true</code> there but the table data might be changed in that time. Red a lot of materials but didn't find the right way.</p>
  
  <pre><code>$mem = new \Memcached();
  $mem-&gt;addServer("localhost", 11211);
  
  $result = $mem-&gt;get("boots");
  
  if(!$result){
      $boots = Product::find()-&gt;where('active=1')-&gt;asArray()-&gt;all();
      $mem-&gt;set("boots", $boots);
  }
  
  $result = $mem-&gt;get("boots");
  var_dump($result);die;
  </code></pre>