async fn save_to_db(
        &self,
        key: &ImageKey,
        mime_type: String,
        data: Bytes,
    ) -> Result<(), CacheError> {
        let entry = ImageEntry::new_assume(data, mime_type);
        let ser_bytes: Bytes = entry.try_into().map_err(CacheError::Bincode)?;
        self.cache
            .write(key.as_bkey(), &ser_bytes)
            .await
            .map_err(CacheError::Forceps)?;

        // update the total size counter with the new storage value
        self.total
            .fetch_add(ser_bytes.len() as u64, Ordering::SeqCst);
        Ok(())
    }
/// Writes an entry to the database and returns the error that occurs
Writes an entry to the database and returns the error that occurs
Writes an entry to the database and returns the error that occurs
async fn save_to_db(
        &self,
        key: &ImageKey,
        mime_type: String,
        data: Bytes,
    ) -> Result<(), CacheError> {
        let entry = ImageEntry::new_assume(data, mime_type);
        let ser_bytes: Bytes = entry.try_into().map_err(CacheError::Bincode)?;
        self.cache
            .write(key.as_bkey(), &ser_bytes)
            .await
            .map_err(CacheError::Forceps)?;
        // update the total size counter with the new storage value
        self.total
            .fetch_add(ser_bytes.len() as u64, Ordering::SeqCst);
        Ok(())
    }
async fn save_to_db ( & self , key : & ImageKey , mime_type : String , data : Bytes , ) -> Result < ( ) , CacheError > { let entry = ImageEntry :: new_assume ( data , mime_type ) ; let ser_bytes : Bytes = entry . try_into ( ) . map_err ( CacheError :: Bincode ) ? ; self . cache . write ( key . as_bkey ( ) , & ser_bytes ) . await . map_err ( CacheError :: Forceps ) ? ; // update the total size counter with the new storage value self . total . fetch_add ( ser_bytes . len ( ) as u64 , Ordering :: SeqCst ) ; Ok ( ( ) ) }
Writes an entry to the database and returns the error that occurs
Writes an entry to the database and returns the error that occurs
&self
key
&ImageKey
mime_type
String
data
Bytes