launchflow.aws.elasticache
ElasticacheRedis
1class 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:
1import launchflow as lf
2
3elasticache = lf.aws.ElasticacheRedis("my-redis-cluster")
4
5# Set a key-value pair
6client = elasticache.redis()
7client.set("my-key", "my-value")
8
9# Async compatible
10async_client = await elasticache.redis_async()
11await async_client.set("my-key", "my-value")
__init__
1def __init__(name: str) -> None
Create a new Elasticache Redis resource.
Args:
name
: The name of the Elasticache Redis cluster.
django_settings
1def django_settings()
Returns a Django settings dictionary for connecting to the Elasticache Redis cluster.
Example usage:
1import launchflow as lf
2
3elasticache = lf.aws.ElasticacheRedis("my-redis-cluster")
4
5# settings.py
6CACHES = {
7 # Connect Django's cache backend to the Elasticache Redis cluster
8 "default": elasticache.django_settings(),
9}
redis
1def redis()
Get a Generic Redis Client object from the redis-py library.
Returns:
- The Generic Redis Client from the redis-py library.
redis_async
1async def redis_async()
Get an Async Redis Client object from the redis-py library.
Returns:
- The Async Redis Client object from the redis-py library.