This topic contains information for application development with use with the VMware GemFire for Redis Apps add-on.

Features and Requirements

  • Applications must use a Redis client that supports Redis Cluster commands. Redis Cluster commands have been available since Redis 3 and are available for many of the most popular languages and frameworks.
  • VMware GemFire for Redis Apps currently implements more than 140 Redis commands. These include Redis commands for Strings, Hashes, Lists, Sets, Sorted Sets, HyperLogLog and Pub/Sub.
  • VMware GemFire for Redis Apps supports the noeviction and allkeys-lru eviction policies.
  • VMware GemFire for Redis Apps supports kespace notifications.
  • For security and operational reasons, VMware GemFire for Redis Apps does not support a Redis configuration file and does not support the 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, Eviction and maxmemory Settings

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.

Expiration

VMware GemFire for Redis Apps automatically expires entries in two ways, actively and passively:

  • With passive expiration, expiration is evaluated whenever an entry is accessed. If the expiration time for the entry has passed, it is deleted.
  • With active expiration, all entries are evaluated every three minutes. If the expiration time for an entry has passed, it is deleted.

Expiration can be set on any key in the data store by using the following commands:

  • EXPIRE
  • EXPIREAT
  • PEXPIRE
  • PEXPIREAT

Eviction

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.

maxmemory Settings

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

Keyspace Notifications

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.

Note

For the RPOPLPUSH and LMOVE commands, VMware GemFire for Redis Apps sends the pop notification (either rpop or lpop) first, followed by the push notification (either rpush or lpush). This reflects the actual order of events that take place, but differs from Open Source Redis, which sends the push notification first, followed by the pop notification.

Application Development with VMware GemFire for TAS

Connecting a Redis client

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:

  • “uri”: “redis://REDIS-USER:REDIS-PASSWORD@REDIS-HOST-NAME:6379”
  • “hostname”: “REDIS-HOST-NAME”
  • “port”: 6379
  • “username”: “REDIS-USER”
  • “password”: “REDIS-PASSWORD”

Before you begin, note that:

  • Applications must be using a Redis client that supports Redis Cluster mode.
  • VMware GemFire for Redis Apps currently implements a subset of the full set of Redis commands. For more information, see Compatible Redis Commands.

Follow the steps below to connect a Redis client to the VMware GemFire for TAS service.

  1. 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
    
  2. 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.

  3. 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

  4. 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`
    

Security

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.

check-circle-line exclamation-circle-line close-line
Scroll to top icon