{"id":25522249,"url":"https://github.com/dotnet-labs/memorycachelabs","last_synced_at":"2026-04-30T13:32:16.995Z","repository":{"id":108781281,"uuid":"333123700","full_name":"dotnet-labs/MemoryCacheLabs","owner":"dotnet-labs","description":"Cache in-memory in ASP.NET Core | tests | immutable","archived":false,"fork":false,"pushed_at":"2021-03-12T17:48:21.000Z","size":114,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-21T12:51:30.617Z","etag":null,"topics":["cache","dotnet","dotnet-core","dotnetcore","immutable","memory-cache","unit-testing","unitest"],"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/dotnet-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"changhuixu","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-01-26T15:14:41.000Z","updated_at":"2021-04-01T22:16:32.000Z","dependencies_parsed_at":"2023-06-04T23:45:24.501Z","dependency_job_id":null,"html_url":"https://github.com/dotnet-labs/MemoryCacheLabs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dotnet-labs/MemoryCacheLabs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FMemoryCacheLabs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FMemoryCacheLabs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FMemoryCacheLabs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FMemoryCacheLabs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnet-labs","download_url":"https://codeload.github.com/dotnet-labs/MemoryCacheLabs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FMemoryCacheLabs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32466333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cache","dotnet","dotnet-core","dotnetcore","immutable","memory-cache","unit-testing","unitest"],"created_at":"2025-02-19T18:18:56.342Z","updated_at":"2026-04-30T13:32:16.990Z","avatar_url":"https://github.com/dotnet-labs.png","language":"C#","funding_links":["https://ko-fi.com/changhuixu","https://ko-fi.com/changhuixu'"],"categories":[],"sub_categories":[],"readme":"# Memory Cache Lab\n\n\u003ca href='https://ko-fi.com/changhuixu' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\n## [Medium Article: IMemoryCache: Immutable Collections and Unit Tests](https://codeburst.io/imemorycache-immutable-collections-and-unit-tests-cfac7b389a5)\n\nThere are many introductory articles talking about using the `IMemoryCache` to store data in the memory of the webserver. However, few of them have mentioned how to ensure the consistency of cached values at runtime. In other words, if not designed carefully, the cached values could be mutated accidentally in code.\n\nIn this article, I will first present an example cache service that allows us to mutate a cached entry, which is an undesired outcome in most cases. To improve the implementation, next, I will show you a way to create immutable collections as cache objects by using `IReadOnlyList\u003cT\u003e` and `record`.\n\n![immutable-cache](immutable-cache.png)\n\n## License\n\nFeel free to use the code in this repository as it is under MIT license.\n\n\u003ca href='https://ko-fi.com/changhuixu' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-labs%2Fmemorycachelabs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnet-labs%2Fmemorycachelabs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-labs%2Fmemorycachelabs/lists"}