#value #map #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

#249 in Concurrency

Download history 302/week @ 2024-12-22 145/week @ 2024-12-29 22/week @ 2025-01-05 66/week @ 2025-01-12 283/week @ 2025-01-19 14/week @ 2025-01-26 5/week @ 2025-02-02 144/week @ 2025-02-09 154/week @ 2025-02-16 337/week @ 2025-02-23 802/week @ 2025-03-02 503/week @ 2025-03-09 299/week @ 2025-03-16 176/week @ 2025-03-23 135/week @ 2025-03-30 140/week @ 2025-04-06

787 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