Skip to main content

FeedCache

Trait FeedCache 

Source
pub trait FeedCache: Send + Sync {
    // Required methods
    fn get(&self, key: &str) -> Result<Option<String>>;
    fn put(&self, key: &str, value: &str) -> Result<()>;
}
Expand description

What: Define caller-owned storage for raw news and advisory feed payloads.

Inputs:

  • key: Stable feed key supplied by the news fetch helper.
  • value: Raw successful feed payload to store.

Output:

  • Cached payloads on hits and explicit errors from a caller’s storage backend.

Details:

  • The boundary is intentionally independent from the AUR cache and makes no assumptions about persistence, expiration, encryption, or eviction.
  • Callers own freshness policy; a cache implementation can decline a stale entry by returning Ok(None).

Required Methods§

Source

fn get(&self, key: &str) -> Result<Option<String>>

What: Look up a raw feed payload by a stable key.

Inputs:

  • key: Namespaced key generated from the feed kind and URL.

Output:

  • Ok(Some(payload)) for a cache hit, Ok(None) for a miss, or an error when the backing store cannot be read.

Details:

  • Implementations should enforce their own expiration policy before returning a payload.
§Errors

Returns a backing-store error when the requested payload cannot be read.

Source

fn put(&self, key: &str, value: &str) -> Result<()>

What: Store a raw feed payload under a stable key.

Inputs:

  • key: Namespaced key generated from the feed kind and URL.
  • value: Successful bounded response body to store.

Output:

  • Ok(()) when the value is stored, otherwise a backing-store error.

Details:

  • Feed fetches surface write errors explicitly so callers do not mistake an unavailable requested cache for a successful durable cache write.
§Errors

Returns a backing-store error when the payload cannot be stored.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§