ElasticacheRedis

A Redis cluster running on AWS's Elasticache service.

Like all Resources, this class configures itself across multiple Environments.

For more information see the official documentation.

NOTE: This resource can only be accessed from within the same VPC it is created in. Use EC2Redis to create a Redis instance that can be accessed from outside the VPC.

Example Usage

1
import launchflow as lf
2
3
# Automatically creates / connects to an Elasticache Redis cluster in your AWS account
4
elasticache = lf.aws.ElasticacheRedis("my-redis-cluster")
5
6
# Set a key-value pair
7
client = elasticache.redis()
8
client.set("my-key", "my-value")
9
10
# Async compatible
11
async_client = await elasticache.redis_async()
12
await async_client.set("my-key", "my-value")

initialization

Create a new Elasticache Redis resource.

Args:

  • name (str): The name of the Elasticache Redis cluster.
  • node_type (Optional[str]): The instance class of the Elasticache Redis cluster. Defaults to cache.t4g.micro for development environments and cache.r7g.large for production environments.
  • parameter_group_name (str): The name of the parameter group to associate with the Elasticache Redis cluster. Defaults to default.redis7.
  • engine_version (str): Version number of the cache engine to use. Defaults to 7.0.

inputs

1
ElasticacheRedis.inputs(environment_state: EnvironmentState) -> ElasticacheRedisInputs

Get the inputs for the Elasticache Redis resource.

Args:

  • environment_state (EnvironmentState): The environment to get inputs for.

Returns:

  • ElasticacheRedisInputs: The inputs for the Elasticache Redis resource.

django_settings

1
ElasticacheRedis.django_settings()

Returns a Django settings dictionary for connecting to the Elasticache Redis cluster.

Returns:

  • A dictionary of Django settings for connecting to the Elasticache Redis cluster.

Example usage:

1
import launchflow as lf
2
3
elasticache = lf.aws.ElasticacheRedis("my-redis-cluster")
4
5
# settings.py
6
CACHES = {
7
# Connect Django's cache backend to the Elasticache Redis cluster
8
"default": elasticache.django_settings(),
9
}

redis

1
ElasticacheRedis.redis()

Get a Generic Redis Client object from the redis-py library.

Returns:

redis_async

1
async ElasticacheRedis.redis_async()

Get an Async Redis Client object from the redis-py library.

Returns: