当前位置:Gxlcms > 数据库问题 > redis缓存数据库

redis缓存数据库

时间:2021-07-01 10:21:17 帮助过:14人阅读

redis pool = redis.ConnectionPool(host=192.168.14.35, port=6379,password="Alex3714" ,db=1) r = redis.Redis(connection_pool=pool) pub = r.pubsub() #打开收音机 pub.subscribe("fm87.7") #调台 pub.parse_response() #准备接收 print("准备监听...") data = pub.parse_response() #正式接收 print(data)

 发布:

import redis
pool =  redis.ConnectionPool(host=192.168.14.35, port=6379,password="Alex3714" ,db=1)
r = redis.Redis(connection_pool=pool)

r.publish("fm87.7", "big SB!")

 

什么时候用关系型数据库,什么时候 用NoSQL?

Go for legacy relational databases (RDBMS) when:

  1. The data is well structured, and lends itself to a tabular arrangement (rows and columns) in a relational database. Typical examples: bank account info, customer order info, customer info, employee info, department info etc etc.
  2. Another aspect of the above point is : schema oriented data model. When you design a data model (tables, relationships etc) for a potential use of RDBMS, you need to come up with a well defined schema: there will be these many tables, each table having a known set of columns that store data in known typed format (CHAR, NUMBER, BLOB etc).
  3. Very Important: Consider whether the data is transactional in nature. In other words, whether the data will be stored, accessed and updated in the context of transactions providing the ACID semantics or is it okay to compromise some/all of these properties.
  4. Correctness is also important and any compromise is _unacceptable_. This stems from the fact that in most NoSQL databases, consistency is traded off in favor of performance and scalability (points on NoSQL databases are elaborated below).
  5. There is no strong/compelling need for a scale out architecture ; a database that linearly scales out (horizontal scaling) to multiple nodes in a cluster.
  6. The use case is not for “high speed data ingestion”.
  7. If the client applications are expecting to quickly stream large amounts of data in/out of the database then relational database may not be a good choice since they are not really designed for scaling write heavy workloads.
  8. In order to achieve ACID properties, lots of additional background work is done especially in writer (INSERT, UPDATE, DELETE) code paths. This definitely affects performance.
  9. The use case is not for “storing enormous amounts of data in the range of petabytes”.

 

Go for NoSQL databases when:

  1. There is no fixed (and predetermined) schema that data fits in:
  2. Scalability, Performance (high throughput and low operation latency), Continuous Availability are very important requirements to be met by the underlying architecture of database.
  3. Good choice for “High Speed Data Ingestion”. Such applications (for example IoT style) which generate millions of data points in a second and need a database capable of providing extreme write scalability.
  4. The inherent ability to horizontally scale allows to store large amounts of data across commodity servers in the cluster. They usually use low cost resources, and are able to linearly add compute and storage power as the demand grows.

source page https://www.quora.com/When-should-you-use-NoSQL-vs-regular-RDBMS 

 

     

redis缓存数据库

标签:tle   命令   ica   存储   api   就会   cond   another   body   

人气教程排行