[IDX-7035] Misc. API improvements#42
Open
dalloriam wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the cache API and heterogeneous lookup support by adding a reusable composite key type, extending transparent equality to support three-way comparisons, and introducing a find_or_insert convenience API with accompanying tests.
Changes:
- Add
cachemere::CompositeKey<...>with Abseil hashing support (including consistent hashing forstd::stringvsstd::string_view). - Extend
detail::TransparentEqto fall back to<=>when==is not available, enabling more heterogeneous comparison patterns. - Add
Cache::find_or_insertAPI and tests validating the insertion/caching behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/src/detail/heterogeneous_lookup_tests.cpp | Adds coverage for heterogeneous comparisons using <=>. |
| tests/src/detail/composite_key_tests.cpp | New tests for CompositeKey construction, comparison, hashing, and heterogeneous lookup in a cache. |
| tests/src/cache_tests.cpp | Adds test ensuring find_or_insert only calls the factory once and caches the result. |
| tests/CMakeLists.txt | Registers the new composite key test file in the test target. |
| include/cachemere/detail/transparent_eq.h | Adds <=>-based equality fallback for transparent comparisons. |
| include/cachemere/detail/traits.h | Adds string/string_view traits and a FactoryFn concept used for find_or_insert. |
| include/cachemere/composite_key.h | Introduces CompositeKey with tuple-based storage and Abseil hashing. |
| include/cachemere/cache.h | Adds find_or_insert API and implementation. |
| include/cachemere.h | Exposes composite_key.h from the umbrella header. |
| CMakeLists.txt | Adds composite_key.h to the interface sources. |
Comments suppressed due to low confidence (1)
include/cachemere/detail/traits.h:51
FactoryFn's template parameter order (FactoryFn<T, K, V>) doesn't match how it's being used incache.h(whereFnis the callable). Consider redefining the concept astemplate<typename Fn, typename K, typename V> concept FactoryFn = ...and useconst K&(and possiblystd::invoke) in the requires-expression so lambdas/functions match naturally without requiring copies.
template<typename T, typename K, typename V>
concept FactoryFn = requires(T t, K key) {
{ t(key) } -> std::convertible_to<V>;
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dalloriam
force-pushed
the
feature/IDX-7025-concepts
branch
from
May 21, 2026 15:05
dedc204 to
56b7e9c
Compare
dalloriam
force-pushed
the
feature/IDX-7025-api-improvements
branch
from
May 21, 2026 15:44
8a83016 to
93dfa25
Compare
dalloriam
marked this pull request as ready for review
May 21, 2026 15:51
dalloriam
force-pushed
the
feature/IDX-7025-concepts
branch
from
May 27, 2026 12:47
56b7e9c to
3229d5b
Compare
dalloriam
force-pushed
the
feature/IDX-7025-api-improvements
branch
from
May 27, 2026 12:50
93dfa25 to
b3f9034
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
Cache::find_or_insert()(src)<=>operator for comparing keys/key views when possible (src)CompositeKey(src)