shared_hashmap

Crates.ioshared_hashmap
lib.rsshared_hashmap
version0.1.2
sourcesrc
created_at2023-06-24 08:41:59.422727
updated_at2023-10-03 13:23:29.762263
descriptionA shared hashmap for use between processes, using shared memory
homepage
repositoryhttps://github.com/humanmade/shared_hashmap/
max_upload_size
id898852
size28,596
Joe Hoyle (joehoyle)

documentation

README

Shared HashMap

Continuous integration

A shared memory hashmap including LRU eviction.

This crate provides a shared hashmap limited by memory size that can be used between difference processes and thread. This is achieved by using the shared_memory crate and raw_sync-rs for IPC mutexes.

The SharedMemoryHashMap internally handles locking and serializing of Keys and Values in an optimized memory layout. Current the LRU implementation is basic, using timestamps for access rather than an ordered key-list. Implementing a key-list for LRU purposes is possible but requires more manual memory management.

Usage

use shared_memory_hashmap::SharedMemoryHashMap;

fn main() {
    let mut map = SharedMemoryHashMap::new(1024); // bytes.
    map.insert(1, "Hello");
    map.insert(2, "World");

    map2 = map.clone(); // map2 uses the same shared memory block as `map`.
    spawn(|| move {
        map2.insert(3, "Goodbye");
    });
}
Commit count: 26

cargo fmt