{"id":26364937,"url":"https://github.com/jjosh102/obaki.localstoragecache","last_synced_at":"2025-07-20T21:33:18.528Z","repository":{"id":99953906,"uuid":"582331422","full_name":"jjosh102/Obaki.LocalStorageCache","owner":"jjosh102","description":"This is a simple library that allows you to easily cache data in the browser's local storage.","archived":false,"fork":false,"pushed_at":"2025-02-11T12:37:11.000Z","size":95,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T05:44:33.836Z","etag":null,"topics":["blazor-webassembly","cache","csharp","dotnet","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,"zenodo":null}},"created_at":"2022-12-26T13:39:38.000Z","updated_at":"2025-02-11T12:37:16.000Z","dependencies_parsed_at":"2024-03-05T10:29:05.675Z","dependency_job_id":"9bc1cf4b-f2fe-4870-ac1e-b9e2f0cdd9ea","html_url":"https://github.com/jjosh102/Obaki.LocalStorageCache","commit_stats":null,"previous_names":["joshjlp/obaki.localstoragecache","jjosh102/obaki.localstoragecache","jjosh102/localstorage.extensions"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jjosh102/Obaki.LocalStorageCache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2FObaki.LocalStorageCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2FObaki.LocalStorageCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2FObaki.LocalStorageCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2FObaki.LocalStorageCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jjosh102","download_url":"https://codeload.github.com/jjosh102/Obaki.LocalStorageCache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjosh102%2FObaki.LocalStorageCache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266204534,"owners_count":23892364,"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-webassembly","cache","csharp","dotnet","localstorage","show"],"created_at":"2025-03-16T19:28:46.062Z","updated_at":"2025-07-20T21:33:18.495Z","avatar_url":"https://github.com/jjosh102.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Obaki.LocalStorageCache\n[![NuGet](https://img.shields.io/nuget/v/Obaki.LocalStorageCache.svg)](https://www.nuget.org/packages/Obaki.LocalStorageCache)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/Obaki.LocalStorageCache?logo=nuget)](https://www.nuget.org/packages/Obaki.LocalStorageCache)\n\n\u003e **⚠️ Hey there! Important Update:**\n\u003e\n\u003e I recommend switching to this new library instead: [browser-cache-extensions](https://github.com/jjosh102/browser-cache-extensions).  \n\u003e It's a simple extension on local storage and cuts out the extra  wrapper from the old library.\n\n\nThis is a simple library that allows you to easily cache data in the browser's local storage. It provides a simple API for storing and retrieving data  based on a specified time-to-live (TTL). The library make use of [Blazored LocalStorage](https://github.com/Blazored/LocalStorage) for storing cache data.\n\nOverall, Obaki.LocalStorageCache is a simple and easy-to-use library that can help you improve the performance of your web application by caching data locally in the browser.\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=\"Obaki.LocalStorageCache\" 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 Obaki.LocalStorageCache\n```\n\nFor more information you can check the [nuget package](https://www.nuget.org/packages/Obaki.LocalStorageCache).\n\n## Setup\nRegister the needed services in your Program.cs file as **Scoped**\n\n```c#\npublic void ConfigureServices(IServiceCollection services)\n{\n    services.AddLocalStorageCacheAsScoped();\n}\n``` \n\nOr as **Singleton**\n\n```c#\npublic void ConfigureServices(IServiceCollection services)\n{\n    services.AddLocalStorageCacheAsSingleton();\n}\n```\n## Usage \n**Asynchronous(Non-Blocking)**\n```c#\nusing Obaki.LocalStorageCache;\n\npublic class TestAsync {\n  private readonly ILocalStorageCache _localStorageCache;\n  \n  public TestAsync(ILocalStorageCache localStorageCache) {\n    _localStorageCache = localStorageCache;\n  }\n\n  public async Task\u003cTCacheData\u003e GetDataAsync() {\n    var cache = await _localStorageCache.GetOrCreateCacheAsync(\n      Key, //Define Key\n      TimeSpan.FromHours(1), //TTL\n       async () =\u003e\n         return await GetNewData\u003cTCacheData\u003e(); //Refresh cache data.\n      });\n      \n    return cache ?? default;\n  }\n}\n```\n**Synchronous(Blocking)**\n```c#\nusing Obaki.LocalStorageCache;\n\npublic class TestSync {\n  private readonly ILocalStorageCacheSync _localStorageCacheSync;\n  \n  public TestSync(ILocalStorageCacheSync localStorageCacheSync) {\n    _localStorageCacheSync = localStorageCacheSync;\n  }\n\n  public TCacheData GetDataSync() {\n    var cache = _localStorageCacheSync.GetOrCreateCache(\n      Key, //Define Key\n      TimeSpan.FromHours(1), //TTL\n        () =\u003e\n         return GetNewData\u003cTCacheData\u003e(); //Refresh cache data.\n      });\n      \n    return cache ?? default;\n  }\n}\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# License\nMIT License\n## Star History\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjosh102%2Fobaki.localstoragecache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjjosh102%2Fobaki.localstoragecache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjosh102%2Fobaki.localstoragecache/lists"}