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

Solid Cache is a database-backed Active Support cache store that let's you keep a much larger cache than is typically possible with traditional memory-only Redis or Memcached stores. This is thanks to the speed of modern SSD drives, which make the access-time penalty of using disk vs RAM insignificant for most caching purposes. Simply put, you're now usually better off keeping a huge cache on disk rather than a small cache in memory.

Installation

Solid Cache is configured by default in new Rails 8 applications. But if you're running an earlier version, you can add it manually following these steps:

  1. bundle add solid_cache
  2. bin/rails solid_cache:install

This will configure Solid Cache as the production cache store, create config/cache.yml, and create db/cache_schema.rb.

You will then have to add the configuration for the queue database in config/database.yml. If you're using sqlite, it'll look like this:

production
  primary
…
Enter fullscreen mode Exit fullscreen mode

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)