Skip to content

Modify the lock mechanism to operate on a per-key basis rather than per-function basis. - #5

Merged
zoola969 merged 6 commits into
masterfrom
rewrite-locks
Jul 29, 2025
Merged

Modify the lock mechanism to operate on a per-key basis rather than per-function basis.#5
zoola969 merged 6 commits into
masterfrom
rewrite-locks

Conversation

@zoola969

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 27, 2025 18:37

This comment was marked as outdated.

@zoola969
zoola969 requested a review from Copilot July 29, 2025 06:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread tests/test__storages.py Outdated
Comment thread tests/test__storages.py Outdated
Comment thread tests/test__storages.py Outdated
Comment thread py_cashier/_storages/_ttl_map.py
Comment thread py_cashier/_storages/_ttl_map.py
@zoola969
zoola969 merged commit f62a7ac into master Jul 29, 2025
9 checks passed
@zoola969
zoola969 deleted the rewrite-locks branch July 29, 2025 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants