search

Home  >  Q&A  >  body text

redis和memcached是不是存储多少空间就占多少内存?

这些内存数据库都是把数据放到内存里,作为缓存的话,是不是存储多少内容就占用多少内存呢?

比如我的Linux服务器是2G内存的,那使用他们作为缓存数据库,就不能缓存超过2G的内容呢?

ringa_leeringa_lee2819 days ago922

reply all(2)I'll reply

  • 某草草

    某草草2017-04-27 09:04:23

    It’s not about how much memory you save.

    memcached’s caching mechanism
    memcached uses the Slab Allocation memory allocation mechanism. You can read this article Memcached’s data storage method
    This mechanism has a disadvantage. It divides the allocated memory into chunks (chuck) of a specific length, such as : Storing 70-byte data into 88-byte blocks results in a waste of 18 bytes

    Memory allocation process

    Redis will be added if needed or later.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-04-27 09:04:23

    Yes. Because they are memory-based databases.

    Although it can be transformed to use the disk to cache part of the data, doing so will lose its own meaning.

    reply
    0
  • Cancelreply