The purpose of this repository is to make it easier to use the Pivotal Cloud Foundry Redis Tile Redis for PCF. The repository contains example Cloud Foundry Apps that demonstrate using Redis for PCF.
The example application is written in Java and makes use of the compatibility of Spring with Cloud Foundry bound services.
The example application takes advantage of recent updates to the Spring Java-CFEnv to automatically connect to Redis via TLS when available. In order to take advantage of this behaviour, it is necessary to disable the Java buildpack auto-reconfiguration cf set-env <APP> JBP_CONFIG_SPRING_AUTO_RECONFIGURATION '{enabled: false}'
and instead explicitly use the Spring capability cf set-env <APP> SPRING_PROFILES_ACTIVE cloud
.
Redis can be used for storing a wide range of data. No reference architecture is a good fit with all possible uses of Redis. Our existing examples focus on using redis as a cache. If you require that the data in Redis be stored in a specific structure, such as a specific list or set, this is likely not possible using Spring Cache. We do not yet have a reference architecture for you.
This example architecture uses the Spring Cache framework with a single Redis service to cache calls to a java method.
- Appropriate if you have a method that will benefit from caching:
- the method is slow to run
- the method always returns the same result for a given input (similar to a pure function, but may have idempotent side effects)
- the method is called repeatedly with the same input
- Appropriate if your App can handle a short period of time when the cache is unavailable
- Redis for PCF service instances become unavailable for a few minutes during upgrades
- Not appropriate if you require direct access and manipulation of the underlying Redis cache