set() публичный Метод

Sets data for a key with a timeout.
public set ( string $key, mixed $value, integer $timeout = null ) : boolean
$key string
$value mixed
$timeout integer
Результат boolean
Пример #1
0
 public function saveLatency()
 {
     $lastLatency = $this->distributedCache->get('core/latency');
     $max = 20;
     $change = false;
     foreach (array('frontend', 'backend', 'cache', 'session') as $key) {
         if (!isset($this->latency[$key]) || !$this->latency[$key]) {
             continue;
         }
         $this->latency[$key] = array_sum($this->latency[$key]) / count($this->latency[$key]);
         $lastLatency[$key] = (array) @$lastLatency[$key] ?: array();
         array_unshift($lastLatency[$key], @$this->latency[$key]);
         if ($max < count($lastLatency[$key])) {
             array_splice($lastLatency[$key], $max);
         }
         $change = true;
     }
     if ($change) {
         $this->latency = array();
         $this->distributedCache->set('core/latency', $lastLatency);
     }
 }