

# Create a Redis OSS serverless cache
<a name="GettingStarted.serverless-redis.step1"></a>

In this step, you create a new cache in Amazon ElastiCache.

**AWS Management Console**

To create a new cache using the ElastiCache console:

1. Sign in to the AWS Management Console and open the ElastiCache console at [https://console.aws.amazon.com/elasticache/](https://console.aws.amazon.com/elasticache/).

1. In the navigation pane on the left side of the console, choose **Redis OSS caches**.

1. On the right side of the console, choose **Create Redis OSS cache**

1. In the **Cache settings** enter a **Name**. You can optionally enter a **description** for the cache. 

1. Leave the default settings selected.

1. Click **Create** to create the cache.

1. Once the cache is in "ACTIVE" status, you can begin writing and reading data to the cache. .

**AWS CLI**

The following AWS CLI example creates a new cache using create-serverless-cache. 

**Linux**

```
aws elasticache create-serverless-cache \
    --serverless-cache-name CacheName \
    --engine redis
```

**Windows**

```
aws elasticache create-serverless-cache ^
    --serverless-cache-name CacheName ^
    --engine redis
```

Note that the value of the Status field is set to `CREATING`.

To verify that ElastiCache has finished creating the cache, use the `describe-serverless-caches` command. 

**Linux**

```
aws elasticache describe-serverless-caches --serverless-cache-name CacheName
```

**Windows**

```
aws elasticache describe-serverless-caches --serverless-cache-name CacheName 
```

After creating the new cache, proceed to [Read and write data to the cache](GettingStarted.serverless-redis.step2.md).

# Read and write data to the cache
<a name="GettingStarted.serverless-redis.step2"></a>

This section assumes that you've created an Amazon EC2 instance and can connect to it. For instructions on how to do this, see the [Amazon EC2 Getting Started Guide](https://aws.amazon.com/ec2/getting-started/). 

This section also assumes that you have setup VPC access and security group settings for the EC2 instance from where you are connecting to your cache, and setup valkey-cli on your EC2 instance. For more information on that step see [Setting up ElastiCache](set-up.md). 

**Find your cache endpoint**

**AWS Management Console**

To find your cache’s endpoint using the ElastiCache console:

1. Sign in to the AWS Management Console and open the Amazon ElastiCache console at [https://console.aws.amazon.com/elasticache/](https://console.aws.amazon.com/elasticache/). 

1. In the navigation pane on the left side of the console, choose **Valkey caches** **Redis OSS caches**.

1. On the right side of the console, click on the name of the cache that you just created. 

1. In the **Cache details**, locate and copy the cache endpoint. 

**AWS CLI**

The following AWS CLI example shows to find the endpoint for your new cache using the describe-serverless-caches command. Once you have run the command, look for the "Endpoint" field.

**Linux**

```
aws elasticache describe-serverless-caches \
		--serverless-cache-name CacheName
```

**Windows**

```
aws elasticache describe-serverless-caches ^
		--serverless-cache-name CacheName
```

## Connect to your Valkey or Redis OSS Cache (Linux)
<a name="w2aac14c19c37c27b1"></a>

Now that you have the endpoint you need, you can log in to your EC2 instance and connect to the cache. In the following example, you use the *valkey-cli* utility to connect to a cluster. The following command connects to a cache (note: replace cache-endpoint with the endpoint you retrieved in the previous step).

```
src/valkey-cli -h cache-endpoint --tls -p 6379
set a "hello"          // Set key "a" with a string value and no expiration
OK
get a                  // Get value for key "a"
"hello"
```

## Connect to your Valkey or Redis OSS Cache (Windows)
<a name="w2aac14c19c37c27b3"></a>

Now that you have the endpoint you need, you can log in to your EC2 instance and connect to the cache. In the following example, you use the *valkey-cli* utility to connect to a cluster. The following command connects to a cache. Open the Command Prompt and change to the Valkey directory and run the command (note: replace Cache\$1Endpoint with the endpoint you retrieved in the previous step).

```
c:\Redis>valkey-cli -h Redis_Cluster_Endpoint --tls -p 6379
set a "hello"          // Set key "a" with a string value and no expiration
OK
get a                  // Get value for key "a"
"hello"
```

You may now proceed to [(Optional) Clean up](GettingStarted.serverless-redis.step3.md).

# (Optional) Clean up
<a name="GettingStarted.serverless-redis.step3"></a>

If you no longer need the Amazon ElastiCache cache that you created, you can delete it. This step helps ensure that you are not charged for resources that you are not using. You can use the ElastiCache console, the AWS CLI, or the ElastiCache API to delete your cache.

**AWS Management Console**

To delete your cache using the console:

1. Sign in to the AWS Management Console and open the Amazon ElastiCache console at [https://console.aws.amazon.com/elasticache/](https://console.aws.amazon.com/elasticache/). 

1. In the navigation pane on the left side of the console, choose **Valkey or Redis OSS Caches**.

1. Choose the radio button next to the cache you want to delete.

1. Select **Actions** on the top right, and select **Delete**.

1. You can optionally choose to take a final snapshot before you delete your cache. 

1. In the **Delete** confirmation screen, re-enter the cache name and choose **Delete** to delete the cluster, or choose **Cancel** to keep the cluster.

As soon as your cache moves in to the **DELETING** status, you stop incurring charges for it.

**AWS CLI**

The following AWS CLI example deletes a cache using the delete-serverless-cache command. 

**Linux**

```
aws elasticache delete-serverless-cache \
		--serverless-cache-name CacheName
```

**Windows**

```
aws elasticache delete-serverless-cache ^
		--serverless-cache-name CacheName
```

Note that the value of the **Status** field is set to **DELETING**. 

You may now proceed to [Next Steps](GettingStarted.serverless-redis.next-steps.md).

# Next Steps
<a name="GettingStarted.serverless-redis.next-steps"></a>

For more information about ElastiCache see the following pages:
+ [Working with ElastiCache](WorkingWithElastiCache.md)
+ [Scaling ElastiCache](Scaling.md)
+ [Logging and monitoring in Amazon ElastiCache](MonitoringECMetrics.md)
+ [ElastiCache best practices and caching strategies](BestPractices.md)
+ [Snapshot and restore](backups.md)
+ [Amazon SNS monitoring of ElastiCache events](ECEvents.md)