Redis on Fly
What Is 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.
Getting Redis For An Application
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.
How it works
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.
The Redis select
command
When you connect to the Fly Redis service, you can only read from database 0. Most Redis drivers select database 0 by default.
Managing Redis data globally
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 propagate (if you set
a very large value, for example). Commands might also be slow to propagate in the event of network issues.
Unsupported Redis Commands
PubSub commands not supported | ||||
PSUBSCRIBE | PUBLISH | PUBSUB | PUNSUBSCRIBE | SUBSCRIBE |
UNSUBSCRIBE | DISCARD | EXEC | MULTI |
Other commands not supported | ||||
MOVE | RANDOMKEY | SORT | DBSIZE | TIME |
CLIENT | CONFIG | MONITOR | SLOWLOG | SWAPDB |
MEMORY | LOLWUT | EVAL | EVALSHA | SCRIPT |
GEOADD | GEOHASH | GEOPOS | GEORADIUS | GEORADIUS BYMEMBER |
FLUSHDB |
Note: Many of these commands are excluded because they are used for server or client management.