{"id":31931260,"url":"https://github.com/andreas-dorfer/in-memory-store","last_synced_at":"2025-10-14T04:33:13.246Z","repository":{"id":109206059,"uuid":"384200367","full_name":"Andreas-Dorfer/in-memory-store","owner":"Andreas-Dorfer","description":"A thread-safe in-memory key-value store with optimistic concurrency support.","archived":false,"fork":false,"pushed_at":"2024-01-07T17:28:10.000Z","size":191,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T04:57:18.250Z","etag":null,"topics":["csharp","dotnet","fsharp","in-memory-storage","key-value-store","mocking","optimistic-concurrency","prototyping","testing"],"latest_commit_sha":null,"homepage":"","language":"C#","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/Andreas-Dorfer.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}},"created_at":"2021-07-08T17:24:48.000Z","updated_at":"2024-07-07T00:04:37.000Z","dependencies_parsed_at":"2023-08-28T03:30:12.644Z","dependency_job_id":null,"html_url":"https://github.com/Andreas-Dorfer/in-memory-store","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Andreas-Dorfer/in-memory-store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andreas-Dorfer%2Fin-memory-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andreas-Dorfer%2Fin-memory-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andreas-Dorfer%2Fin-memory-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andreas-Dorfer%2Fin-memory-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Andreas-Dorfer","download_url":"https://codeload.github.com/Andreas-Dorfer/in-memory-store/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andreas-Dorfer%2Fin-memory-store/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017942,"owners_count":26086213,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["csharp","dotnet","fsharp","in-memory-storage","key-value-store","mocking","optimistic-concurrency","prototyping","testing"],"created_at":"2025-10-14T04:33:12.106Z","updated_at":"2025-10-14T04:33:13.240Z","avatar_url":"https://github.com/Andreas-Dorfer.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NuGet Package](https://img.shields.io/nuget/v/AndreasDorfer.InMemoryStore.svg)](https://www.nuget.org/packages/AndreasDorfer.InMemoryStore/)\n# AD.InMemoryStore\nA thread-safe in-memory key-value store with optimistic concurrency support. Great for testing / mocking and prototyping.\n## NuGet Package\n    PM\u003e Install-Package AndreasDorfer.InMemoryStore -Version 1.4.0\n### Namespace\n```csharp\nusing AD.InMemoryStore;\n```\n### Create a Store\n```csharp\nKeyValueStore\u003cint, string\u003e store = new();\n```\n### Add a Value\n```csharp\ntry\n{\n    var version = store.Add(key: 1, value: \"A\");\n}\ncatch (DuplicateKeyException\u003cint\u003e ex)\n{ }\n```\n### Get a Value\n```csharp\ntry\n{\n    var (value, version) = store.Get(key: 1);\n}\ncatch (KeyNotFoundException\u003cint\u003e ex)\n{ }\n```\n### Get all Values\n```csharp\nforeach (var (key, value, version) in store.GetAll())\n{ }\n```\n### Update a Value\n```csharp\ntry\n{\n    var newVersion = store.Update(key: 1, value: \"B\", match: version);\n}\ncatch (VersionMismatchException\u003cint\u003e ex)\n{ }\n```\n### Update a Value with No Version Check\n```csharp\ntry\n{\n    var newVersion = store.Update(key: 1, value: \"B\", match: null);\n}\ncatch (KeyNotFoundException\u003cint\u003e ex)\n{ }\n```\n### Remove a Value\n```csharp\ntry\n{\n    store.Remove(key: 1, match: version);\n}\ncatch (VersionMismatchException\u003cint\u003e ex)\n{ }\n```\n### Remove a Value with No Version Check\n```csharp\ntry\n{\n    store.Remove(key: 1, match: null);\n}\ncatch (KeyNotFoundException\u003cint\u003e ex)\n{ }\n```\n---\n[![NuGet Package](https://img.shields.io/nuget/v/AndreasDorfer.InMemoryStore.Functional.svg)](https://www.nuget.org/packages/AndreasDorfer.InMemoryStore.Functional/)\n# AD.InMemoryStore.Functional\nA functional wrapper around `AD.InMemoryStore`. Optimized for F#.\n## NuGet Package\n    PM\u003e Install-Package AndreasDorfer.InMemoryStore.Functional -Version 1.4.0\n### Namespace\n```fsharp\nopen AD.InMemoryStore.Functional\n```\n### Create a Store\n```fsharp\nlet store = KeyValueStore\u003cint, string\u003e ()\n```\n### Add a Value\n```fsharp\nmatch store.Add(key = 1, value = \"A\") with\n| Ok (key, value, version) -\u003e ()\n| Error (AddError.DuplicateKey key) -\u003e ()\n```\nOr if you don't care about the specific error type:\n```fsharp\nmatch store.Add(key = 1, value = \"A\") with\n| Ok (key, value, version) -\u003e ()\n| Error (ErrorKey key) -\u003e ()\n```\n### Get a Value\n```fsharp\nmatch store.Get(key = 1) with\n| Ok (key, value, version) -\u003e ()\n| Error (GetError.KeyNotFound key) -\u003e ()\n```\nOr if you don't care about the specific error type:\n```fsharp\nmatch store.Get(key = 1) with\n| Ok (key, value, version) -\u003e ()\n| Error (ErrorKey key) -\u003e ()\n```\n### Get all Values\n```fsharp\nfor (key, value, version) in store.GetAll() do\n    ()\n```\n### Update a Value\n```fsharp\nmatch store.Update(key = 1, value = \"B\", ``match`` = Some version) with\n| Ok (key, value, version) -\u003e ()\n| Error error -\u003e\n    match error with\n    | UpdateError.VersionMismatch key -\u003e ()\n    | _ -\u003e ()\n```\nOr if you don't care about the specific error type:\n```fsharp\nmatch store.Update(key = 1, value = \"B\", ``match`` = Some version) with\n| Ok (key, value, version) -\u003e ()\n| Error (ErrorKey key) -\u003e ()\n```\n### Update a Value with No Version Check\n```fsharp\nmatch store.Update(key = 1, value = \"B\", ``match`` = None) with\n| Ok (key, value, version) -\u003e ()\n| Error error -\u003e\n    match error with\n    | UpdateError.KeyNotFound key -\u003e ()\n    | _ -\u003e ()\n```\nOr if you don't care about the specific error type:\n```fsharp\nmatch store.Update(key = 1, value = \"B\", ``match`` = None) with\n| Ok (key, value, version) -\u003e ()\n| Error (ErrorKey key) -\u003e ()\n```\n### Remove a Value\n```fsharp\nmatch store.Remove(key = 1, ``match`` = Some version) with\n| Ok key -\u003e ()\n| Error error -\u003e\n    match error with\n    | RemoveError.VersionMismatch key -\u003e ()\n    | _ -\u003e ()\n```\nOr if you don't care about the specific error type:\n```fsharp\nmatch store.Remove(key = 1, ``match`` = Some version) with\n| Ok key -\u003e ()\n| Error (ErrorKey key) -\u003e ()\n```\n### Remove a Value with No Version Check\n```fsharp\nmatch store.Remove(key = 1, ``match`` = None) with\n| Ok key -\u003e ()\n| Error error -\u003e\n    match error with\n    | RemoveError.KeyNotFound key -\u003e ()\n    | _ -\u003e ()\n```\nOr if you don't care about the specific error type:\n```fsharp\nmatch store.Remove(key = 1, ``match`` = None) with\n| Ok key -\u003e ()\n| Error (ErrorKey key) -\u003e ()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreas-dorfer%2Fin-memory-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreas-dorfer%2Fin-memory-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreas-dorfer%2Fin-memory-store/lists"}