Skip to content

refactor: sliding expiration cache with cleanup task#389

Merged
sophia-bq merged 3 commits intomainfrom
refactor/sliding-expiration-cache
Mar 4, 2025
Merged

refactor: sliding expiration cache with cleanup task#389
sophia-bq merged 3 commits intomainfrom
refactor/sliding-expiration-cache

Conversation

@sophia-bq
Copy link
Copy Markdown
Contributor

@sophia-bq sophia-bq commented Jan 28, 2025

Summary

Introduces a new class SlidingExpirationCacheWithCleanupTask that asynchronously cleans up the cache.

Description

Instead of cleaning up whenever we access the cache, SlidingExpirationCacheWithCleanupTask cleans up all items of the cache that have expired at the rate of cleanupIntervalNanos given in the constructor.

The cleanup task is only initialized after the first item has been added to the cache. This ensures that static caches can be declared and not used without starting an untracked asynchronous task.

The clear method is also made asynchronous, when it is called the cleanup task is aborted and all items in the cache are disposed of and cleared.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sophia-bq sophia-bq requested a review from a team as a code owner January 28, 2025 01:39
@sophia-bq sophia-bq force-pushed the refactor/sliding-expiration-cache branch from b69c4d4 to 0682fce Compare January 29, 2025 00:03
@sophia-bq sophia-bq added the wip Pull requests that are a work in progress label Feb 3, 2025
@sophia-bq sophia-bq force-pushed the refactor/sliding-expiration-cache branch 2 times, most recently from db605e8 to 083d56f Compare February 4, 2025 17:11
@sophia-bq sophia-bq changed the title refactor: async clear for sliding expiration cache refactor: sliding expiration cache with cleanup task Feb 4, 2025
@sophia-bq sophia-bq force-pushed the refactor/sliding-expiration-cache branch from 083d56f to 1544535 Compare February 4, 2025 17:21
Comment thread common/lib/internal_pooled_connection_provider.ts Outdated
Comment thread common/lib/utils/locales/en.json Outdated
Comment thread tests/unit/sliding_expiration_cache.test.ts
Comment thread tests/unit/sliding_expiration_cache.test.ts
Comment thread common/lib/utils/sliding_expiration_cache_with_cleanup_task.ts Outdated
@sophia-bq sophia-bq force-pushed the refactor/sliding-expiration-cache branch from f0c5c4b to ebf88d4 Compare February 5, 2025 01:19
@sophia-bq sophia-bq added ready for review Pull requests that are ready to be reviewed and removed wip Pull requests that are a work in progress labels Feb 5, 2025
@sophia-bq sophia-bq force-pushed the refactor/sliding-expiration-cache branch from ebf88d4 to c253e10 Compare February 26, 2025 22:56
@sophia-bq sophia-bq force-pushed the refactor/sliding-expiration-cache branch from 25f713d to 0ffe63c Compare March 3, 2025 14:40
@sophia-bq sophia-bq merged commit 9cb9cf2 into main Mar 4, 2025
@sophia-bq sophia-bq deleted the refactor/sliding-expiration-cache branch March 4, 2025 00:47
karenc-bq added a commit that referenced this pull request Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Pull requests that are ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants