-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancements to SlidingCache<> for Improved Thread Safety and Performance #769
Labels
Comments
TWhidden
pushed a commit
to TWhidden/System.Linq.Dynamic.Core
that referenced
this issue
Feb 2, 2024
…Safety and Performance
This was referenced Feb 2, 2024
TWhidden
pushed a commit
to TWhidden/System.Linq.Dynamic.Core
that referenced
this issue
Feb 3, 2024
TWhidden
pushed a commit
to TWhidden/System.Linq.Dynamic.Core
that referenced
this issue
Feb 3, 2024
StefH
pushed a commit
that referenced
this issue
Feb 3, 2024
…ance (#770) * #769 - Enhancements to SlidingCache<> for Improved Thread Safety and Performance * #769 - Rename Config ReturnExpiredItems; Refactor Tests * #769 - SlidingCache Test Code-Comment Cleanup --------- Co-authored-by: Travis Whidden <[email protected]>
@TWhidden |
It's currently running in a beta instance without any known issues. I have not rolled it to prod yet. I'll try to get that out this week or early next week. Sorry for the delay. |
Did you have time to test it? |
Ok, pushed to production - will follow up in a couple days. |
Hello @TWhidden, what is the status? |
Thanks for verifying. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the latest update to the
SlidingCache<>
implementation, we addressed a critical oversight related to concurrent modifications and access patterns. Specifically, we identified that a cache key could be removed during enumeration, triggering aKeyNotFoundException
. To address these concerns and enhance the cache's robustness and efficiency, the following adjustments were made:Atomic Locking with
Interlocked.CompareExchange
: We introduced an atomic lock mechanism usingInterlocked.CompareExchange
to prevent simultaneous entries into theCleanup
method. This enhancement aims to significantly reduce contention and ensure thread-safe operations within the cache cleanup process.Deferred Cleanup Execution: The
CleanupIfNeeded
method has been relocated to a finally block following theTryGetValue
execution. This will ensure that ifPermitExpiredReturns
is enabled, there is no race to remove the item while accessing it.Support for Deterministic Element Caching: A new parameter has been added to
SlidingCache<>
, enabling the caching of expired but deterministic elements. This feature allows expired objects to remain accessible before the Cleanup process has executed, preventing unnecessary removals and recreations. This capability is particularly beneficial forConstantExpressions
and is enabled by default to optimize performance for predictable data patterns.Configurable Expired Returns via
CacheConfig
: To provide greater control over cache behavior, thePermitExpiredReturns
setting has been incorporated into theCacheConfig
class. This addition allows developers to manage the allowance of expired item returns based on their specific application requirements and caching strategies.These enhancements are designed to bolster the
SlidingCache<>
's performance, reliability, and flexibility, particularly in high-concurrency environments.The text was updated successfully, but these errors were encountered: