Skip to content

Commit 2ab8eed

Browse files
committed
fix: redis/fastapi-cache2 compatibility and vault test typo
- Pin redis to 4.6.0 (latest 4.x) for fastapi-cache2 compatibility - fastapi-cache2 0.2.2 requires redis>=4.2.0rc1,<5.0.0 - redis 4.3.0+ required for redis.asyncio.cluster module - Fix CacheManager to not use decode_responses=True - fastapi-cache2 stores binary data, requires decode_responses=False - Fix typo in vault test: $PROJECT_RO../devstack -> $PROJECT_ROOT/devstack All 17 test suites (571+ tests) pass.
1 parent cc95f7d commit 2ab8eed

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

reference-apps/fastapi-api-first/app/middleware/cache.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,9 @@ async def init(self, redis_url: str, prefix: str = "cache:"):
166166
prefix: Cache key prefix
167167
"""
168168
try:
169-
self.redis_client = aioredis.from_url(
170-
redis_url,
171-
encoding="utf8",
172-
decode_responses=True
173-
)
169+
# Note: decode_responses must be False (default) for fastapi-cache2
170+
# as it stores cached data as binary/bytes
171+
self.redis_client = aioredis.from_url(redis_url)
174172

175173
# Test connection
176174
await self.redis_client.ping()

reference-apps/fastapi-api-first/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ motor==3.7.1
1919
pymongo==4.15.5
2020

2121
# Redis and Caching
22-
redis[hiredis]==7.1.0 # Compatible with fastapi-cache2 (requires <5.0.0)
22+
# redis 4.3.0+ required for redis.asyncio.cluster module used by fastapi-cache2
23+
# redis 4.6.0 is the latest 4.x version compatible with fastapi-cache2 (<5.0.0 requirement)
24+
redis[hiredis]==4.6.0 # fastapi-cache2 0.2.2 requires redis>=4.2.0rc1,<5.0.0
2325
fastapi-cache2[redis]==0.2.2 # Response caching
2426

2527
# RabbitMQ

reference-apps/fastapi/app/middleware/cache.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,9 @@ async def init(self, redis_url: str, prefix: str = "cache:"):
166166
prefix: Cache key prefix
167167
"""
168168
try:
169-
self.redis_client = aioredis.from_url(
170-
redis_url,
171-
encoding="utf8",
172-
decode_responses=True
173-
)
169+
# Note: decode_responses must be False (default) for fastapi-cache2
170+
# as it stores cached data as binary/bytes
171+
self.redis_client = aioredis.from_url(redis_url)
174172

175173
# Test connection
176174
await self.redis_client.ping()

reference-apps/fastapi/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ motor==3.7.1
1515
pymongo==4.15.5
1616

1717
# Redis and Caching
18-
redis[hiredis]==7.1.0 # fastapi-cache2 0.2.2 requires redis<5.0.0
18+
# redis 4.3.0+ required for redis.asyncio.cluster module used by fastapi-cache2
19+
# redis 4.6.0 is the latest 4.x version compatible with fastapi-cache2 (<5.0.0 requirement)
20+
redis[hiredis]==4.6.0 # fastapi-cache2 0.2.2 requires redis>=4.2.0rc1,<5.0.0
1921
fastapi-cache2[redis]==0.2.2 # Response caching
2022

2123
# RabbitMQ

tests/test-vault.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,13 @@ test_management_commands() {
567567
info "Test 10: Management script Vault commands work"
568568

569569
# Test vault-status
570-
if "$PROJECT_RO../devstack" vault-status &>/dev/null; then
570+
if "$PROJECT_ROOT/devstack" vault-status &>/dev/null; then
571571
# Test vault-token
572-
local token=$("$PROJECT_RO../devstack" vault-token 2>/dev/null)
572+
local token=$("$PROJECT_ROOT/devstack" vault-token 2>/dev/null)
573573

574574
if [ -n "$token" ]; then
575575
# Test vault-show-password
576-
local password=$("$PROJECT_RO../devstack" vault-show-password postgres 2>/dev/null)
576+
local password=$("$PROJECT_ROOT/devstack" vault-show-password postgres 2>/dev/null)
577577

578578
if [ -n "$password" ]; then
579579
success "Management commands work correctly"

0 commit comments

Comments
 (0)