Conversation
- Implemented Seti method to update data in shard memory based on index. - Added tests for Seti method, including validation for out-of-bounds index. - Enhanced existing tests for shard functionality.
Introduce KeepTTL constant to allow records to retain their current expiration time when updated. This enhances the flexibility of the Set method in managing cache records.
Implement a test to verify that updating a cache value with KeepTTL maintains the original expiration time while allowing the value to be updated.
- Added system information to benchmark results for better context. - Updated benchmark results to reflect recent performance measurements.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces the ability to preserve TTL when updating cache entries, along with performance optimizations to the cache's Set method and comprehensive test coverage for the new functionality.
Key changes include:
- Added
KeepTTLconstant to allow updates while preserving existing expiration times - Optimized the Set method to minimize locking and improve efficiency for existing record updates
- Enhanced test coverage for shards and the new TTL preservation feature
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| cache.go | Added KeepTTL constant and optimized Set method with reduced locking and new Seti usage |
| shard.go | Added Seti method for direct index-based updates without bounds checking |
| cache_test.go | Added test coverage for KeepTTL functionality |
| shard_test.go | Added comprehensive tests for Seti, Free, IsEmpty, and GetSlotsAvail methods |
| README.md | Updated benchmark results with system specifications and improved performance metrics |
Comments suppressed due to low confidence (1)
shard_test.go:16
- Error message references 'SetI' but the method name is 'Seti'. The error message should use the correct method name for clarity.
t.Errorf("SetI: got %v, want %v", got, want)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
This pull request introduces several improvements and optimizations to the
atomic-cachelibrary, including enhanced benchmarking documentation, new features for cache expiration handling, performance optimizations in theSetmethod, and additional test coverage for shards and cache behavior.Benchmarking Updates:
README.mdto reflect the latest performance metrics, including reduced memory allocations and improved operation times. Added system details (e.g., OS, architecture, and CPU) for reproducibility. [1] [2]New Features:
KeepTTLto allow updates to cache records while preserving their existing expiration times.KeepTTLin theSetmethod, enabling more flexible expiration management.Performance Optimizations:
Setmethod incache.goto minimize locking and improve efficiency when updating existing records or allocating new ones.Setimethod inshard.goto directly update shard memory by index, reducing overhead for in-place updates.Test Enhancements:
KeepTTLfunctionality to ensure expiration times are preserved during updates.Seti, slot availability, and shard empty state validation.These changes collectively improve the library's performance, flexibility, and reliability.