Skip to content

Conversation

@praserx
Copy link
Owner

@praserx praserx commented Jul 22, 2025

This pull request introduces several improvements and optimizations to the atomic-cache library, including enhanced benchmarking documentation, new features for cache expiration handling, performance optimizations in the Set method, and additional test coverage for shards and cache behavior.

Benchmarking Updates:

  • Updated benchmark results in README.md to 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:

  • Introduced a new constant KeepTTL to allow updates to cache records while preserving their existing expiration times.
  • Added support for KeepTTL in the Set method, enabling more flexible expiration management.

Performance Optimizations:

  • Optimized the Set method in cache.go to minimize locking and improve efficiency when updating existing records or allocating new ones.
  • Added the Seti method in shard.go to directly update shard memory by index, reducing overhead for in-place updates.

Test Enhancements:

  • Added unit tests for the new KeepTTL functionality to ensure expiration times are preserved during updates.
  • Expanded shard tests to include scenarios for Seti, slot availability, and shard empty state validation.

These changes collectively improve the library's performance, flexibility, and reliability.

praserx added 4 commits July 22, 2025 10:31
- 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.
@praserx praserx requested a review from Copilot July 22, 2025 08:46
@praserx praserx self-assigned this Jul 22, 2025
Copy link
Contributor

Copilot AI left a 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 KeepTTL constant 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)

praserx and others added 5 commits July 22, 2025 10:48
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>
@praserx praserx merged commit c099aa8 into master Jul 22, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants