Redis, from the Ground Up(2)
Key DisadvantagesRedis requires that the whole dataset be loaded into main memory at all times. (Redis Virtual Memory, which we’ll discuss later, relaxes this requirement, but still needs all keys to always be in memory.). Guaranteed in-memory access to most of the dataset is Redis' main performance driver — and is also responsible for creating its main limitations.
RAM
RAM is the gold of cloud computing. (Cloud servers are primarily priced based on the amount of available RAM. By comparison, disk and CPU are cheap.)
The amount of RAM that Redis needs is proportional to the size of the dataset. Large datasets in Redis are going to be fast, but expensive.
Persistence
Redis persistence is highly configurable but the implementation makes extremely heavy use of I/O resources. Furthermore, most save operations require additional memory to complete successfully, and, in some cases, asynchronous saves can block the server for lengthy periods of time. (These points are discussed in more detail, below; see thePersistence section.)
Memory Bloat
Redis' internal design typically trades off memory for speed. For some workloads, there can be an order of magnitude difference between the raw number of bytes handed off to Redis to store, and the amount of memory that Redis uses.
Diving In
String Keys
Regardless of the data type, the data is always identified by a key, and the key is always a string.
For example, using the string data type:
<div style="padding-top: 0.5em; padding-right: 1em; padding-bottom: 0.5em; padding-left: 1em; margin-bottom: 1em; font-family: monaco, monospace; line-height: 1.1em; background-color: #111111; color: #ffffff; font-size: 18px;" class="highlight"> redis> SET foo bar OK redis> GET foo "bar" redis> GET dne (nil)
页:
[1]