-
Notifications
You must be signed in to change notification settings - Fork 0
feat: preserve ttl on update #5
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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.