Redis基础
- docker attach 3ba4
- apt-get install redis-server
- 启动: /etc/init.d/redis-server restart
- 退出:exit
- 查看是否能ping通: redis-cli -h 127.0.0.1 -o 6379
Redis命令
- redis-cli -h 127.0.0.1 p 6379
- set hello 123456789 #以key-value 方式存储
- get hello
- strlen hello
- 批量设置: mset a 199 b450 c hello
- 批量获取: mget a c
- 哈希存储法: key-filed-value
- hset title name hello
- hget title name
- hset title sex boy
- hget title sex
- 批量设置: hmset title name abc id 890 sex boy
- key:title filed:name id sex value:abc 890 boy
- hget title id
- hgetall title
- hset url 123.com 1
- hget url 123.com #判断是否为1还是0
import redis
import pymysql
rconn = redis.Redis("172.17.0.8", "6379")
for i in range(100):
rconn.hget('url', str(i))
rconn.hset('url'. str(i), '1')
url = "http://www.baidu"+str(i)+".com"