pub struct Stats { /* private fields */ }Implementations§
Source§impl Stats
impl Stats
Sourcepub fn new(
max_size: u64,
used_size: u64,
num_objects: u64,
total_gets: u64,
total_sets: u64,
total_dels: u64,
miss_ratio: f64,
policies: Vec<PaperPolicy>,
policy: PaperPolicy,
is_auto_policy: bool,
uptime: u64,
) -> Self
pub fn new( max_size: u64, used_size: u64, num_objects: u64, total_gets: u64, total_sets: u64, total_dels: u64, miss_ratio: f64, policies: Vec<PaperPolicy>, policy: PaperPolicy, is_auto_policy: bool, uptime: u64, ) -> Self
Creates a new instance of the cache’s stats.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 0, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);Sourcepub fn get_max_size(&self) -> u64
pub fn get_max_size(&self) -> u64
Returns the cache’s maximum size in bytes.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(1000, 0, 0, 0, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_max_size(), 1000);Sourcepub fn get_used_size(&self) -> u64
pub fn get_used_size(&self) -> u64
Returns the cache’s used size in bytes.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(1000, 500, 0, 0, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_used_size(), 500);Sourcepub fn get_num_objects(&self) -> u64
pub fn get_num_objects(&self) -> u64
Returns the number of objects in the cache.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(1000, 500, 10, 0, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_num_objects(), 10);Sourcepub fn get_total_gets(&self) -> u64
pub fn get_total_gets(&self) -> u64
Returns the cache’s total number of gets.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 10, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_total_gets(), 10);Sourcepub fn get_total_sets(&self) -> u64
pub fn get_total_sets(&self) -> u64
Returns the cache’s total number of sets.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 0, 10, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_total_sets(), 10);Sourcepub fn get_total_dels(&self) -> u64
pub fn get_total_dels(&self) -> u64
Returns the cache’s total number of dels.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 0, 0, 10, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_total_dels(), 10);Sourcepub fn get_miss_ratio(&self) -> f64
pub fn get_miss_ratio(&self) -> f64
Returns the cache’s miss ratio.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 0, 0, 0, 1.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_miss_ratio(), 1.0);Sourcepub fn get_policies(&self) -> &[PaperPolicy]
pub fn get_policies(&self) -> &[PaperPolicy]
Returns the cache’s configured eviction policies.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 0, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_policies(), &[PaperPolicy::Lru]);Sourcepub fn get_policy(&self) -> &PaperPolicy
pub fn get_policy(&self) -> &PaperPolicy
Returns the cache’s eviction policy.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 0, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 0);
assert_eq!(stats.get_policy(), &PaperPolicy::Lru);Sourcepub fn is_auto_policy(&self) -> bool
pub fn is_auto_policy(&self) -> bool
Returns true if the cache is configured to the PaperPolicy::Auto
eviction policy.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 0, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, true, 0);
assert!(stats.is_auto_policy());Sourcepub fn get_uptime(&self) -> u64
pub fn get_uptime(&self) -> u64
Returns the cache’s uptime.
§Examples
use paper_client::{Stats, PaperPolicy};
let stats = Stats::new(0, 0, 0, 0, 0, 0, 0.0, vec![PaperPolicy::Lru], PaperPolicy::Lru, false, 1);
assert_eq!(stats.get_uptime(), 1);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Stats
impl RefUnwindSafe for Stats
impl Send for Stats
impl Sync for Stats
impl Unpin for Stats
impl UnwindSafe for Stats
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