# orcaman/concurrent-map

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/orcaman-concurrent-map).**

4,528 stars · 556 forks · Go · mit

## Links

- GitHub: https://github.com/orcaman/concurrent-map
- awesome-repositories: https://awesome-repositories.com/repository/orcaman-concurrent-map.md

## Topics

`concurrency` `concurrent-programming` `go` `golang` `map` `thread-safety`

## Description

Concurrent-map is a lock-striped hash map and sharded concurrent cache for Go, designed as a high-performance key-value store that enables thread-safe parallel reads and writes with minimal blocking. It replaces a single global mutex with per-shard locking, using hash-based key distribution to assign entries to independent segments, allowing multiple goroutines to operate simultaneously without race conditions.

The library achieves its performance through fine-grained locking and a lock-free read path, where each shard operates independently with its own lock, enabling parallel reads and writes across different shards without interference. It supports snapshot-based iteration, allowing safe traversal of all entries while concurrent modifications occur, and provides standard key-value operations including insertion, retrieval, deletion, existence checks, counting, and clearing all entries in a thread-safe manner.

As a sharded in-memory cache, concurrent-map partitions data into independent segments to reduce lock contention and maximize throughput for concurrent access patterns. The project is distributed as a Go package with a straightforward API for storing and retrieving key-value pairs across multiple goroutines.

## Tags

### Data & Databases

- [Concurrent Map Implementations](https://awesome-repositories.com/f/data-databases/key-value-pair-managers/concurrent-map-implementations.md) — Provides a high-performance concurrent map implementation optimized for parallel reads and writes.
- [Sharded Read-Write Operations](https://awesome-repositories.com/f/data-databases/acid-transactional-cores/concurrent-read-write-transactions/sharded-read-write-operations.md) — Divides a map into shards each with its own lock so multiple goroutines can read and write simultaneously. ([source](https://github.com/orcaman/concurrent-map#readme))
- [Thread-Safe Sharded Caches](https://awesome-repositories.com/f/data-databases/distributed-caching/distributed-data-caching-layers/thread-safe-sharded-caches.md) — Provides a thread-safe in-memory cache supporting parallel reads and writes without race conditions.
- [Concurrent Store-and-Retrieve Operations](https://awesome-repositories.com/f/data-databases/high-concurrency-database-access/concurrent-read-access/concurrent-store-and-retrieve-operations.md) — Stores and retrieves key-value pairs across multiple shards so goroutines can read and write without blocking. ([source](https://github.com/orcaman/concurrent-map/blob/master/concurrent_map.go))
- [Key-Value Pair Managers](https://awesome-repositories.com/f/data-databases/key-value-pair-managers.md) — Provides concurrent-safe insertion and update of key-value pairs in a sharded map. ([source](https://github.com/orcaman/concurrent-map/blob/master/README.md))
- [Key-Value Stores](https://awesome-repositories.com/f/data-databases/key-value-stores.md) — Delivers a high-performance key-value store optimized for concurrent access across many goroutines.
- [Concurrent](https://awesome-repositories.com/f/data-databases/key-value-stores/concurrent.md) — Stores and retrieves values by key across multiple goroutines without data races or corruption. ([source](https://github.com/orcaman/concurrent-map/blob/master/.gitignore))
- [Map Key Removals](https://awesome-repositories.com/f/data-databases/key-value-stores/structured-object-mappings/object-linked-key-value-mappings/map-key-removals.md) — Provides concurrent-safe deletion of key-value pairs from a sharded map structure. ([source](https://github.com/orcaman/concurrent-map/blob/master/.gitignore))
- [Safe Key Accessors](https://awesome-repositories.com/f/data-databases/storage-engines/key-value/safe-key-accessors.md) — Implements safe key-value retrieval with existence checks for concurrent read access. ([source](https://github.com/orcaman/concurrent-map/blob/master/README.md))
- [Snapshot Iterations](https://awesome-repositories.com/f/data-databases/concurrent-data-processors/parallel-snapshot-iteration/snapshot-iterations.md) — Supports snapshot-based iteration allowing safe traversal of all entries while concurrent modifications occur.
- [Key-Value Store Iterators](https://awesome-repositories.com/f/data-databases/key-value-store-iterators.md) — Walks through all key-value pairs in the map using a callback function while maintaining thread safety. ([source](https://github.com/orcaman/concurrent-map/blob/master/.gitignore))
- [Concurrent Map Iterators](https://awesome-repositories.com/f/data-databases/key-value-store-iterators/concurrent-map-iterators.md) — Walks every key-value pair in the map while other goroutines continue to modify it using a snapshot or lock-per-shard strategy. ([source](https://github.com/orcaman/concurrent-map/blob/master/concurrent_map.go))
- [Parallel Shard Reads and Writes](https://awesome-repositories.com/f/data-databases/read-and-write-splitting/parallel-shard-reads-and-writes.md) — Enables simultaneous reads and writes across different map shards to avoid global lock contention. ([source](https://github.com/orcaman/concurrent-map/blob/master/go.mod))

### Programming Languages & Runtimes

- [Concurrent Data Structures](https://awesome-repositories.com/f/programming-languages-runtimes/concurrent-data-structures.md) — Implements a thread-safe concurrent map data structure for multi-goroutine environments.

### Security & Cryptography

- [Concurrent Shared-Map Access](https://awesome-repositories.com/f/security-cryptography/row-level-security/concurrent-shared-map-access.md) — Partitions the map into shards each with its own lock so multiple goroutines can read and write with minimal contention. ([source](https://github.com/orcaman/concurrent-map#readme))

### Software Engineering & Architecture

- [Fine-Grained Locking](https://awesome-repositories.com/f/software-engineering-architecture/fine-grained-locking.md) — Implements per-shard locking to enable parallel reads and writes across independent map segments.
- [Hash-Based Data Distribution](https://awesome-repositories.com/f/software-engineering-architecture/hash-based-data-distribution.md) — Uses a hash function to distribute keys across shards for balanced load and deterministic placement.
- [Lock-Striped Sharding](https://awesome-repositories.com/f/software-engineering-architecture/producer-consumer-workflow-managers/lock-free-concurrent-queues/locking-optimizations/lock-striped-sharding.md) — Divides the map into independent segments each with its own lock to reduce contention during concurrent access.
- [Lock-Striped Hash Maps](https://awesome-repositories.com/f/software-engineering-architecture/producer-consumer-workflow-managers/lock-free-concurrent-queues/locking-optimizations/lock-striped-sharding/lock-striped-hash-maps.md) — Implements a lock-striped hash map that reduces contention through fine-grained per-shard locking.
- [Sharded Key-Value Stores](https://awesome-repositories.com/f/software-engineering-architecture/producer-consumer-workflow-managers/lock-free-concurrent-queues/locking-optimizations/lock-striped-sharding/sharded-key-value-stores.md) — Partitions data into independent shards with per-shard locks for high-throughput concurrent access.
- [Lock-Free Read Paths](https://awesome-repositories.com/f/software-engineering-architecture/producer-consumer-workflow-managers/lock-free-concurrent-queues/locking-optimizations/lock-striped-sharding/lock-free-read-paths.md) — Provides a lock-free read path that allows concurrent reads without blocking other shard operations.
- [Sharded Maps](https://awesome-repositories.com/f/software-engineering-architecture/producer-consumer-workflow-managers/lock-free-concurrent-queues/locking-optimizations/lock-striped-sharding/sharded-maps.md) — Shards a map into segments with independent locks to reduce contention and boost concurrent throughput. ([source](https://github.com/orcaman/concurrent-map#readme))
