This topic contains information for application development with use with the VMware GemFire for Redis Apps add-on.
noeviction
and allkeys-lru
eviction policies.CONFIG
command.If your application uses Spring Session Data Redis. you must add code like the following to disable 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 disable 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 disable the CONFIG
command for security reasons. For information regarding this decision, see the AWS Elasticache Restrictions issue report in GitHub.
Expiration removes entries based on an expiration time associated with the entry.
Eviction controls data resource usage based on space-based thresholds.
maxmemory Settings define the memory usage thresholds at which eviction begins and commands which write data are denied.
VMware GemFire for Redis Apps automatically expires entries in two ways, actively and passively:
Expiration can be set on any key in the data store by using the following commands:
EXPIRE
EXPIREAT
PEXPIRE
PEXPIREAT
VMware GemFire for Redis Apps currently supports the following Redis eviction policies:
noeviction
allkeys-lru
Eviction is configured using the gemfire-for-redis-maxmemory-eviction-percent
and gemfire-for-redis-maxmemory-policy
startup parameters. Eviction settings cannot be changed at runtime.
When setting memory thresholds, VMware GemFire for Redis Apps differs from Open Source Redis. Instead of one maxmemory
setting which serves as the threshold for both triggering eviction and denying commands which write data, VMware GemFire for Redis Apps defines two separate settings:
gemfire-for-redis-maxmemory-eviction-percent
which defines the threshold at which eviction will begin, if eviction is enabled.gemfire-for-redis-maxmemory-deny-commands-percent
which defines the threshold at which commands which write data will be denied.Each of these settings is defined as a percentage of the total available heap memory for the VMware GemFire for Redis Apps server and cannot be changed at runtime.
By allowing the user to independently configure the thresholds for these behaviors, VMware GemFire for Redis Apps provides more control and customization, allowing for a more nuanced, optimized and tailored experience.
Below is an example of how these settings are configued when starting a VMware GemFire for Redis Apps server:
start server
--name=redisServer1
--locators=localhost[10334]
--server-port=0
--J=-Dgemfire-for-redis-enabled=true
--J=-Dgemfire-for-redis-port=6379
--J=-Dgemfire-for-redis-maxmemory-policy=allkeys-lru
--J=-Dgemfire-for-redis-maxmemory-eviction-percent=75
--J=-Dgemfire-for-redis-maxmemory-deny-commands-percent=85
For more information on how to configure eviction settings, see Configuring VMware GemFire for Redis Apps
VMware GemFire for Redis Apps supports keyspace notifications, which allow clients to subscribe to Pub/Sub channels in order to receive events affecting the VMware GemFire for Redis Apps data set in some way. Keyspace notifications are configured on server startup using the gemfire-for-redis-notify-keyspace-events
setting and cannot be changed at runtime. Below is an example of how this setting is configued when starting a VMware GemFire for Redis Apps server:
start server
--name=redisServer1
--locators=localhost[10334]
--server-port=0
--J=-Dgemfire-for-redis-enabled=true
--J=-Dgemfire-for-redis-port=6379
--J=-Dgemfire-for-redis-notify-keyspace-events=AKE
For more information on how to configure keyspace notifications, see Configuring VMware GemFire for Redis Apps.
NoteFor the
RPOPLPUSH
andLMOVE
commands, VMware GemFire for Redis Apps sends thepop
notification (eitherrpop
orlpop
) first, followed by thepush
notification (eitherrpush
orlpush
). This reflects the actual order of events that take place, but differs from Open Source Redis, which sends thepush
notification first, followed by thepop
notification.
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.
If you have not already created a service key, create a service key 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.