Several features of Redis
1, Redis uses a single-threaded IO multiplexing model, which encapsulates a simple Aeevent event processing framework, mainly implements the Epoll, Kqueue and select, for only IO operation, single-threaded can be used to maximize the speed advantage, However, Redis also provides some simple computing functions, such as sorting, aggregation, etc., for these operations, the single-threaded model can actually seriously affect the overall throughput, CPU calculation process, the entire IO schedule is blocked.
2, Redis uses on-site memory to store data, and rarely use free-list and other ways to optimize memory allocation, there will be a certain degree of memory fragmentation, Redis and according to the storage command parameters, the data with the expiration time is stored separately, and call them temporary data, Non-temporary data is never removed, even if there is not enough physical memory, so that swap will not eliminate any non-temporal data (but will attempt to eliminate some temporary data), which is more appropriate for Redis as storage instead of the cache.
Memcached uses a pre-allocated pool of memory to manage memory using slab and chunk of different sizes, item selects the appropriate chunk storage based on size, the way memory pools can save the cost of requesting/freeing memory, and can reduce memory fragmentation, But this approach also leads to a degree of wasted space, and when memory is still large, new data may be removed;
3, Redis provides the function of the transaction, can guarantee the atomicity of a sequence of commands, the middle will not be interrupted by any action.
4, Redis In addition to Key/value, but also support list,set,sorted Set,hash and many other data structures, provided the keys for enumeration operations, but not online, if you need to enumerate the data on the line, Redis provides tools to scan its dump files, enumerate all the data, and Redis also provides features such as persistence and replication.
Redis and Mamcatch differences