示例#1
0
 /**
  * {@inheritdoc}
  */
 public function mSet(array $array)
 {
     $cachedValues = array();
     foreach ($array as $key => $value) {
         $entry = array('value' => $value, 'cached_at' => $this->time->current(), 'ttl' => $this->lifetime);
         $this->cache[$key] = $entry;
         $cachedValues[$key] = $value;
     }
     $this->redis->mSet($cachedValues);
 }
 /**
  * Tries to reactivate sleeping connections.
  *
  * @param int $since the amount of seconds that must have passed since the deactivation, default 2
  */
 public function reactivateSleepingConnections($since = 2)
 {
     // the following line is a safeguard against trying to reconnect instances which were just set to sleeping
     // this way we can deactivate a connection, call this method immediately after and still be sure that we
     // get a proper healthy connection from getHealthyConnection()
     $since = max(2, $since);
     $time = $this->timer->current();
     foreach ($this->connState as $key => $info) {
         if ($info['state'] == FailoverWrapper::CONNECTION_SLEEPING && $info['lastChange'] <= $time - $since) {
             $this->log->info(sprintf("Reactivating connection %s", $this->conns[$key]->getUniqueId()));
             $this->connState[$key]['state'] = FailoverWrapper::CONNECTION_HEALTHY;
             $this->connState[$key]['lastChange'] = $time;
         }
     }
 }