When to use Redis instead of MySQL for PHP applications?

前端 未结 6 651
-上瘾入骨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:54

    MySQL is a relational data store. If configured (e.g. using innodb tables), MySQL is a reliable data-store offering ACID transactions.

    Redis is a NoSQL database. It is faster (if used correctly) because it trades speed with reliability (it is rare to run with fsync as this dramatically hurts performance) and transactions (which can be approximated - slowly - with SETNX).

    Redis has some very neat features such as sets, lists and sorted lists.

    These slides on Redis list statistics gathering and session management as examples. There is also a twitter clone written with redis as an example, but that doesn't mean twitter use redis (twitter use MySQL with heavy memcache caching).

提交回复
热议问题