TinyCache 1.0.2
Package Description
See the version list below for details.
Install-Package TinyCache -Version 1.0.2
dotnet add package TinyCache --version 1.0.2
<PackageReference Include="TinyCache" Version="1.0.2" />
paket add TinyCache --version 1.0.2
TinyCache
Example
Create a cache storage, in memory cache will be the default.
var store = new XamarinPropertyStorage();
Set cache storage
TinyCache.TinyCache.SetCacheStore(store);
Preload cache if needed:
store.LoadFromString(CacheResources.PreloadData.JsonData);
Handle errors
TinyCache.TinyCache.OnError += (sender, e) =>
{
ShowError(e);
};
Set a base policy that will be used when no policy is specified
TinyCache.TinyCache.SetBasePolicy(
new TinyCachePolicy()
.SetMode(TinyCacheModeEnum.CacheFirst)
.SetFetchTimeout(6000));
Fetch data with default policy
var result = await TinyCache.TinyCache.UsePolicy<List<Data>>("cachekey", () => { return api.GetData("customdata"); });
Handle background changes
TinyCache.TinyCache.OnUpdate += async (object sender, CacheUpdatedEvt e) => {
var cacheKey = e.Key;
var dataObject = e.Value;
// HandleObjectChange(cacheKey,dataObject as MyDataType);
};
TinyCache
Example
Create a cache storage, in memory cache will be the default.
var store = new XamarinPropertyStorage();
Set cache storage
TinyCache.TinyCache.SetCacheStore(store);
Preload cache if needed:
store.LoadFromString(CacheResources.PreloadData.JsonData);
Handle errors
TinyCache.TinyCache.OnError += (sender, e) =>
{
ShowError(e);
};
Set a base policy that will be used when no policy is specified
TinyCache.TinyCache.SetBasePolicy(
new TinyCachePolicy()
.SetMode(TinyCacheModeEnum.CacheFirst)
.SetFetchTimeout(6000));
Fetch data with default policy
var result = await TinyCache.TinyCache.UsePolicy<List<Data>>("cachekey", () => { return api.GetData("customdata"); });
Handle background changes
TinyCache.TinyCache.OnUpdate += async (object sender, CacheUpdatedEvt e) => {
var cacheKey = e.Key;
var dataObject = e.Value;
// HandleObjectChange(cacheKey,dataObject as MyDataType);
};
Dependencies
-
.NETStandard 1.4
- NETStandard.Library (>= 1.6.1)
Used By
NuGet packages (2)
Showing the top 2 NuGet packages that depend on TinyCache:
Package | Downloads |
---|---|
TinyCache.FileStorage
Small helper for offline and caching of long-running processes
|
|
TinyCache.Forms
Small helper for offline and caching of long-running processes
|
GitHub repositories
This package is not used by any popular GitHub repositories.
Version History
Version | Downloads | Last updated |
---|---|---|
2.0.2 | 1,250 | 11/26/2019 |
2.0.1 | 274 | 11/26/2019 |
1.0.48 | 1,399 | 7/5/2019 |
1.0.47 | 460 | 7/5/2019 |
1.0.45 | 1,387 | 11/2/2018 |
1.0.44 | 2,529 | 7/4/2018 |
1.0.43 | 1,992 | 3/16/2018 |
1.0.42 | 761 | 3/16/2018 |
1.0.38 | 712 | 3/8/2018 |
1.0.32 | 658 | 1/15/2018 |
1.0.29 | 554 | 1/13/2018 |
1.0.25 | 537 | 1/11/2018 |
1.0.23 | 540 | 1/10/2018 |
1.0.21 | 542 | 1/10/2018 |
1.0.19 | 574 | 1/7/2018 |
1.0.18 | 734 | 1/5/2018 |
1.0.11 | 510 | 1/2/2018 |
1.0.2 | 526 | 1/2/2018 |