#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

7 releases

new 0.1.6 Jan 20, 2025
0.1.5 Jan 18, 2025
0.1.4 Dec 31, 2024
0.1.1 Nov 22, 2024

#688 in Concurrency

Download history 266/week @ 2024-11-18 23/week @ 2024-11-25 19/week @ 2024-12-09 316/week @ 2024-12-23 136/week @ 2024-12-30 18/week @ 2025-01-06 57/week @ 2025-01-13

527 downloads per month

MIT/Apache

45KB
922 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");
    *entry.get_mut() = Some("new value".into());
}

// Remove a value
assert_eq!(map.remove("key"), Some("new value".into()));

Dependencies

~0–10MB
~43K SLoC