Hi All,
A simple question, I use nodejs for HTTP restful API service. Now I want
query some mysql data before http server start, the code snippet:
var price = -1; var userId = 'some user provided value'; var sql = 'SELECT
max(price) FROM users WHERE id = ' + connection.escape(userId);
connection.query(sql, function(err, results) {
price = results.price; });
server = http.createServer(function (request, response) {
handler(request); //response depend on price}).listen(8012);
Here are two solution to combine mysql query and http server code.
1. put http server in query callback. Will it cause Mysql keep connect
during http server running? If Mysql disconnect (usually after 8 hours),
application works fine?
2. put query in every request, which cause Mysql query each time for every
request, maybe performance issue.
Any other suggestion for this situation?
Thanks,
Linbo
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.