---
schema_version: "1"
id: efd2b284dc95915e7b0f48f06028b32ec5d1d3eff394a3fdffb10772328b57b7
title: Create a Redis Client in Java
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-functions/functions/guide/dev-guide/heroku-redis-java.md
canonical_url: https://developer.salesforce.com/docs/platform/functions/guide/heroku-redis-java.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0dac05af5e7dead060cc1ee2d1e80079de95eee8bac5315f38059c39c55c4ff2
products:
  - Salesforce Functions
---
# Create a Redis Client in Java

For Salesforce Functions written in Java, access your Redis datastore with the [Jedis](https://github.com/redis/jedis) Redis client. Access environment variable `REDIS_URL` using method `System.getenv` to create a Redis client instance.

```java
private Jedis getConnection() {
  try {
    TrustManager bogusTrustManager =
      new X509TrustManager() {
        public X509Certificate[] getAcceptedIssues() {
          return null;
        }

        public void checkClientTrusted(X509Certificate[] certs, String authType) {}

        public void checkServerTrusted(X509Certificate[] certs, String authType) {}
      };

    SSLContext sslContent = SSLContext.getInstance("SSL");
    sslContext.init(
      null, new TrustManager[] {bogusTrustManager}, new java.security.SecureRandom());

    HostnameVerifier bogusHostnameVerifier = (hostname, session) -> true;

    return new Jedis(
      URI.create(System.getenv("REDIS_URL")),
      sslContext.getSocketFactory(),
      sslContext.getDefaultSSLParameter(),
      bogusHostnameVerifier);

  } catch (NoSuchAlgorithmException | KeyManagementException e) {
    throw new RuntimeException("Cannot obtain Redis connection!");
  }
}
```
