Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Redis vs Memcached: Picking Your Cache

Almost every backend system eventually needs a cache. A database that answers every read directly becomes the bottleneck sooner or later, so teams put a fast in-memory store in front of it. The two names that come up in that conversation are Redis and Memcached. Both are in-memory key value stores, both are fast, and both have been running in production for well over a decade. They are not…

Redis and Memcached are both in-memory key-value stores that have been in production for over a decade. However, they serve different purposes and have distinct features.

Memcached, created in 2003 for LiveJournal, is designed for simple caching of frequently read database rows. It stores opaque blobs under string keys, with no knowledge of the contents. Redis, introduced in 2009, is a more comprehensive data structure server that also excels as a cache. Redis supports various data types like strings, hashes, lists, sets, sorted sets, streams, and geospatial indexes. Its values have types, enabling operations like incrementing counters or adding set members atomically.

Redis offers persistence to disk, replication, and can function as a primary store for specific workloads. It also provides more control over eviction policies, allowing you to treat different types of data differently. Memcached, on the other hand, uses a slab allocator with LRU eviction inside each slab class and lacks advanced features like persistence, replication, and advanced eviction policies.

In terms of data structures, Redis offers a more diverse range of data types compared to Memcached's single data type of byte strings. This allows Redis to perform operations such as incrementing counters, updating specific fields in hashes, and maintaining leaderboards in sorted sets, all of which are more efficient and less prone to race conditions. Memcached, however, relies on client-side serialization and deserialization, which can be slower and more error-prone.

When it comes to scaling, Memcached uses consistent hashing on the client side to distribute keys across nodes. Redis, while simpler and faster in this regard, also supports clustering and replication, allowing for failover and redistribution of data when nodes are added or removed. This means Redis can handle larger workloads and provide higher availability than Memcached.

In summary, Memcached is best suited for simple caching needs, while Redis offers more advanced features and flexibility for a wider range of use cases. The choice between the two depends on the specific requirements of your application, such as the need for data structures, persistence, and advanced eviction policies.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

From Excel to a web-based business app: how to migrate without stopping the office

Almost every small office starts on Excel, and that is fine: it is fast, everyone knows it and it costs nothing. The trouble comes later, when there are ten spreadsheets, versions multiply and nobody…

  • Excel widely used for data management in small businesses
  • Complex data leads to confusion, multiple versions, inaccurate information
  • Transition requires understanding workflow, not just choosing a tool

Beyond the Announcement: Assessing the Deliverability of the U.S. Data Center Pipeline

If you build or run software that depends on compute, you have probably seen the headlines: hundreds of gigawatts of new capacity announced, each project bigger than the last.

  • Only about 5 GW of 16 GW targeted 2026 capacity was under construction in Feb 2026
  • Currence and DCMap datasets have different definitions and are not additive
  • Texas, Virginia, Pennsylvania, and Utah concentrate pipeline power due to state policies

More from Thursday 26 November →