/// Returns the count in the current time window.
Returns the count in the current time window.
Returns the count in the current time window .
pub async fn fetch_fixed_window(
        &mut self,
        resource: &str,
        subject: &str,
        size: Duration,
    ) -> Result<u64, Box<dyn Error>> {
        let now = SystemTime::now().duration_since(time::UNIX_EPOCH).unwrap();
        let window = (now.as_secs() / size.as_secs()) * size.as_secs();
        let key = format!("{}:{}:{}:{}", KEY_PREFIX, resource, subject, window);
        let count: u64 = self.conn.get(key).await?;
        Ok(count)
    }
pub async fn fetch_fixed_window ( & mut self , resource : & str , subject : & str , size : Duration , ) -> Result < u64 , Box < dyn Error > > { let now = SystemTime :: now ( ) . duration_since ( time :: UNIX_EPOCH ) . unwrap ( ) ; let window = ( now . as_secs ( ) / size . as_secs ( ) ) * size . as_secs ( ) ; let key = format ! ( " " KEY_PREFIX resource subject window ) ; let count : u64 = self . conn . get ( key ) . await ? ; Ok ( count ) }
Returns the count in the current time window.
Returns the count in the current time window .
&mut self
resource
&str
subject
&str
size
Duration