11---
22title : " ElastiCache"
3- linkTitle : " ElastiCache"
43tags : ["Base"]
54description : Get started with AWS ElastiCache on LocalStack
65persistence : supported
@@ -15,7 +14,7 @@ It supports popular open-source caching engines like Redis and Memcached (LocalS
1514providing a means to efficiently store and retrieve frequently accessed data with minimal latency.
1615
1716LocalStack supports ElastiCache via the Pro offering, allowing you to use the ElastiCache APIs in your local environment.
18- The supported APIs are available on our [ API Coverage Page] ({{< ref "references/coverage/coverage_elasticache" >}} ),
17+ The supported APIs are available on our [ API Coverage Page] ( ) ,
1918which provides information on the extent of ElastiCache integration with LocalStack.
2019
2120## Getting started
@@ -26,82 +25,87 @@ This guide is designed for users new to ElastiCache and assumes basic knowledge
2625
2726After starting LocalStack Pro, you can create a cluster with the following command.
2827
29- {{< command >}}
30- $ awslocal elasticache create-cache-cluster \
28+ ``` bash
29+ awslocal elasticache create-cache-cluster \
3130 --cache-cluster-id my-redis-cluster \
3231 --cache-node-type cache.t2.micro \
3332 --engine redis \
3433 --num-cache-nodes 1
35- {{< /command>}}
34+ ```
3635
3736Wait for it to be available, then you can use the cluster endpoint for Redis operations.
3837
39- {{< command >}}
40- $ awslocal elasticache describe-cache-clusters --show-cache-node-info --query "CacheClusters[ 0] .CacheNodes[ 0] .Endpoint"
38+ ``` bash
39+ awslocal elasticache describe-cache-clusters --show-cache-node-info --query " CacheClusters[0].CacheNodes[0].Endpoint"
40+ ```
41+
42+ The output will be:
43+
44+ ``` json
4145{
4246 "Address" : " localhost.localstack.cloud" ,
4347 "Port" : 4510
4448}
45- {{< /command >}}
49+ ```
4650
47- The cache cluster uses a random port of the [ external service port range] ({{< ref "external-ports" >}} ).
51+ The cache cluster uses a random port of the [ external service port range] ( ) .
4852Use this port number to connect to the Redis instance like so:
4953
50- {{< command >}}
51- $ redis-cli -p 4510 ping
54+ ``` bash
55+ redis-cli -p 4510 ping
5256PONG
53- $ redis-cli -p 4510 set foo bar
57+ redis-cli -p 4510 set foo bar
5458OK
55- $ redis-cli -p 4510 get foo
59+ redis-cli -p 4510 get foo
5660" bar"
57- {{< / command >}}
61+ ```
5862
5963### Replication groups in non-cluster mode
6064
61- {{< command >}}
62- $ awslocal elasticache create-replication-group \
65+ ``` bash
66+ awslocal elasticache create-replication-group \
6367 --replication-group-id my-redis-replication-group \
6468 --replication-group-description ' my replication group' \
6569 --engine redis \
6670 --cache-node-type cache.t2.micro \
6771 --num-cache-clusters 3
68- {{< /command >}}
72+ ```
6973
7074Wait for it to be available.
7175When running the following command, you should see one node group when running:
7276
73- {{< command >}}
74- $ awslocal elasticache describe-replication-groups --replication-group-id my-redis-replication-group
75- {{< /command >}}
77+ ``` bash
78+ awslocal elasticache describe-replication-groups --replication-group-id my-redis-replication-group
79+ ```
7680
7781To retrieve the primary endpoint:
7882
79- {{< command >}}
80- $ awslocal elasticache describe-replication-groups --replication-group-id my-redis-replication-group \
83+ ``` bash
84+ awslocal elasticache describe-replication-groups --replication-group-id my-redis-replication-group \
8185 --query " ReplicationGroups[0].NodeGroups[0].PrimaryEndpoint"
82- {{< /command >}}
86+ ```
8387
8488### Replication groups in cluster mode
8589
8690The cluster mode is enabled by using ` --num-node-groups ` and ` --replicas-per-node-group ` :
8791
88- {{< command >}}
89- $ awslocal elasticache create-replication-group \
92+ ``` bash
93+ awslocal elasticache create-replication-group \
9094 --engine redis \
9195 --replication-group-id my-clustered-redis-replication-group \
9296 --replication-group-description ' my clustered replication group' \
9397 --cache-node-type cache.t2.micro \
9498 --num-node-groups 2 \
9599 --replicas-per-node-group 2
96- {{< /command >}}
100+ ```
97101
98102Note that the group nodes do not have a primary endpoint.
99103Instead they have a ` ConfigurationEndpoint ` , which you can connect to using ` redis-cli -c ` where ` -c ` is for cluster mode.
100104
101- {{< command >}}
102- $ awslocal elasticache describe-replication-groups --replication-group-id my-clustered-redis-replication-group \
105+ ``` bash
106+ awslocal elasticache describe-replication-groups --replication-group-id my-clustered-redis-replication-group \
103107 --query " ReplicationGroups[0].ConfigurationEndpoint"
104- {{< /command >}}
108+ ```
105109
106110## Container mode
107111
@@ -119,11 +123,11 @@ You can access the Resource Browser by opening the LocalStack Web Application in
119123In the ElastiCache resource browser you can:
120124
121125* List and remove existing cache clusters
122- {{< img src=" elasticache-resource-browser-list.png" alt="Create a ElastiCache cluster in the resource browser" >}}
126+ ![ List existing cache clusters ] ( /images/aws/ elasticache-resource-browser-list.png)
123127* View details of cache clusters
124- {{< img src=" elasticache-resource-browser-show.png" alt="Create a ElastiCache cluster in the resource browser" >}}
128+ ![ View details of cache clusters ] ( /images/aws/ elasticache-resource-browser-show.png)
125129* Create new cache clusters
126- {{< img src="elasticache-resource-browser-create.png" alt=" Create a ElastiCache cluster in the resource browser" >}}
130+ ![ Create a ElastiCache cluster in the resource browser] ( /images/aws/elasticache-resource-browser-create.png )
127131
128132## Current Limitations
129133
0 commit comments