UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Q+EEW6BuZKPffqfMx6Yb7A960lIcpv1q8+BH1egA+Mc=' 
WHERE 
  key_id = 'b11e8986263daed5a9896b50ad34b6a19ec76185339feebf09a6de2e13878811' 
  AND (
    token = 'Q+EEW6BuZKPffqfMx6Yb7A960lIcpv1q8+BH1egA+Mc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044