{"id":25367979,"url":"https://github.com/jjosh102/browser-cache-extensions","last_synced_at":"2026-04-29T15:34:00.730Z","repository":{"id":276892731,"uuid":"930302391","full_name":"jjosh102/browser-cache-extensions","owner":"jjosh102","description":"BrowserCacheExtensions is a collection of extensions designed to cache non-confidential data in the browser.","archived":false,"fork":false,"pushed_at":"2025-02-11T01:37:14.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-11T02:26:38.711Z","etag":null,"topics":["blazor","blazor-webassembly","csahrp","localstorage","show"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jjosh102.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-10T12:18:08.000Z","updated_at":"2025-02-11T01:37:17.000Z","dependencies_parsed_at":"2025-02-11T02:36:51.681Z","dependency_job_id":null,"html_url":"https://github.com/jjosh102/browser-cache-extensions","commit_stats":null,"previous_names":["jjosh102/browser-cache-extensions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2Fbrowser-cache-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2Fbrowser-cache-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2Fbrowser-cache-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2Fbrowser-cache-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jjosh102","download_url":"https://codeload.github.com/jjosh102/browser-cache-extensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987106,"owners_count":21028891,"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":["blazor","blazor-webassembly","csahrp","localstorage","show"],"created_at":"2025-02-15T00:23:52.285Z","updated_at":"2026-04-29T15:33:55.702Z","avatar_url":"https://github.com/jjosh102.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BrowserCacheExtensions\n[![NuGet](https://img.shields.io/nuget/v/BrowserCache.Extensions.svg)](https://www.nuget.org/packages/BrowserCache.Extensions)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/BrowserCache.Extensions?logo=nuget)](https://www.nuget.org/packages/BrowserCache.Extensions)\n\nBrowserCacheExtensions is a collection of extensions designed to cache non-confidential data in the browser using popular libraries like [Blazored LocalStorage](https://github.com/Blazored/LocalStorage). Future plans include extending support to [Blazor.IndexedDB](https://github.com/wtulloch/Blazor.IndexedDB).\n\n## Installing\n\nTo install the package add the following line inside your csproj file with the latest version.\n\n```\n\u003cPackageReference Include=\"BrowserCache.Extensions\" Version=\"x.x.x\" /\u003e\n```\n\nAn alternative is to install via the .NET CLI with the following command:\n\n```\ndotnet add package BrowserCache.Extensions\n```\n\n## Usage\n\n### LocalStorageAsyncExtensions\n\nThe `LocalStorageAsyncExtensions` class provides asynchronous methods for caching data. Here's how to use it:\n\n```csharp\nusing Blazored.LocalStorage;\nusing BrowserCache.Extensions.LocalStorage;\nusing System;\nusing System.Threading.Tasks;\n\npublic class Example\n{\n    private readonly ILocalStorageService _localStorageService;\n\n    public Example(ILocalStorageService localStorageService)\n    {\n        _localStorageService = localStorageService;\n    }\n\n    public async Task UseCacheAsync()\n    {\n        string key = \"cachedData\";\n        TimeSpan timeToLive = TimeSpan.FromMinutes(10);\n\n        var data = await _localStorageService.GetOrCreateCacheAsync(\n            key,\n            timeToLive,\n            async () =\u003e await FetchDataAsync()\n        );\n\n        // Use 'data' as needed\n    }\n\n    private async Task\u003cMyDataType\u003e FetchDataAsync()\n    {\n        // Fetch or generate data\n        return await Task.FromResult(new MyDataType());\n    }\n}\n```\n\n### LocalStorageSyncExtensions\n\nThe `LocalStorageSyncExtensions` class offers synchronous methods for caching data:\n\n```csharp\nusing Blazored.LocalStorage;\nusing BrowserCache.Extensions.LocalStorage;\nusing System;\n\npublic class Example\n{\n    private readonly ISyncLocalStorageService _localStorageService;\n\n    public Example(ISyncLocalStorageService localStorageService)\n    {\n        _localStorageService = localStorageService;\n    }\n\n    public void UseCache()\n    {\n        string key = \"cachedData\";\n        TimeSpan timeToLive = TimeSpan.FromMinutes(10);\n\n        var data = _localStorageService.GetOrCreateCache(\n            key,\n            timeToLive,\n            () =\u003e FetchData()\n        );\n\n        // Use 'data' as needed\n    }\n\n    private MyDataType FetchData()\n    {\n        // Fetch or generate data\n        return new MyDataType();\n    }\n}\n```\n\n## Note\nIf you prefer not to rely on this library, you can copy the extension methods directly into your project and modify them as needed to suit your requirements.\n\n## Disclaimer\nUse only this library for caching non sensitive data.\nIf you are working with highly private and confidential data , you should not be storing this data in your client's browser.\n\n# License\nMIT License\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjosh102%2Fbrowser-cache-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjjosh102%2Fbrowser-cache-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjosh102%2Fbrowser-cache-extensions/lists"}