Skip to content

Add Caffeine cache utility and coroutine scheduling functions#313

Merged
twisti-dev merged 6 commits intoversion/26.1from
feat/more-utils
Apr 18, 2026
Merged

Add Caffeine cache utility and coroutine scheduling functions#313
twisti-dev merged 6 commits intoversion/26.1from
feat/more-utils

Conversation

@twisti-dev
Copy link
Copy Markdown
Contributor

This pull request introduces new utility functions for cache management and coroutine scheduling, and bumps the project version to 3.2.0. The most significant changes are the addition of utilities for Caffeine cache auto-closing and advanced coroutine scheduling helpers, which will help manage resources and periodic tasks more safely and conveniently.

New utility features:

  • Added withAutoCloseOnRemoval extension function for Caffeine caches in caffeine-util.kt, allowing automatic closing of keys and values that implement AutoCloseable when they are removed from the cache, with error handling and optional custom removal listener.
  • Introduced coroutine scheduling helpers in coroutine-util.kt:
    • runAtFixedRate: runs a suspending block at a fixed rate, regardless of execution time.
    • runWithFixedDelay: runs a suspending block with a fixed delay after each execution.
    • runUntil: runs a suspending block repeatedly with a delay, stopping when a predicate returns false.

API surface updates:

  • Added new public classes and functions to the API surface in surf-api-core.api for the new cache and coroutine utilities.

Project metadata:

  • Bumped the project version from 3.1.1 to 3.2.0 in gradle.properties.

- introduce withAutoCloseOnRemoval extension for Caffeine cache builder
- ensure AutoCloseable keys and values are closed on removal
- add error handling and logging for removal and close operations
- document behavior, parameters, and return value of withAutoCloseOnRemoval extension
- clarify auto-close logic and exception handling in removal listener
…ed delay, and conditional loops

- introduce runAtFixedRate for scheduling coroutines at a fixed interval
- add runWithFixedDelay for repeated execution with a fixed delay between runs
- implement runUntil for conditional repeated execution with delay and predicate
- include kdoc for all new coroutine utility functions
@twisti-dev twisti-dev self-assigned this Apr 18, 2026
@twisti-dev twisti-dev merged commit b5002b2 into version/26.1 Apr 18, 2026
4 checks passed
@twisti-dev twisti-dev deleted the feat/more-utils branch April 18, 2026 18:58
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.

1 participant