#value #map #access

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

#205 in Concurrency

Download history 8/week @ 2024-12-04 11/week @ 2024-12-11 416/week @ 2024-12-25 42/week @ 2025-01-01 15/week @ 2025-01-08 223/week @ 2025-01-15 135/week @ 2025-01-22 3/week @ 2025-01-29 94/week @ 2025-02-05 71/week @ 2025-02-12 147/week @ 2025-02-19 782/week @ 2025-02-26 566/week @ 2025-03-05 420/week @ 2025-03-12 269/week @ 2025-03-19

2,039 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