pub struct Matecito<K, T>(/* private fields */);
Expand description
Matecito is an experimental concurrent cache. Its main purpose is to give a thread safe interface to use an in-memory storage for some expensive computations.
§Example
use matecito::Matecito;
// Initialize the cache with space for 1024 objects.
let m = Matecito::<u64, String>::new(2usize.pow(10));
let m1 = m.clone();
std::thread::spawn(move || {
m1.put(123, "asd".to_string());
m1.put(01010101, "321".to_string());
});
// We need to give the cache a sec to populate the values.
std::thread::sleep(std::time::Duration::from_millis(1));
assert_eq!(Some("asd".to_string()), m.get(123));
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<K, T> Freeze for Matecito<K, T>
impl<K, T> !RefUnwindSafe for Matecito<K, T>
impl<K, T> Send for Matecito<K, T>
impl<K, T> Sync for Matecito<K, T>
impl<K, T> Unpin for Matecito<K, T>
impl<K, T> !UnwindSafe for Matecito<K, T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)