pub struct MemoryCache { /* private fields */ }Expand description
Everything in memory, behind one mutex.
Trait Implementations§
Source§impl Cache for MemoryCache
impl Cache for MemoryCache
Source§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 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.Source§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 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.Source§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_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.Source§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_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.
Source§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_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.
Source§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 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.
Source§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,
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.
Source§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 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.Source§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,
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.Source§impl Debug for MemoryCache
impl Debug for MemoryCache
Auto Trait Implementations§
impl !Freeze for MemoryCache
impl Forget for MemoryCache
impl RefUnwindSafe for MemoryCache
impl Send for MemoryCache
impl Sync for MemoryCache
impl Unpin for MemoryCache
impl UnsafeUnpin for MemoryCache
impl UnwindSafe for MemoryCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more