This topic contains information for application development with use with the VMware GemFire for Redis Apps add-on.
VMware GemFire for Redis Apps currently supports the Redis noeviction policy. New values are not saved when memory limit is reached.
Warning: Users must use a Key expiration strategy to avoid this situation. This means that users should assign Keys with one of the following:
EXPIRE
EXPIREAT
PEXPIRE
PEXPIREAT
Users can also use a custom region configuration, allowing them to customize the data eviction strategy. For more information about setting data eviction settings, see Configure Data Eviction in the VMware GemFire documentation.
When setting expiration, keys are expired in two ways, actively and passively:
CONFIG
command.If your application uses Spring Session Data Redis. you must add code like the following to deactivate Spring Session from calling CONFIG
.
@SpringBootApplication
public class Application {
public static void main(String[] args) {SpringApplication.run(Application.class, args); }
@Bean
public static ConfigureRedisAction configureRedisAction() {
return ConfigureRedisAction.NO_OP;
}
}
This is a known solution for many Managed Redis products (ElastiCache, Azure Cache for Redis, etc.) that deactivate the CONFIG
command for security reasons. For information regarding this decision, see the Spring Session issue report in GitHub.
If your application uses redis-py-cluster, you must specify the option “skip_full_coverage_check=True” when creating the connection to the cluster. This is a known solution for many Managed Redis products (ElastiCache, Azure Cache for Redis, etc.) that deactivate the CONFIG
command for security reasons. For information regarding this decision, see the AWS Elasticache Restrictions issue report in GitHub.
To connect a Redis application to the VMware GemFire for TAS service instance, you must create a service key. A service instance with GemFire for Redis Apps enabled will include the following additional properties in the service key as well as to the binding environment for the bound app:
Before you begin, note that:
Follow the steps below to connect a Redis client to the VMware GemFire for TAS service.
Create a service key (if you have not created one already) by running the following command: cf create-service-key MY-INSTANCE MY-KEY
Inspect the service key: cf service-key MY-INSTANCE MY-KEY
This returns a JSON response (VCAP_SERVICES
) containing the fields shown in this example:
{
"uri": "redis://developer_GUID:[email protected]:6379",
"hostname": "redis-endpoint.service-instance-INSTANCE-GUID.bosh",
"username": "developer_GUID",
"password": "PASSWORD",
"port": 6379,
"users": [
{
"password": "PASSWORD",
"roles": [
"developer"
],
"username": "developer_GUID"
}
]
}
Note: The username
field is the same as the username configured for the developer
role. This role has the necessary permissions to access all GemFire for Redis Apps functionality.
If TLS is enabled for the service, the uri
scheme will be rediss:
, and the port
field will be replaced by a tls_port
field which must be used for TLS enabled connections. Only one of port
or tls_port
will be present. Redis clients cannot establish both TLS and non-TLS connections to the same GemFire for Redis Apps service.
Configure the application. You can use the values from the service key to configure the application, as appropriate, to connect to the service.
For example, a Spring Boot application would need the following set in its application.properties
file:
spring.redis.cluster.nodes=redis-endpoint.service-instance-INSTANCE-GUID.bosh:6379
spring.redis.username=developer_GUID
spring.redis.password=PASSWORD
If your application does not use Spring Boot, you must to parse the environment variables using the java-cfenv
library
Push your application to your environment with the cf push
command.
Note: If you migrate an existing application that uses the Redis tile to GemFire for TAS, you typically must unbind the app from the Redis for TAS tile and rebind the app to GemFire for TAS. - If your app is still bound to the Redis service, unbind it: cf unbind-service APP-NAME SERVICE-INSTANCE-NAME
- Bind your app to the new VMware GemFire for TAS service: cf bind-service APP-NAME SERVICE-INSTANCE-NAME
If the VMware GemFire for TAS service is configured to use external authentication (UAA), Redis applications must be configured with a user and associated password that has the PCC_DATA-ACCESS
role as described in Configuring User Account and Authentication (UAA) Roles in the VMware GemFire for TAS documentation.
When UAA is configured, the VCAP_SERVICES
data will not include a username
or password
field.
GemFire for Redis Apps does not persist any data to disk, so it is not possible to back up and restore.