Redis on Fly
Redis is a popular in-memory key/value store. On Fly, it can provide a region-local cache to Fly applications and a cross-region mechanism for communication.
There is no configuration to be done to enable Redis. The environment variable
FLY_REDIS_CACHE_URL contains a URL for Redis and should be retrieved by your application so they can use a standard Redis driver to connect.
We run Redis clusters in each region for your app processes. Your app can access these clusters with minimal latency so you can cache application data, views, or partials.
Writes to the regional Redis clusters are only visible within their region. If you cache information in Chicago, for example, it’s not visible to application processes that run in Amsterdam. This helps reduce duplication of data, applications have surprisingly little cache overlap across regions.
The clusters are volatile and in memory only. Cache data can vanish at any time. These Redis instances should not be used for data you don’t want to lose, they’re intended only for use as caches.
When you connect to the Fly Redis service, you can only read from database 0. Most Redis drivers select database 0 by default.
Database 1 is a “virtual” Redis. You can access it by running the
select 1 command. This database returns an
ok response for any well formed command immediately, and then replays the command + parameters in every region your application is running in.
This is useful for purging cache data, and can also be used to “push” cache data to each region.
Note: command propagation is eventually consistent. Under most circumstances, small commands should be applied to every region in less than 1 second. Large commands can take a bit longer to progate (if you
set a very large value, for example). Commands might also be slow to propagate in the event of network issues.