Skip to content

refactoring codebase #25

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

Merged
merged 41 commits into from
Jun 9, 2025
Merged

Conversation

amirreza8002
Copy link
Member

@amirreza8002 amirreza8002 commented May 7, 2025

this is a sub-pr from #24

  1. refactor the code base to reduce repeated code
  2. add utils for raw usage
  3. sharded client now has get_client, but get_server is removed

NOTES:

refactoring invloves these points:

1.moving all client operations into their own class
2.removing shared methods from other clients, and handling all of them in one method (where possible)
3. removing hardcoded (a) prifix from async code and handling that dynamically
4. turning some async methods into sync so both clients can share them
5. reuse normal sync tests for cluster (as much as possible)
6. document the changes

(cherry picked from commit 53e50d8)
cluster clients don't support the omit_exception functionality, so had to remove the decorator from the methods, which is done be un-decorating them

(cherry picked from commit 1608aec)
(cherry picked from commit b554a14)
(cherry picked from commit a36cd11)
(cherry picked from commit c289d9b)
(cherry picked from commit 95f8542)
(cherry picked from commit 8d22fc8)
(cherry picked from commit 6c6a206)
by moving `get_server` logic to `get_client`, and adjusting operation methods, same methods can be used with shard as well

(cherry picked from commit 21a1ee9)
(cherry picked from commit 4df4565)
(cherry picked from commit 1ea3331)
(cherry picked from commit 71ffd57)
(cherry picked from commit d924df5)
this was done so people can use them with a raw client

(cherry picked from commit d39a5ab)
(cherry picked from commit 772ed71)
this was left out during cherry-picking
@amirreza8002
Copy link
Member Author

amirreza8002 commented Jun 4, 2025

note for future:
i've tested removing methods from the cache backend and replace them with a __getattr__
but i won't add it to this PR, i need more time to think about it

… them

also changed how `_incr` handles errors
@amirreza8002 amirreza8002 self-assigned this Jun 9, 2025
@amirreza8002 amirreza8002 added enhancement New feature or request code quality improve codebase quality labels Jun 9, 2025
@amirreza8002 amirreza8002 marked this pull request as ready for review June 9, 2025 23:32
@amirreza8002 amirreza8002 merged commit 9521706 into django-utils:main Jun 9, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality improve codebase quality enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant