# Cache - Amazon ElastiCache

## Creating a Redis based Amazon ElastiCache

{% hint style="warning" %}
**AWS ElastiCache Serverless is not supported.** Please use an instance-based ElastiCache configuration instead.
{% endhint %}

Open ElastiCache Dashboard In the AWS Console, select ElastiCache. Hit **Get started** and select **Redis.** Click **Design your own cache** and select the **Cluster cache** method. Cluster mode **Disabled**.

Choose a name for your cluster and continue to Cluster settings. There, keep everything default apart from the Node type where I recommend you choose **cluster.t4g.micro.**

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FdkndsPrej0jZj3UhMMj3%2Fimage.png?alt=media&#x26;token=be3bbf21-3c77-47c5-bb14-e70075348135" alt=""><figcaption></figcaption></figure>

Next in Connectivity choose Create a new subnet group, give it a name and choose your VPC.

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FwzV0jAaIgNddN2y8VZc6%2Fimage.png?alt=media&#x26;token=222b8f0f-e7cc-4cff-825c-b5acabb2f42a" alt=""><figcaption></figcaption></figure>

Next up the Advanced settings.

Assign the cache your preffered security groups, for the purposes of this tutorial I only use the default one.

I choose to disable automatic backups as DecisionRules uses Redis only for caching and not as operational storage.

Keep the rest of the settings default and hit **Next.** Review the settings and **Create.**

## Necessary settings and connection strings

#### Maxmemory policy

Navigate to **ElastiCache / Configurations / Parameter groups**. Click **Create parameter group**. Here assign the parameter group a name and for the **Family** setting choose **redis7.** Hit **Create.**

Go to the newly created parameter group and click **Edit parameter values.** Search for **maxmemory-policy**. For the value of this policy select either **allkeys-lfu or allkeys-lru.** Hit **Save changes.**

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FdMIGJ8X7WwrEhdDDuBDf%2Fimage.png?alt=media&#x26;token=7e03f6a4-9fed-4b4c-b9be-f7a3663299a7" alt=""><figcaption></figcaption></figure>

#### Connection string

To find your connection string navigate to your redis ElastiCache and there under **Cluster details** look for **Primary endpoint.**

The **connection string** will have the following format: `redis://<primary_endpoint>`

**For ease-of-use below are the necessary settings in list form:**

* **Engine**: Redis
* **Engine version**: 6 and newer
* **Port**: 6379
* **Number of replicas**: 2
* **Multi-AZ**: Yes
* **Advanced Redis settings:**
  * **Subnet group**: Same as DecisionRules server app
  * **Availability zones placement**: No preference
* **Security:**
  * **Security groups**: Same as DecisionRules server app
  * **Encryption at-rest**: No
  * **Encryption in-transit**: No
