pub trait Cache: Send + Sync {
// Required methods
fn get_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn put_entry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
entry: &'life2 CacheEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn index_restaurants<'life0, 'life1, 'async_trait>(
&'life0 self,
rows: &'life1 [RestaurantRow],
seen_from: Option<(f64, f64)>,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn index_items<'life0, 'life1, 'async_trait>(
&'life0 self,
items: &'life1 [ItemRow],
now: i64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn index_menu<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
restaurant: &'life1 RestaurantRow,
categories: &'life2 [CategoryRow],
items: &'life3 [ItemRow],
seen_from: Option<(f64, f64)>,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn search_restaurants<'life0, 'life1, 'async_trait>(
&'life0 self,
q: &'life1 RestaurantQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<RestaurantHit>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn search_items<'life0, 'life1, 'async_trait>(
&'life0 self,
q: &'life1 ItemQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<ItemHit>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn restaurant<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RestaurantHit>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn image<'life0, 'life1, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_now: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedImage>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn put_image<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_bytes: &'life2 [u8],
_content_type: &'life3 str,
_now: i64,
) -> Pin<Box<dyn Future<Output = Result<CachedImage>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}Expand description
Storage for the read-only browse cache. Object-safe: use it as
Arc<dyn Cache>. Backends store and return data; TTLs, modes and the
read-only safety rules are applied by CacheHandle.
Responses are keyed by CacheKey::hash (namespace and kind are on the
key for housekeeping). Catalog upserts must not erase known fields with
unknowns (a row without cuisines keeps the stored ones). Images are
optional: the default methods store nothing.
Required Methods§
Sourcefn get_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The stored entry for key (expired or not), if any.
Sourcefn put_entry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
entry: &'life2 CacheEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put_entry<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
entry: &'life2 CacheEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Insert or replace the entry for key.
Sourcefn index_restaurants<'life0, 'life1, 'async_trait>(
&'life0 self,
rows: &'life1 [RestaurantRow],
seen_from: Option<(f64, f64)>,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn index_restaurants<'life0, 'life1, 'async_trait>(
&'life0 self,
rows: &'life1 [RestaurantRow],
seen_from: Option<(f64, f64)>,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Upsert restaurants seen in a list response. seen_from is the
delivery location of the request; when given, each row’s distance /
ETA / fee are also recorded for that location.
Sourcefn index_items<'life0, 'life1, 'async_trait>(
&'life0 self,
items: &'life1 [ItemRow],
now: i64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn index_items<'life0, 'life1, 'async_trait>(
&'life0 self,
items: &'life1 [ItemRow],
now: i64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Upsert individual items (e.g. dish hits), keeping known categories.
Store a full menu: the restaurant, its categories (replacing the old ones) and items; items no longer on the menu are removed.
Sourcefn search_restaurants<'life0, 'life1, 'async_trait>(
&'life0 self,
q: &'life1 RestaurantQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<RestaurantHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search_restaurants<'life0, 'life1, 'async_trait>(
&'life0 self,
q: &'life1 RestaurantQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<RestaurantHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Query restaurants in the catalog.
Sourcefn search_items<'life0, 'life1, 'async_trait>(
&'life0 self,
q: &'life1 ItemQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<ItemHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn search_items<'life0, 'life1, 'async_trait>(
&'life0 self,
q: &'life1 ItemQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<ItemHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Query menu items in the catalog.
Sourcefn restaurant<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RestaurantHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn restaurant<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RestaurantHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
One restaurant by id.
Provided Methods§
Sourcefn image<'life0, 'life1, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_now: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedImage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn image<'life0, 'life1, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_now: i64,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedImage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The stored image for url, marking it recently used.
Sourcefn put_image<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_bytes: &'life2 [u8],
_content_type: &'life3 str,
_now: i64,
) -> Pin<Box<dyn Future<Output = Result<CachedImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn put_image<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_url: &'life1 str,
_bytes: &'life2 [u8],
_content_type: &'life3 str,
_now: i64,
) -> Pin<Box<dyn Future<Output = Result<CachedImage>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Store downloaded image bytes for url.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".