When to use Redis instead of MySQL for PHP applications?

前端 未结 6 647
-上瘾入骨i
-上瘾入骨i 2021-01-31 01:06

I\'ve been looking at Redis. It looks very interesting. But from a practical perspective, in what cases would it be better to use Redis over MySQL?

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-31 01:47

    Redis, SQL (+NoSQL) have their benefits+drawbacks and often live side by side:

    • Redis - Local variables moved to a separate application
      • Easy to move from local variables/prototype
      • Persistant storrage
      • Multiple users/applications all see the same data
      • Scalability
      • Failover
      • (-) Hard to do more advanced queries/questions on the data
    • NoSQL
      • Dump raw data into the "database"
      • All/most of Redis features
      • (-) Harder to do advanced queries, compared to SQL
    • SQL
      • Advanced queries between data
      • All/most of Redis features
      • (-) Need to place data into "schema" (think sheet/Excel)
      • (-) Bit harder to get simple values in/out than Redis/NoSQL

    (different SQL/NoSQL solutions can vary. You should read up on CAP theorem and ACID on why one system can't simultaneously give you all)

提交回复
热议问题