python redis和cache的区别

请教一下,python redis和cache的区别
最新回答
情不知所起

2024-06-01 10:15:56

简单区别: 
1. Redis中,并不是所有的数据都一直存储在内存中的,这是和Memcached相比一个最大的区别。 
2. Redis不仅仅支持简单的k/v类型的数据,同时还提供list,set,hash等数据结构的存储。 
3. Redis支持数据的备份,即master-slave模式的数据备份。 
4. Redis支持数据的持久化,可以将内存中的数据保持在磁盘中,重启的时候可以再次加载进行使用。

Redis在很多方面具备数据库的特征,或者说就是一个数据库系统,而Memcached只是简单的K/V缓存

下面是来自redis作者的说法(stackoverflow上面)。 
You should not care too much about performances. Redis is faster per core with small values, but memcached is able to use multiple cores with a single executable and TCP port without help from the client. Also memcached is faster with big values in the order of 100k. Redis recently improved a lot about big values (unstable branch) but still memcached is faster in this use case. The point here is: nor one or the other will likely going to be your bottleneck for the query-per-second they can deliver. 
You should care about memory usage. For simple key-value pairs memcached is more memory efficient