#value #map #access #lockmap #lock-map

lockmap

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

10 releases

0.1.9 Feb 19, 2025
0.1.8 Feb 10, 2025
0.1.7 Jan 23, 2025
0.1.4 Dec 31, 2024
0.1.1 Nov 22, 2024

#245 in Concurrency

Download history 189/week @ 2025-01-14 168/week @ 2025-01-21 4/week @ 2025-01-28 83/week @ 2025-02-04 73/week @ 2025-02-11 155/week @ 2025-02-18 629/week @ 2025-02-25 592/week @ 2025-03-04 491/week @ 2025-03-11 273/week @ 2025-03-18 157/week @ 2025-03-25 147/week @ 2025-04-01 134/week @ 2025-04-08 158/week @ 2025-04-15 83/week @ 2025-04-22 29/week @ 2025-04-29

440 downloads per month
Used in r2pc

MIT/Apache

51KB
1K SLoC

lockmap

Rust codecov Crates.io Documentation

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

Dependencies

~0–10MB
~43K SLoC