Skip to main content

Module offload

Module offload 

Source
Expand description

Background task offloading for stale-while-revalidate.

When using the OffloadRevalidate stale policy, expired cache entries are served immediately while fresh data is fetched in the background. This module provides the OffloadManager for handling these background tasks. Offload manager for background task execution.

This module provides infrastructure for offloading tasks to background execution, primarily used for Stale-While-Revalidate (SWR) cache pattern where stale data is returned immediately while cache revalidation happens asynchronously.

§Example

use hitbox::offload::{OffloadManager, OffloadConfig};

let config = OffloadConfig::default();
let manager = OffloadManager::new(config);

// Spawn a background task
manager.spawn(async {
    // Revalidation logic here
});

Structs§

OffloadConfig
Configuration for the OffloadManager.
OffloadConfigBuilder
Builder for OffloadConfig.
OffloadHandle
Handle to a spawned offload task.
OffloadManager
Manager for offloading tasks to background execution.
SmolStr
A SmolStr is a string type that has the following properties:

Enums§

OffloadKey
Key for identifying offloaded tasks.
TimeoutPolicy
Policy for handling task timeouts.