Skip to content

Commit

Permalink
Store qualified counters in dedicated capacity limited cache
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsnaps committed Jul 31, 2023
1 parent f63bdb7 commit ac1e00b
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 97 deletions.
153 changes: 153 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions limitador/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ infinispan_storage = ["infinispan", "reqwest", "base64"]
lenient_conditions = []

[dependencies]
moka = "0.11.2"
ttl_cache = "0.5"
serde = { version = "1", features = ["derive"] }
postcard = { version = "1.0.4", features = ["use-std"] }
Expand Down
4 changes: 4 additions & 0 deletions limitador/src/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ impl Counter {
self.expires_in = Some(duration)
}

pub fn is_qualified(&self) -> bool {
!self.set_variables.is_empty()
}

#[cfg(feature = "disk_storage")]
pub(crate) fn variables_for_key(&self) -> Vec<(&str, &str)> {
let mut variables = Vec::with_capacity(self.set_variables.len());
Expand Down
Loading

0 comments on commit ac1e00b

Please sign in to comment.