async fn save_entry(&self, key: &ImageKey, mut entry: ImageEntry) -> Result<(), CacheError> {
        use std::convert::TryInto;
        let bkey = Bytes::copy_from_slice(&key.as_bkey());

        // create the future that will save the image data
        let bytes = std::mem::replace(&mut entry.bytes, Bytes::new());
        let images_fut = self.put_cf_async(Self::IMAGES_CF, bkey.clone(), bytes);

        // create the future that will save the metadata (first omitting the bytes)
        let len = entry.get_bytes_len();
        let meta_fut = self.put_cf_async(
            Self::META_CF,
            bkey,
            entry.try_into().map_err(CacheError::Bincode)?,
        );

        // update the db size counter
        self.db_size.fetch_add(len, Ordering::Relaxed);

        tokio::try_join!(images_fut, meta_fut)?;
        Ok(())
    }
/// Saves an ImageEntry to the database at the specified key
///
/// Returns early if an error occurred on any DB operation
Saves an ImageEntry to the database at the specified key
Returns early if an error occurred on any DB operation
Saves an ImageEntry to the database at the specified key Returns early if an error occurred on any DB operation
async fn save_entry(&self, key: &ImageKey, mut entry: ImageEntry) -> Result<(), CacheError> {
        use std::convert::TryInto;
        let bkey = Bytes::copy_from_slice(&key.as_bkey());
        // create the future that will save the image data
        let bytes = std::mem::replace(&mut entry.bytes, Bytes::new());
        let images_fut = self.put_cf_async(Self::IMAGES_CF, bkey.clone(), bytes);
        // create the future that will save the metadata (first omitting the bytes)
        let len = entry.get_bytes_len();
        let meta_fut = self.put_cf_async(
            Self::META_CF,
            bkey,
            entry.try_into().map_err(CacheError::Bincode)?,
        );
        // update the db size counter
        self.db_size.fetch_add(len, Ordering::Relaxed);
        tokio::try_join!(images_fut, meta_fut)?;
        Ok(())
    }
async fn save_entry ( & self , key : & ImageKey , mut entry : ImageEntry ) -> Result < ( ) , CacheError > { use std :: convert :: TryInto ; let bkey = Bytes :: copy_from_slice ( & key . as_bkey ( ) ) ; // create the future that will save the image data let bytes = std :: mem :: replace ( & mut entry . bytes , Bytes :: new ( ) ) ; let images_fut = self . put_cf_async ( Self :: IMAGES_CF , bkey . clone ( ) , bytes ) ; // create the future that will save the metadata (first omitting the bytes) let len = entry . get_bytes_len ( ) ; let meta_fut = self . put_cf_async ( Self :: META_CF , bkey , entry . try_into ( ) . map_err ( CacheError :: Bincode ) ? , ) ; // update the db size counter self . db_size . fetch_add ( len , Ordering :: Relaxed ) ; tokio :: try_join ! ( images_fut meta_fut ) ? ; Ok ( ( ) ) }
Saves an ImageEntry to the database at the specified key
Returns early if an error occurred on any DB operation
Saves an ImageEntry to the database at the specified key Returns early if an error occurred on any DB operation
&self
key
&ImageKey
entry
ImageEntry