lockmap

Crates.iolockmap
lib.rslockmap
version0.1.14
created_at2024-11-21 06:11:42.073079+00
updated_at2025-09-04 02:22:43.41787+00
descriptionA high-performance, thread-safe HashMap implementation for Rust that provides fine-grained locking at the key level.
homepagehttps://github.com/SF-Zhou/lockmap
repositoryhttps://github.com/SF-Zhou/lockmap
max_upload_size
id1455758
size108,070
(SF-Zhou)

documentation

README

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

Commit count: 17

cargo fmt