{"id":24757717,"url":"https://github.com/iharyakimush/community-extensions-caching","last_synced_at":"2025-10-11T05:30:46.254Z","repository":{"id":92323346,"uuid":"142007400","full_name":"IharYakimush/community-extensions-caching","owner":"IharYakimush","description":"Combine In-Memory and Distributed Caching in ASP.NET Core","archived":false,"fork":false,"pushed_at":"2018-07-26T12:35:46.000Z","size":78,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T23:43:45.635Z","etag":null,"topics":["asp-net-core","cache","distributed-cache","in-memory-caching"],"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/IharYakimush.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":"2018-07-23T11:52:41.000Z","updated_at":"2021-04-16T06:40:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"b27ad3d0-6490-4ab9-9092-795362b432fd","html_url":"https://github.com/IharYakimush/community-extensions-caching","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/IharYakimush/community-extensions-caching","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2Fcommunity-extensions-caching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2Fcommunity-extensions-caching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2Fcommunity-extensions-caching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2Fcommunity-extensions-caching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IharYakimush","download_url":"https://codeload.github.com/IharYakimush/community-extensions-caching/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IharYakimush%2Fcommunity-extensions-caching/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006320,"owners_count":26084085,"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-11T02:00:06.511Z","response_time":55,"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":["asp-net-core","cache","distributed-cache","in-memory-caching"],"created_at":"2025-01-28T15:34:49.040Z","updated_at":"2025-10-11T05:30:45.842Z","avatar_url":"https://github.com/IharYakimush.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Combine In-Memory and Distributed Caching\nStandard version of `IMemoryCache` and `IDistributedCache` from `Microsoft.Extensions.Caching` allows to register only 1 instance in `IServiceCollection`. \nThis project allows you to:\n - Use generic versions of `IMemoryCache\u003cT\u003e` and `IDistributedCache\u003cT\u003e` to be able to manage multiple cache instances\n - Use strongly typed objects with `IDistributedCache\u003cT\u003e` instead of byte arrays\n - Use `ICombinedCache\u003cT\u003e` combined cache which try to get value from memory cache first and perform fallback to distributed cache\n - Use App.Metrics to monitor cache hit ration and performance\n\n # Sample\n ### Register caches\n ```\npublic void ConfigureServices(IServiceCollection services)\n{\n    // Register memory cache\n    services.AddMemoryCache\u003cMyCache\u003e();\n\n    // Allow to collect App.Metrics for memory cache\n    services.AddMetricsToMemoryCache\u003cMyCache\u003e();\n\n    // Register Redis distributed cache\n    services.AddRedisDistributedCache\u003cMyCache\u003e(options =\u003e\n    {\n        options.Configuration = \"redis\";\n        options.InstanceName = \"redis\";\n    });\n\n    // Allow to collect App.Metrics for distributed cache\n    services.AddMetricsToDistributedCache\u003cMyCache\u003e();\n\n    // Register combined cache\n    services.AddCombinedCache\u003cMyCache\u003e();\n\n    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);\n}\n```\n\n### Use caches\n```\npublic class ValuesController : ControllerBase\n{\n    private readonly IMemoryCache\u003cMyCache\u003e mem;\n    private readonly IDistributedCache\u003cMyCache\u003e dist;\n    private readonly ICombinedCache\u003cMyCache\u003e comb;\n\n    public ValuesController(\n        IMemoryCache\u003cMyCache\u003e onlyMemoryCache,\n        IDistributedCache\u003cMyCache\u003e onlyDistributedCache, \n        ICombinedCache\u003cMyCache\u003e combinedCache)\n    {\n        mem = onlyMemoryCache ?? throw new ArgumentNullException(nameof(onlyMemoryCache));\n        dist = onlyDistributedCache ?? throw new ArgumentNullException(nameof(onlyDistributedCache));\n        comb = combinedCache ?? throw new ArgumentNullException(nameof(combinedCache));\n    }\n\n    public ActionResult\u003cIEnumerable\u003cstring\u003e\u003e Get()\n    {\n        string dateString = DateTime.UtcNow.ToString(\"O\");\n\n        return new string[]\n        {\n            \"v1mem-\" + this.mem.GetOrSetValue(\"v1\", () =\u003e dateString),\n\n            \"v1dist-\" + this.dist.GetOrSetValue(\"v1\", () =\u003e dateString),\n\n            \"v1comb-\" + this.comb.GetOrSetValue(\"v1\", () =\u003e dateString)\n        };\n    }\n}\n```\n\n### Sample project\nhttps://github.com/IharYakimush/community-extensions-caching/tree/master/Community.Extensions.Caching.Sample\n\n# Grafana Dashboard\nGrafana dashboard for InfluxDB available at https://github.com/IharYakimush/community-extensions-caching/tree/master/GrafanaDashbord.json\n\n# NuGet\n - Base abstractions and memory cache: https://www.nuget.org/packages/Community.Extensions.Caching/\n - Redis distributed cache: https://www.nuget.org/packages/Community.Extensions.Caching.Redis/\n - App.Metrics for caches: https://www.nuget.org/packages/Community.Extensions.Caching.AppMetrics/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiharyakimush%2Fcommunity-extensions-caching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiharyakimush%2Fcommunity-extensions-caching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiharyakimush%2Fcommunity-extensions-caching/lists"}