redis单例数据库

 1 #redis单例连接
 2 '''
 3 redis-server redis_diy.conf
 4 '''
 5 import redis
 6 conn=redis.StrictRedis(host='192.168.160.135',port='6380',db=0,password='123456')#redis配置文件,db指定redis数据库的隔离区,有0-15共16个,默认为0
 7 print(conn.dbsize())
 8 print(conn.keys())
 9 conn.set('age',18)
10 print(conn.keys())
11 print(conn.get('name'))
12 print(conn.exists('name'))
redis单例数据库

相关文章:

  • 2021-12-17
  • 2021-04-10
  • 2021-11-29
猜你喜欢
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2021-11-09
相关资源
相似解决方案