RDBC-1035 RDBC-1036 Add aggressive caching context managers and store-level session events#277
Open
redknightlois wants to merge 1 commit intoravendb:v7.1from
Open
RDBC-1035 RDBC-1036 Add aggressive caching context managers and store-level session events#277redknightlois wants to merge 1 commit intoravendb:v7.1from
redknightlois wants to merge 1 commit intoravendb:v7.1from
Conversation
…evel events - Add add/remove_before_store, add/remove_after_save_changes, add/remove_before_delete, add/remove_before_query to DocumentStoreBase; register_events_for_session wires them into every new session - Add aggressively_cache_for(duration, mode) and disable_aggressive_caching() context managers on DocumentStore; AggressiveCacheOptions is thread-local via threading.local(), mirroring C# AsyncLocal<T> - Add _AggressiveCacheEviction inner class: subscribes to Changes() feed and increments HttpCache.generation on DocumentChange / IndexChange events - Fix _listen_to_changes_and_update_cache: construct _AggressiveCacheEviction outside __add_change_lock to prevent deadlock when store.changes() (which acquires the same lock) is called during construction - Remove dead HttpCache.ReleaseCacheItem inner class; fix _get_from_cache to import and return the module-level ReleaseCacheItem for non-cacheable command paths (was AttributeError at runtime) - Fix before_delete event timing for key-based session.delete(): move BeforeDeleteEventArgs dispatch from delete() into prepare_for_save_changes() via __prepare_for_key_deletes, matching C# PrepareForEntitiesDeletion timing and making both delete paths (key vs entity) consistent - Fix session-level remove_before_query: was appending instead of removing, making it impossible to unregister a query event handler on an open session - Rename session-level remove_before_delete_entity to remove_before_delete, matching the naming convention of all other remove methods and the store-level API - Add no_caching guard to _check_aggressive_cache_guard test helper so it exactly mirrors the condition in execute(); add test for no_caching bypass - Add integration tests verifying event args contents: args.entity identity in OnBeforeStore and args.key in OnBeforeDelete (per C# Events.cs spec) - Remove test for unreachable RAW-command cache-hit path: _get_from_cache never returns a populated item for non-OBJECT commands, so the scenario the test described could not occur in production
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.
Issue link
https://issues.hibernatingrhinos.com/issue/RDBC-1035
https://issues.hibernatingrhinos.com/issue/RDBC-1036
Additional description
RDBC-1035 – Adds aggressive caching support to the Python client.
store.aggressively_cache_for(duration)andstore.disable_aggressive_caching()are context managers that enable/disable serving GET responses directly from the local HTTP cache without a server round-trip. Cache options are thread-local, matching the C#AsyncLocal<T>semantics. The cache is automatically invalidated when document or index change notifications arrive.RDBC-1036 – Adds store-level session event hooks:
add_before_store,add_after_save_changes,add_before_delete, andadd_before_query(with correspondingremove_*variants). Handlers registered on the store are automatically wired into every new session, eliminating the need to re-register on eachopen_sessioncall.Type of change
How risky is the change?
Backward compatibility
Is it platform specific issue?
Documentation update
Documentation Requiredtag.Testing by Contributor
private)Testing by RavenDB QA team
QA Requiredtag.Is there any existing behavior change of other features due to this change?
UI work
Studio Requiredtag.