Cache user positions per wallet#381
Open
silentgeckoaudit3801 wants to merge 5 commits into
Open
Conversation
|
|
||
|
|
||
| def test_user_positions_endpoint_uses_wallet_scoped_cache(): | ||
| assert "USER_POSITIONS_CACHE_TTL = 60" in POSITION_SOURCE |
|
|
||
| def test_user_positions_endpoint_uses_wallet_scoped_cache(): | ||
| assert "USER_POSITIONS_CACHE_TTL = 60" in POSITION_SOURCE | ||
| assert "def _user_positions_cache_key(wallet_id: str, start: int, limit: int)" in POSITION_SOURCE |
| def test_user_positions_endpoint_uses_wallet_scoped_cache(): | ||
| assert "USER_POSITIONS_CACHE_TTL = 60" in POSITION_SOURCE | ||
| assert "def _user_positions_cache_key(wallet_id: str, start: int, limit: int)" in POSITION_SOURCE | ||
| assert 'return f"user_positions:{wallet_id}:{start}:{limit}"' in POSITION_SOURCE |
| assert "USER_POSITIONS_CACHE_TTL = 60" in POSITION_SOURCE | ||
| assert "def _user_positions_cache_key(wallet_id: str, start: int, limit: int)" in POSITION_SOURCE | ||
| assert 'return f"user_positions:{wallet_id}:{start}:{limit}"' in POSITION_SOURCE | ||
| assert "await get_cached_or_fetch(" in POSITION_SOURCE |
| assert "def _user_positions_cache_key(wallet_id: str, start: int, limit: int)" in POSITION_SOURCE | ||
| assert 'return f"user_positions:{wallet_id}:{start}:{limit}"' in POSITION_SOURCE | ||
| assert "await get_cached_or_fetch(" in POSITION_SOURCE | ||
| assert "ttl=USER_POSITIONS_CACHE_TTL" in POSITION_SOURCE |
|
|
||
|
|
||
| def test_cache_helper_supports_pattern_invalidation(): | ||
| assert "async def delete_cache_pattern(pattern: str)" in CACHE_SOURCE |
|
|
||
| def test_cache_helper_supports_pattern_invalidation(): | ||
| assert "async def delete_cache_pattern(pattern: str)" in CACHE_SOURCE | ||
| assert "await client.scan(cursor=cursor, match=pattern, count=100)" in CACHE_SOURCE |
| def test_cache_helper_supports_pattern_invalidation(): | ||
| assert "async def delete_cache_pattern(pattern: str)" in CACHE_SOURCE | ||
| assert "await client.scan(cursor=cursor, match=pattern, count=100)" in CACHE_SOURCE | ||
| assert "await client.delete(*keys)" in CACHE_SOURCE |
| assert "async def delete_cache_pattern(pattern: str)" in CACHE_SOURCE | ||
| assert "await client.scan(cursor=cursor, match=pattern, count=100)" in CACHE_SOURCE | ||
| assert "await client.delete(*keys)" in CACHE_SOURCE | ||
| assert "Cache invalidation failed" in CACHE_SOURCE No newline at end of file |
| assert 'await delete_cache_pattern(f"user_positions:{wallet_id}:*")' in POSITION_SOURCE | ||
| assert "await _invalidate_user_positions_cache(form_data.wallet_id)" in POSITION_SOURCE | ||
| assert "wallet_id = _get_wallet_id_for_position(position_id)" in POSITION_SOURCE | ||
| assert "await _invalidate_user_positions_cache(wallet_id)" in POSITION_SOURCE |
| assert "await _invalidate_user_positions_cache(form_data.wallet_id)" in POSITION_SOURCE | ||
| assert "wallet_id = _get_wallet_id_for_position(position_id)" in POSITION_SOURCE | ||
| assert "await _invalidate_user_positions_cache(wallet_id)" in POSITION_SOURCE | ||
| assert "def _get_wallet_id_for_position_object(position: object | None)" in POSITION_SOURCE |
| assert "await _invalidate_user_positions_cache(wallet_id)" in POSITION_SOURCE | ||
| assert "def _get_wallet_id_for_position_object(position: object | None)" in POSITION_SOURCE | ||
| assert 'getattr(position, "user_id", None)' in POSITION_SOURCE | ||
| assert "_get_wallet_id_for_position_object(position)" in POSITION_SOURCE |
| assert "wallet_id = _get_wallet_id_for_position(position_id)" in POSITION_SOURCE | ||
| assert "await _invalidate_user_positions_cache(wallet_id)" in POSITION_SOURCE | ||
| assert "def _get_wallet_id_for_position_object(position: object | None)" in POSITION_SOURCE | ||
| assert 'getattr(position, "user_id", None)' in POSITION_SOURCE |
| assert "await _invalidate_user_positions_cache(wallet_id)" in POSITION_SOURCE | ||
| assert "def _get_wallet_id_for_position_object(position: object | None)" in POSITION_SOURCE | ||
| assert 'getattr(position, "user_id", None)' in POSITION_SOURCE | ||
| assert 'getattr(user, "wallet_id", None)' in POSITION_SOURCE |
| assert "def _get_wallet_id_for_position_object(position: object | None)" in POSITION_SOURCE | ||
| assert 'getattr(position, "user_id", None)' in POSITION_SOURCE | ||
| assert 'getattr(user, "wallet_id", None)' in POSITION_SOURCE | ||
| assert "if not isinstance(user_id, UUID):" in POSITION_SOURCE |
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.
Closes #237
Summary
/api/user-positions/{wallet_id}responses for 60 seconds using wallet/start/limit scoped keysValidation