How safe is it to store sessions with Redis?

后端 未结 3 1843
盖世英雄少女心
盖世英雄少女心 2020-12-12 09:37

I\'m currently using MySql to store my sessions. It works great, but it is a bit slow.

I\'ve been asked to use Redis, but I\'m wondering if it is a good idea because

3条回答
  •  盖世英雄少女心
    2020-12-12 09:49

    This question is really about real-time sessions, and seems to have arisen partly due to a misunderstanding of the phrase 'delayed write operations' While the details were eventually teased out in the comments, I just wanted to make it super-duper clear...

    You will have no problems implementing real-time sessions.

    Redis is an in-memory key-value store with optional persistence to disk. 'Delayed write operations' refers to writes to disk, not the database in general, which exists in memory. If you SET a key/value pair, you can GET it immediately (i.e in real-time). The policy you select with regards to persistence (how much you delay the writes) will determine the upper-bound for how much data could be lost in a crash.

提交回复
热议问题