launchflow.aws.elasticache

ElasticacheRedis

1
class ElasticacheRedis(AWSResource[ElasticacheRedisConnectionInfo])

A Redis cluster running on AWS's Elasticache service.

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
elasticache = lf.aws.ElasticacheRedis("my-redis-cluster")
4
5
# Set a key-value pair
6
client = elasticache.redis()
7
client.set("my-key", "my-value")
8
9
# Async compatible
10
async_client = await elasticache.redis_async()
11
await async_client.set("my-key", "my-value")

__init__

1
def __init__(name: str) -> None

Create a new Elasticache Redis resource.

Args:

  • name: The name of the Elasticache Redis cluster.

django_settings

1
def django_settings()

Returns a Django settings dictionary 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
def redis()

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

Returns:

redis_async

1
async def redis_async()

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

Returns: