redis non-relational databases

redis type of data stored on the disk inside, so the store faster, or other types of data stored in a database so more slowly

Redis database link:

When r = redis.Redis (host = "%%%%%%%", password = "HK139bc & *", db = 10, decode_responses = True) # port = 6379 default can not write db not write, the default is 0 decode_responses = True: If you do not need to be binary decode time

A string type

1, is written to the redis

r.set("key","value")

2, the data acquired in redis

r.get("key")

3, delete data

r.delete("key")

4, increase the time to failure

r.set ( "key", "yj", 10) # ( "key", "yj") key, values ​​statement to add data pattern # 10 represents the expiration date, if it is -1, which means permanent expiring (but after restart expire)

If the increased key, increase the time to failure

r.expire("key",10)

Second, the type of hash

1, is written to the redis

r.hset("name","wyj",'{"cat":"1","small":"2"}')   #大key + key +value

2, the data acquired in redis

r.hget("大key",”key“)

3, delete data

r.hdel("大key",”key“)

Third, Spoken

r.keys () # Get all of the key

r.type () # get the key type

r.flushall () # Empty all contents of all databases

r.flushdb () # clear the current data inside the database

r.exists ( "" key) # key to determine whether there is

Guess you like

Origin www.cnblogs.com/wangyajuanjuan/p/11795964.html