Rails将支持MySQL的自动重连

很久前用MySQL开发的一个项目,服务器跑了一天后就莫名其妙挂掉了,重启后又恢复正常,后来将MySQL的驱动换成那个C版的貌似就没有出现过这个问题。Java的连接池属性都有一个配置是否检查该连接有效,并自动尝试重新连接的选项,Rails也即将支持这个配置选项了,只要在database.yml中加上 reconnect: true 就可以了,不过需要注意:

写道
Mysql#reconnect is set according to the 'reconnect' key in the connection spec.

The 'reconenct' boolean option is read from the connection specification
and is used to set the reconnect attribute of Mysql. The default is
false in order not to change existing application behaviour.

Also, reconnect is set AFTER real_connect is called, so its value sticks
(the mysql gem sets reconnect to false inside real_connect).
 

你可能感兴趣的:(C++,c,mysql,C#,Rails)