mincache 0.1.0

Minimal function return caching crate
Documentation
  • Coverage
  • 25%
    1 out of 4 items documented0 out of 3 items with examples
  • Size
  • Source code size: 6.64 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.27 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • vurvdev/mincache
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • thevurv

mincache

Minimal crate to cache return values of your function returns.

Currently only supports a timer / cooldown cache.

Example

pub use mincache::timecache;

// "fmt" is what you'd put after core::time::Duration::from_<>. E.g. "secs", "millis", "nanos", etc.
#[timecache(time = 5000, fmt = "secs")]
pub fn xyz(x: i32) -> std::time::Instant {
	println!("This will print once {x}");

	// This value will be cloned each time this is called before the cooldown is over
	// If you want to instead pass a reference, look into mincache/tests/ref.rs
	// (just add ``reference = true`` to the attribute params)
	std::time::Instant::now()
}

#[test]
fn main() {
	// Will call the function a single time.
	for _ in 0..1000000 {
		let xyz = xyz(55);
	}
}