Skip to content

Commit

Permalink
Change brotli quality for Redis cache to 4, as the default quality of…
Browse files Browse the repository at this point in the history
… 11 is extremely slow.
  • Loading branch information
lukas-phaf committed Sep 25, 2024
1 parent d07d721 commit 3290b60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/lib/adaguc/runAdaguc.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ async def response_to_cache(redis_pool, key, headers: str, data):
entrytime
+ f"{len(cacheable_headers_json):06d}".encode("utf-8")
+ cacheable_headers_json
+ brotli.compress(data.getvalue()),
+ brotli.compress(data.getvalue(), quality=4),
ex=ttl,
)
await redis_client.aclose()
Expand Down
4 changes: 2 additions & 2 deletions python/python_fastapi_server/routers/caching_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ async def response_to_cache(redis_pool, request, headers, data, ex: int):
entrytime = f"{calendar.timegm(datetime.utcnow().utctimetuple()):10d}".encode(
"utf-8"
)
compressed_data = brotli.compress(data)
compressed_data = brotli.compress(data, quality=4)
if len(compressed_data) < MAX_SIZE_FOR_CACHING:
redis_client = redis.Redis(connection_pool=redis_pool)
await redis_client.set(
key,
entrytime
+ f"{len(headers_json):06d}".encode("utf-8")
+ headers_json
+ brotli.compress(data),
+ compressed_data,
ex=ex,
)
await redis_client.aclose()
Expand Down

0 comments on commit 3290b60

Please sign in to comment.