DEV Community

Cover image for Redis license change, and Rails Solid Cache
Franklin Yu
Franklin Yu

Posted on

Redis license change, and Rails Solid Cache

Redis switched the license of the main repository from BSD to dual license of SSPLv1 + RSALv2 in March. This was reported by The Register, and got heavily discussed on Hacker News. The GitHub pull request also received many comments:

The comments mentioned several alternatives, including forks, and some competitors. Among those is a wire-format-compatible implementation from Microsoft:

GitHub logo microsoft / garnet

Garnet is a remote cache-store from Microsoft Research that offers strong performance (throughput and latency), scalability, storage, recovery, cluster sharding, key migration, and replication features. Garnet can work with existing Redis clients.

Garnet

.NET CI Discord Shield

Garnet is a new remote cache-store from Microsoft Research, that offers several unique benefits:

  • Garnet adopts the popular RESP wire protocol as a starting point, which makes it possible to use Garnet from unmodified Redis clients available in most programming languages of today, such as StackExchange.Redis in C#.
  • Garnet offers much better throughput and scalability with many client connections and small batches, relative to comparable open-source cache-stores, leading to cost savings for large apps and services.
  • Garnet demonstrates extremely low client latencies (often less than 300 microseconds at the 99.9th percentile) using commodity cloud (Azure) VMs with Accelerated Networking enabled, which is critical to real-world scenarios.
  • Based on the latest .NET technology, Garnet is cross-platform, extensible, and modern. It is designed to be easy to develop for and evolve, without sacrificing performance in the common case. We leveraged the rich library ecosystem of .NET for API breadth, with open…

Coincidentally, the Rails team planned their next release earlier this year, where they intended to provide Solid Cache, a cache store backed by a SQL database, as an alternative to Redis-based cache store:

GitHub logo rails / solid_cache

A database-backed ActiveSupport::Cache::Store

Solid Cache

Upgrading from v0.3.0 or earlier? Please see upgrading to version v0.4.x and beyond

Solid Cache is a database-backed Active Support cache store implementation.

Using SQL databases backed by SSDs we can have caches that are much larger and cheaper than traditional memory only Redis or Memcached backed caches.

Usage

To set Solid Cache as your Rails cache, you should add this to your environment config:

config.cache_store = :solid_cache_store
Enter fullscreen mode Exit fullscreen mode

Solid Cache is a FIFO (first in, first out) cache. While this is not as efficient as an LRU cache, this is mitigated by the longer cache lifespan.

A FIFO cache is much easier to manage:

  1. We don't need to track when items are read
  2. We can estimate and control the cache size by comparing the maximum and minimum IDs.
  3. By deleting from one end of the table and adding at the other end we can avoid fragmentation…

This announcement thread in Rails forum mentioned some caveat (which is also on the GitHub ReadMe), a blog post, and a video for the talk:

Actually DHH blogged about this gem in December, before the plan of Rails 8 was announced. Overall it sounds like a feasible solution, given the recent performance improvements of NVMe SSD.

Top comments (0)