#hash-map #locking #thread-safe #level #key #value #access

lockmap

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

8 releases

new 0.1.7 Jan 23, 2025
0.1.6 Jan 20, 2025
0.1.4 Dec 31, 2024
0.1.1 Nov 22, 2024

#522 in Concurrency

Download history 215/week @ 2024-11-16 71/week @ 2024-11-23 3/week @ 2024-11-30 19/week @ 2024-12-07 272/week @ 2024-12-21 171/week @ 2024-12-28 25/week @ 2025-01-04 5/week @ 2025-01-11 293/week @ 2025-01-18

623 downloads per month
Used in r2pc

MIT/Apache

47KB
987 lines

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