BMCache 2.0.0

dotnet add package BMCache --version 2.0.0
NuGet\Install-Package BMCache -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BMCache" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BMCache --version 2.0.0
#r "nuget: BMCache, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BMCache as a Cake Addin
#addin nuget:?package=BMCache&version=2.0.0

// Install BMCache as a Cake Tool
#tool nuget:?package=BMCache&version=2.0.0

<p align="center"> <img src="https://raw.githubusercontent.com/AnemonOFF/BMCache/main/logo.png" alt="BMCache"> <h1 align="center">BMCache</h1> </p> <p align="center"> <a href="https://www.nuget.org/packages/BMCache/"><img alt="Nuget" src="https://img.shields.io/nuget/v/BMCache"></a> <a href="https://github.com/AnemonOFF/BMCache/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/AnemonOFF/BMCache"></a> </p> </br>

A simple C# cacher. Caching in file.

How to use

  1. Firstly create cache provider
var provider = new BMCacheProvider();

| Agrument | type | required | default | description | |-----------------------|-----------|----------|----------|-----------------------------------------------| | dir | string | - | bmcache | directory where storage cache data | | defaultExpirationTime | TimeStamp | - | 24 hours | Default expiration time to delete cached file | 2. Create cacher by provider. DO NOT create it by yourself (using new BMCacher()).

var cacher = provider.CreateCacher("test");

| Agrument | type | required | default | description | |-----------------------|-----------|----------|----------------------------------|--------------------------------------------------------| | name | string | + | | directory (and cacher) name, where to save cached data | | defaultExpirationTime | TimeStamp | - | Provider`s defaultExpirationTime | Default expiration time to delete cached file | 3. Cache

// You can cache and get it back via diferrent methods
var variableToCache = "cache me";
cacher.Cache("identifier", variableToCache);
var variableFromCache = cacher.Get<string>("identifier");
// You can use default methods with just value argument.
// This methods will give you cached before value
// or cache it and throw back
var cachedTime = cacher.GetOrCache<DateTime>("dt", DateTime.UtcNow);
var cachedDoub = await cacher.GetOrCacheAsync<double>("double", 123.456);
// Or use value generator
Func<int> intFunction = () => 12345;
var cachedNum = cacher.GetOrCache<int>("num", intFunction);
var cachedNumAsync = await cacher.GetOrCacheAsync<int>("num", intFunction);
// Or async value generator
Func<Task<List<string>>> listAsyncFunc = async () => new List<string>() { "first", "second", "third" };
var cachedList = await cacher.GetOrCacheAsync<List<string>>("list", listAsyncFunc);

In addition you can set expiration time for each caching separately

// In example, this row will cache string for 2 hour from now
cacher.Cache("identifier", "string to cache", new TimeStamp(2, 0, 0));

*For expiration control, library using UTC time

License

License

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 366 10/25/2022
1.0.0 354 10/14/2022