Redis redis && Python start operating under windows

Redis redis && Python start operating under windows

premise:  

  • Download: https: //redis.io/download download the corresponding version and unpack redie
  • redis version: Redis 3.2.100 (00000000/0) 64 bit 

1. First Start redis-server.exe, double click or   cmd performed: redis-server.exe redis.windows.conf  

2. cmd open a new window, execution proceeds to the installation path of the redis: redis-cli.exe -h localhost -p 6379  

3. Test

  4. Perform Python code (Code Source: geeks time)

# ! / Usr / bin / env Python 
# - * - Coding: UTF-8 - * - 
# @author: Clover 
# @time: 2019/9/17 8: 

Import redis
 Import Time 

Print (redis. __FILE__ )
 # create redis connecting 
the pool redis.ConnectionPool = (Host = ' localhost ' , Port = 6379 ) 
R & lt = redis.StrictRedis (= connection_pool the pool)
 # records the current time 
TIME1 = the time.time ()
 # . 1 million times write 
for I in Range (10000 ) : 
    Data = { 'username ' : ' Clover ' , ' Age ' : ' 20 is ' } 
    r.hmset ( " Users " + STR (I), Data) 

# statistics writing time 
delta_time the time.time = () - TIME1
 Print (delta_time) 

# current statistics time 
TIME1 = the time.time ()
 # . 1 million times read 
for I   in Range (1000 ): 
    Result = r.hmget ( " Users " + STR (I), [ ' username ' , 'Age ' ]) 

# statistics reading time 
delta_time the time.time = () - TIME1
 Print (delta_time)

 result:

 

The following content from Time Geeks: SQL must know will be

 redis basics && commonly used commands

  1. redis full name: REmote DIctionary Server to store data dictionary structure that is key-value data types
  2. redis key belongs (key-value) database, key database uses a hash table storing key data and key as Mu qizhong unique identifier, and the key value can be any content
  3. Redis high query efficiency:
    1. Runtime dependent, the system level code when writing a high efficiency, low dependency, not much running with c language compatibility, high stability
    2. redis is a memory-based database, to avoid disk I / O, redis be called Cache Tool
    3. Simple data structures, the Redis manner using key-value store, which is operated using hash structure, operation complexity data is o (1)
    4. Single-threaded process model to avoid competition for resources and cause unnecessary context switching between threads
    5. Technically redis also uses a multi-channel I / O multiplexing, multiple herein refers to a plurality of network connection socket, a multiplexing means is multiplexed with a thread, a multi-I / O multiplexing techniques benefits can handle a plurality of I / O requests on the same thread, to minimize the network I / O trumpet, improve efficiency

  

  4.Redis data types: strings, hashes, lists, sets, ordered sets

String type is the most basic data type redis provided, such as red marking

A hash value   such as yellow and blue markers yellow marker represents a single blue for simultaneously setting a plurality of

 

 

字符串列表(list)的底层是一个双向链表结构,所以我们可以向列表的两端添加元素 时间复杂度都为O(1)

 

 

  字符串集合(set)是字符串类型的而无序集合,与列表(list)的区别在于集合中的元素是无序的,同时元素是不能重复的

 members  rem:remove   ismember

 

Guess you like

Origin www.cnblogs.com/eosclover/p/11531689.html