IDX-7034 Add Cache::try_insert and Cache::try_find#43
Open
dalloriam wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces non-blocking and timed “try” cache operations (try_find / try_insert) and replaces the prior boolean thread-safety toggle with a more explicit LockingStrategy (None / Mutex / TimedMutex) to control locking behavior.
Changes:
- Add
LockingStrategyand mutex-selection utilities, and plumb this throughCacheand preset aliases. - Add
Cache::try_find/Cache::try_insert(immediate and timed variants) plus new tests covering contention/timeout behavior. - Update performance benchmarks and a single-thread swap test to use the new locking strategy template parameter.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/src/cache_tests.cpp | Adds compile-time checks and runtime tests for try_find/try_insert, including contention and timed-lock scenarios. |
| include/cachemere/presets.h | Replaces bool ThreadSafe with LockingStrategy in preset aliases and updates docs accordingly. |
| include/cachemere/detail/locking.h | Introduces LockingStrategy, NullMutex, and mutex-type mapping utilities. |
| include/cachemere/cache.h | Reworks cache locking to use LockingStrategy and implements try_find/try_insert APIs. |
| benchmarks/performance/src/bench_cache.cpp | Updates benchmarks to instantiate caches with LockingStrategy::{Mutex,None} and fixes complexity type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Cache::try_insert and Cache::try_find
dalloriam
marked this pull request as ready for review
May 21, 2026 17:56
dalloriam
force-pushed
the
feature/IDX-7025-api-improvements
branch
from
May 27, 2026 12:50
93dfa25 to
b3f9034
Compare
dalloriam
force-pushed
the
feature/IDX-7025-try-insert
branch
from
May 27, 2026 12:51
067f16f to
8cf4125
Compare
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.
Changes
try_insertandtry_findmethodsThreadSafebool template param by aLockingStrategyenumTimedMutexto theLockingStrategyenumtry_insertandtry_findif locking strategy isTimedMutex