Modify the lock mechanism to operate on a per-key basis rather than per-function basis. - #5
Merged
Conversation
…er-function basis.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the lock mechanism to operate on a per-key basis rather than per-function basis, allowing concurrent execution of cached functions with different cache keys while maintaining thread safety for the same key.
Key changes:
- Introduces separate async and sync storage classes with per-key locking
- Refactors lock classes to work with key-specific lock storage
- Adds comprehensive test coverage for concurrent access scenarios
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| todo | Updates task list with new items including package structure changes and documentation |
| tests/test__storages.py | Adds new concurrent access tests and updates existing tests for per-key locking |
| tests/test__decorator.py | Updates async storage usage and adds validation tests for storage type compatibility |
| py_cashier/_storages/_ttl_map.py | Implements new lock storage classes and separates sync/async storage implementations |
| py_cashier/_storages/_abc.py | Separates sync and async lock/storage abstractions into distinct base classes |
| py_cashier/_storages/init.py | Exports new async storage and lock classes |
| py_cashier/_decorators.py | Adds storage type validation and proper async/sync storage handling |
| py_cashier/init.py | Minor import reorganization |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.