Struct Stats

Source
pub struct Stats { /* private fields */ }

Implementations§

Source§

impl Stats

Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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]);
Source

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);
Source

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());
Source

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§

Source§

impl Debug for Stats

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.