{"id":24610754,"url":"https://github.com/barteco/redfish","last_synced_at":"2026-05-19T07:32:40.480Z","repository":{"id":143199073,"uuid":"359228438","full_name":"Barteco/Redfish","owner":"Barteco","description":"Strongly typed toolkit for Redis caching and pub-sub service","archived":false,"fork":false,"pushed_at":"2021-05-03T10:49:55.000Z","size":103,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-01T22:00:35.611Z","etag":null,"topics":["caching","pubsub","redis"],"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/Barteco.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":"2021-04-18T18:56:08.000Z","updated_at":"2021-05-03T10:49:57.000Z","dependencies_parsed_at":"2023-07-17T04:16:10.210Z","dependency_job_id":null,"html_url":"https://github.com/Barteco/Redfish","commit_stats":null,"previous_names":["barteco/redcache"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Barteco/Redfish","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barteco%2FRedfish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barteco%2FRedfish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barteco%2FRedfish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barteco%2FRedfish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Barteco","download_url":"https://codeload.github.com/Barteco/Redfish/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barteco%2FRedfish/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278786686,"owners_count":26045588,"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-07T02:00:06.786Z","response_time":59,"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":["caching","pubsub","redis"],"created_at":"2025-01-24T19:18:21.276Z","updated_at":"2025-10-07T13:55:03.294Z","avatar_url":"https://github.com/Barteco.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redfish\n\nRedfish is a strongly typed wrapper for Redis key-value store and pub-sub service, based on [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) library\n\n## 1. Installation\n\n### 1.1. Add packages\nInstall main package in your startup project:\n\n`dotnet add package Redfish`\n\nAdd one of the following serialization packages (see \"Choosing serialization method\" section for more details):\n\n`dotnet add package Redfish.Serialization.Protobuf`\n\n`dotnet add package Redfish.Serialization.SystemTextJson`\n\n`dotnet add package Redfish.Serialization.NewtonsoftJson`\n\nOptionally, add:\n\n`dotnet add package Redfish.Logging`\n\nIn multi-project solutions you can also add following package, which contains only required interfaces and dependencies:\n\n`dotnet add package Redfish.Abstractions`\n\n### 1.2. Configuration\n*appsettings.json*\n```\n\"Redfish\": {\n  \"Redis\": {\n    \"ConnectionString\": \"127.0.0.1:6379\",\n    \"DefaultDatabase\": 0\n  },\n  \"Logging\": { // optional section, only when using logging \n    \"DefaultLevel\": \"Information\"\n  }\n}\n```\n\n### 1.3. Registration\n*Startup.cs*\n```\nusing Redfish;\n\n// ...\n\npublic void ConfigureServices(IServiceCollection services)\n{\n    // ...\n\n    services.AddRedfish(Configuration.GetSection(\"Redfish:Redis\"))\n        .AddProtobufSerializer() // or any other chosen provider\n        .AddLogging(Configuration.GetSection(\"Redfish:Logging\")); // optional, only when using logging \n      \n    // ...\n}\n```\n\n## 2. Usage\n\n### 2.1. Cache service\n\nGetting value from Redis with fallback\n```\npublic class HomeController : Controller\n{\n    private readonly IRedcache _redcache;\n\n    public HomeController(IRedcache redcache)\n    {\n        _redcache = redcache;\n    }\n\n    [HttpGet(\"date\")]\n    public async Task\u003cDateTime\u003e GetDate()\n    {\n        return await _redcache.GetOrSet(\"key\", () =\u003e DateTime.UtcNow, TimeSpan.FromMinutes(1));\n    }\n}\n```\n\n### 2.2. Pub-sub service\n\nPublishing messages to specified channel:\n```\npublic class HomeController : Controller\n{\n    private readonly IRedqueue _redqueue;\n\n    public HomeController(IRedqueue redqueue)\n    {\n        _redqueue = redqueue;\n    }\n\n    [HttpGet(\"publish\")]\n    public async Task\u003cOkResult\u003e Publish()\n    {\n        await _redqueue.Publish(\"channel\", \"message\");\n\n        return Ok();\n    }\n}\n```\n\nSubscribing channels:\n```\npublic class ChannelSubscriber : BackgroundService\n{\n    private readonly IRedqueue _redqueue;\n\n    public ChannelSubscriber(IRedqueue redqueue)\n    {\n        _redqueue = redqueue;\n    }\n\n    protected override async Task ExecuteAsync(CancellationToken stoppingToken)\n    {\n        await _redqueue.Subscribe\u003cstring\u003e(\"channel\", message =\u003e\n        {\n            // handle your message\n        });\n    }\n}\n```\n\n## 3. Choosing serialization method\n\nFor now, Redfish supports three methods of value serialization in Redis.\n\n### 3.1. Protobuf\n\nThis method uses Mark Gravell's [protobuf-net](https://github.com/protobuf-net/protobuf-net) as a contract based binary serializer, which writes data in \"protocol buffers\" format. To use it, you must decorate all object persisted in Redis with `ProtoContract` and `ProtoMember(n)` attributes as follows:\n\n```\n[ProtoContract]\npublic class Person \n{\n    [ProtoMember(1)]\n    public int Id { get; set; }\n\n    [ProtoMember(2)]\n    public string Name { get; set; }\n}\n```\n\nThis format offers significant storage size reduction and faster serialization, but lags behind in readability when browsing Redis with external tools, like Redis Desktop Manager\n\n#### 3.1.1. Installation\n\n`dotnet add package Redfish.Serialization.Protobuf`\n\n#### 3.1.2. Registration\n\n```\nservices.AddRedfish(...)\n    .AddProtobufSerializer();\n```\n\n\n\n### 3.2. System.Text.Json\n\nThis method uses `System.Text.Json`, default Microsoft's Json serializer for ASP.NET Core\n\n#### 3.2.1. Installation\n\n`dotnet add package Redfish.Serialization.SystemTextJson`\n\n#### 3.2.2. Registration\n\n```\nservices.AddRedfish(...)\n    .AddSystemTextJsonSerializer();\n```\n\n### 3.3. Newtonsoft.Json\n\nThis method uses highly popular [Json.NET](https://github.com/JamesNK/Newtonsoft.Json) as Json serializer\n\n#### 3.3.1. Installation\n\n`dotnet add package Redfish.Serialization.NewtonsoftJson`\n\n#### 3.3.2. Registration\n\n```\nservices.AddRedfish(...)\n    .AddNewtonsoftJsonSerializer();\n```\n\n## 4. Logging\n\n## 5. Acknowledgements\n\n* [Icon](https://creativenerds.co.uk/freebies/80-free-wildlife-icons-the-best-ever-animal-icon-set/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarteco%2Fredfish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarteco%2Fredfish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarteco%2Fredfish/lists"}