Redis的两种连接方式
生活随笔
收集整理的这篇文章主要介绍了
Redis的两种连接方式
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
1.简单连接
import redis conn = redis.Redis(host='207.148.120.229', port=6379) conn.set('foo', 'Bar') print(conn.get('foo')) a = input('按任意键结束')
2.使用连接池
import redis pool = redis.ConnectionPool(host='207.148.120.229',port=6379) conn = redis.Redis(connection_pool=pool)conn.set('key', 'Hello World') print(conn.get('key')) a = input('按任意键结束')
转载于:https://www.cnblogs.com/sea-stream/p/10295540.html
总结
以上是生活随笔为你收集整理的Redis的两种连接方式的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Ajax+Python flask实现上
- 下一篇: MySQL.分页 慢日志查询