{"id":21531977,"url":"https://github.com/chainbound/shardmap","last_synced_at":"2025-09-06T18:34:12.576Z","repository":{"id":62866920,"uuid":"560800820","full_name":"chainbound/shardmap","owner":"chainbound","description":"A performant, highly concurrent and simple sharded hashmap implementation using generics","archived":false,"fork":false,"pushed_at":"2024-06-04T11:33:09.000Z","size":8,"stargazers_count":33,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T02:12:43.316Z","etag":null,"topics":["cache","concurrency","generics","golang","high-performance","low-latency","map","sharding"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chainbound.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-02T09:50:03.000Z","updated_at":"2024-11-14T01:11:50.000Z","dependencies_parsed_at":"2024-06-20T00:08:26.315Z","dependency_job_id":"21077865-b91d-4ce5-a15a-31ea8bf03d44","html_url":"https://github.com/chainbound/shardmap","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainbound%2Fshardmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainbound%2Fshardmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainbound%2Fshardmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainbound%2Fshardmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chainbound","download_url":"https://codeload.github.com/chainbound/shardmap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248134816,"owners_count":21053537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","concurrency","generics","golang","high-performance","low-latency","map","sharding"],"created_at":"2024-11-24T02:18:23.035Z","updated_at":"2025-04-10T00:30:34.832Z","avatar_url":"https://github.com/chainbound.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shardmap\n\n\u003e A performant, highly concurrent and simple sharded hashmap implementation using generics.\n\nThis package contains a `ShardedMap` and a `FIFOMap`.\n\n## `ShardedMap`\nA `ShardedMap` is a simple map that uses a sharded design. A sharded map splits the map into\nbuckets or shards according to the key, where each shard has its own `RWMutex`. This ensures that lock contention\nis heavily minimized compared to using one mutex for the whole map, making it very high throughput and low latency\nin highly concurrent situations.\n\nIt has the following interface:\n```go\ntype ShardedMapInterface interface {\n    Get(key K) (val V, ok bool)\n    Put(key K, val V)\n    Has(key K) ok bool\n    Del(key K)\n    Keys() []K\n    Iter() \u003c-chan KVPair[K, V]\n    Len() int\n}\n```\n### Example\n```go\nimport \"github.com/chainbound/shardmap\"\n\nfunc main() {\n    // Initialize a new sharded int -\u003e string map with size 1000, and 10 shards.\n    // We need to provide the hash function for our key type, the defaults being contained\n    // in this package. You can also provide your own.\n    sm := shardmap.NewShardedMap[int, string](1000, 10, shardmap.HashInt)\n    sm.Put(1, \"josh\")\n\n    fmt.Println(sm.Get(1))\n}\n```\n\n## `FIFOMap`\nThe `FIFOMap` is a map with a FIFO eviction policy, meaning that the oldest values get removed once your map\nreaches a certain `size`. Internally, it uses the sharded map above, and shares the same interface.\n```go\nimport \"github.com/chainbound/shardmap\"\n\nfunc main() {\n    // Initialize a new sharded int -\u003e string map with size 1000, and 10 shards.\n    // We need to provide the hash function for our key type, the defaults being contained\n    // in this package. You can also provide your own.\n    sm := shardmap.NewFIFOMap[int, string](1000, 10, shardmap.HashInt)\n\n    // Once the size is reached, the next put will remove the oldest inserted KV pair.\n    sm.Put(1, \"josh\")\n\n    fmt.Println(sm.Get(1))\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainbound%2Fshardmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainbound%2Fshardmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainbound%2Fshardmap/lists"}