multithreading - memcache 和 redis 的内部工作方式有何不同

标签 multithreading caching memory-management redis memcached

redis 如何在内部执行以下功能。

  1. 内存管理: 我知道 memcache 使用固定大小和框架进行内存管理,并且 框架内固定大小的 slab。redis 内存管理有何不同?
  2. 为了逐出内存缓存使用 LRU。为此,每个内存缓存节点都有映射和双向链表。在读写操作中,两种数据结构都是使用全局锁访问的。 Redis 又是如何执行此操作的?由于 Redis 在单线程中不需要为这些数据结构锁定。

最佳答案

首先,我会建议您浏览 this post . 在该 stackoverflow 答案中,您可以看到第一点“内存管理”的答案以及许多其他详细信息。 休息一下你的第二点,我想告诉你,你可以检查 redis 的默认配置文件,从那里你可以管理不同的可用行为。

redis configuration file 中提到了这个片段:

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key according to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations

希望对您有所帮助。休息一下,如果我遗漏了什么,请告诉我最新情况。

关于multithreading - memcache 和 redis 的内部工作方式有何不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44945280/

相关文章:

java - 套接字多线程死锁

php - 如果未修改,使 PHP 页面返回 "304 Not Modified"

caching - 工作箱软件 : Runtime caching not working until second Reload

c++ - 如何使用 Loki 的小对象分配器?

memory-management - org.apache.spark.shuffle.MetadataFetchFailedException : Missing an output location for shuffle? 的可能原因是什么

c# - 线程的异步委托(delegate)

c++ - std::vector::clear()-ing 二维 vector 线程的内部 vector 是否安全?

使用分配的内存将整数复制到整数

java - 如果消息队列不为空,则始终运行处理线程

ruby-on-rails - Rails 4.2 迁移 postgres 更改不起作用