Skip to content
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

#15 implement key expiration and cache eviction policy #16

Merged
merged 4 commits into from
Aug 16, 2024

Conversation

ezrasingh
Copy link
Owner

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Key Changes

This PR implements key expiration and a cache eviction policy, addressing issue #15. The key expiration is managed using a BTreeSet<(Instant, String)> to store expiration keys. To purge expired keys, the BTreeSet is split from the oldest keys up to Instant::now(), effectively targeting the subset of expired keys.

In the Geoprox server, a separate thread is spawned that runs in a sidecar state (Arc::clone of the app state). This thread executes an async loop that checks and removes expired keys every second.

Additional tests have been added to validate the purging process and the async loop runtime. Running cargo test is sufficient to verify the implementation.

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

To test the changes:

  1. Run cargo test to validate the key expiration and cache eviction functionality.
  2. Confirm that expired keys are purged correctly by examining the test results.

Added/updated tests?

  • Yes
  • No, and this is why: please replace this line with details on why tests have not been included
  • I need help with writing tests

@ezrasingh ezrasingh linked an issue Aug 16, 2024 that may be closed by this pull request
@ezrasingh ezrasingh self-assigned this Aug 16, 2024
@ezrasingh ezrasingh added the enhancement New feature or request label Aug 16, 2024
@ezrasingh ezrasingh added this to the v1.0.0 milestone Aug 16, 2024
@ezrasingh ezrasingh merged commit e67e217 into main Aug 16, 2024
4 checks passed
@ezrasingh ezrasingh deleted the 15-implement-key-expiration-and-cache-eviction-policy branch August 16, 2024 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement Key Expiration and Cache Eviction Policy
1 participant