Each VPC has a dedicated Redis cluster, using the AWS Elasticache service.
Elasticache means there is very little overhead when maintaining or operating the Redis cluster.
Persistent and Ephemeral databases
Starting in Workarea V3 and up, each environment has its own persistent and ephemeral redis database.
The databases are set using environment variables on your application servers. By SSH'ing into your servers you can see which Redis database number is in use for your environment:
$ echo $WORKAREA_REDIS_CACHE_DB 0 $ echo $WORKAREA_REDIS_DB 1
If you're in a situation where a 3rd party gem or otherwise requires you to pass a Redis URL, you can
do so with the
Loading development environment (Rails 5.0.4) irb(main):001:0> Workarea::Configuration::Redis.cache.to_url => "redis://localhost:6379/0" irb(main):002:0> Workarea::Configuration::Redis.persistent.to_url => "redis://localhost:6379/1"
A note on the KEYS operation
There can come a time, whether in staging or production, that you may need to clear a large number of keys programatically or manually. The most typical use case, is for clearing cache keys.
It's important to note that the
KEYS operation in Redis blocks all other read and write commands. This can be
problematic when your dataset has a high number of keys.
As a one time key scan, it's not a huge deal, but if you ever finding yourself doing this more than once, you should use
Here is an example of how to implement a non blocking version of
# Usage: find_all_keys("*cache*") def find_all_keys(str) redis = ::Redis.new(Workarea::Configuration::Redis.cache.to_url) cursor = 0 keepLooking = true matches =  while keepLooking res = redis.scan(cursor, match: str) cursor = res.first.to_i matches += res.last keepLooking = false if cursor == 0 end return matches end