/**
  * Extend a lock that was previously obtained with @lock.
  * @param lock $lock - a lock obtained from this factory.
  * @param int $maxlifetime - the new lifetime for the lock (in seconds).
  * @return boolean - true if the lock was extended.
  */
 public function extend_lock(lock $lock, $maxlifetime = 86400)
 {
     $now = time();
     $expires = $now + $maxlifetime;
     $params = array('expires' => $expires, 'token' => $lock->get_key());
     $sql = 'UPDATE {lock_db}
                 SET
                     expires = :expires,
                 WHERE
                     owner = :token';
     $this->db->execute($sql, $params);
     $countparams = array('owner' => $lock->get_key());
     $result = $this->count_records('lock_db', $countparams);
     return $result === 0;
 }