admin 管理员组文章数量: 887032
2024年1月17日发(作者:scrapy如何使用)
unsigned long client_flag = 0; /*A MYSQL* connection handler if the connection was successful, NULL if the connection was unsuccessful. For a successful connection, the return value is the same as the value of the first parameter.*/ if (mysql_real_connect(&m_mysql, host, user, passwd, db, port, unix_socket, client_flag)) { printf("The connection was successful.n"); return true; } else { printf("Error connecting to database:%sn", mysql_error(&m_mysql)); return false; }}void DBHandle::FreeMysqlConnect(){ mysql_free_result(res); mysql_close(&m_mysql);}bool DBHandle::insertDataToMysql(string strData){ char szQuery[256] = {0}; sprintf_s(szQuery, "insert into a_test (type) values ('%s');", strData.c_str()); if (mysql_query(&m_mysql, szQuery)) { printf("Query failed (%s)n", mysql_error(&m_mysql)); return false; } else { printf("Insert successn"); return true; }} 测试结果:
2.写redis->写mysql,读Redis->未找到->读Mysql
版权声明:本文标题:数据库应用之--Redis+mysql实现大量数据的读写,以及高并发 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1705491333h487000.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论