Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support client side caching with ConnectionPool #3099

Merged
merged 7 commits into from
Jan 7, 2024

Conversation

dvora-h
Copy link
Collaborator

@dvora-h dvora-h commented Jan 6, 2024

This pull request extends the single mode, client-side-caching support to ConnectionPools.

@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2024

Codecov Report

Attention: 19 lines in your changes are missing coverage. Please review.

Comparison is base (6d77c6d) 91.50% compared to head (1b2387b) 91.45%.

Files Patch % Lines
redis/connection.py 71.05% 11 Missing ⚠️
redis/asyncio/connection.py 77.14% 8 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3099      +/-   ##
==========================================
- Coverage   91.50%   91.45%   -0.06%     
==========================================
  Files         128      128              
  Lines       33053    33105      +52     
==========================================
+ Hits        30245    30276      +31     
- Misses       2808     2829      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -294,6 +294,13 @@ def __init__(
"lib_version": lib_version,
"redis_connect_func": redis_connect_func,
"protocol": protocol,
"cache_enable": cache_enable,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have you, @vladvildanov and @uglide sync on these just to finalize before the next release. Getting them into the specs finally too - WDYT?

redis/connection.py Outdated Show resolved Hide resolved
Copy link
Contributor

@chayim chayim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small ones - looks good. Let's close the loop in the spec.

@@ -205,6 +221,14 @@ def __init__(
if p < 2 or p > 3:
raise ConnectionError("protocol must be either 2 or 3")
self.protocol = protocol
if cache_enable:
Copy link
Contributor

@chayim chayim Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do an enforce check on RESP version, like others did - just for CSC? It might provide a better error for users.

redis/asyncio/connection.py Show resolved Hide resolved
redis/asyncio/connection.py Show resolved Hide resolved
@@ -268,6 +267,13 @@ def __init__(
"redis_connect_func": redis_connect_func,
"credential_provider": credential_provider,
"protocol": protocol,
"cache_enable": cache_enable,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjpotter @vladvildanov @ofekshenawa Can you all align on these, with whatever is right collectively? Then, we can get this into the specification.

@dvora-h dvora-h marked this pull request as ready for review January 7, 2024 11:51
@dvora-h dvora-h merged commit 8cbf7f5 into redis:master Jan 7, 2024
46 checks passed
Comment on lines +556 to 560
pool = self.connection_pool
conn = self.connection or pool.get_connection(command_name, **options)
response_from_cache = conn._get_from_local_cache(args)
if response_from_cache is not None:
return response_from_cache

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a connection leak if we pull from cache?

We're getting a connection from the pool and never releasing it in this code path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was, but fixed already in #3160

vladvildanov pushed a commit that referenced this pull request Sep 27, 2024
* sync

* async

* fixs connection mocks

* fix async connection mock

* fix test_asyncio/test_connection.py::test_single_connection

* add test for cache blacklist and flushdb at the end of each test

* fix review comments
vladvildanov pushed a commit that referenced this pull request Sep 27, 2024
* sync

* async

* fixs connection mocks

* fix async connection mock

* fix test_asyncio/test_connection.py::test_single_connection

* add test for cache blacklist and flushdb at the end of each test

* fix review comments
vladvildanov pushed a commit that referenced this pull request Sep 27, 2024
* sync

* async

* fixs connection mocks

* fix async connection mock

* fix test_asyncio/test_connection.py::test_single_connection

* add test for cache blacklist and flushdb at the end of each test

* fix review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants