lockmap 0.1.15

A high-performance, thread-safe HashMap implementation for Rust that provides fine-grained locking at the key level.
Documentation
lockmap-0.1.15 has been yanked.

lockmap

Rust codecov Crates.io Documentation FOSSA Status

A high-performance, thread-safe HashMap implementation for Rust that provides fine-grained locking at the key level.

Usage

use lockmap::LockMap;

// Create a new lock map
let map = LockMap::<String, String>::new();

// Set a value
map.insert_by_ref("key", "value".into());

// Get a value
assert_eq!(map.get("key"), Some("value".into()));

// Use entry API for exclusive access
{
    let mut entry = map.entry_by_ref("key");
    assert_eq!(entry.get().as_deref(), Some("value"));
    entry.insert("new value".to_string());
}

// Remove a value
assert_eq!(map.remove("key"), Some("new value".into()));

// Batch lock.
let mut keys = std::collections::BTreeSet::new();
keys.insert("key1".to_string());
keys.insert("key2".to_string());
let mut locked_entries = map.batch_lock::<std::collections::HashMap<_, _>>(keys);

License

FOSSA Status