ZayniFramework.Caching 2.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZayniFramework.Caching --version 2.1.0
NuGet\Install-Package ZayniFramework.Caching -Version 2.1.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="ZayniFramework.Caching" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZayniFramework.Caching --version 2.1.0
#r "nuget: ZayniFramework.Caching, 2.1.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 ZayniFramework.Caching as a Cake Addin
#addin nuget:?package=ZayniFramework.Caching&version=2.1.0

// Install ZayniFramework.Caching as a Cake Tool
#tool nuget:?package=ZayniFramework.Caching&version=2.1.0

CacheManager example.

Add namespace using.

using ZayniFramework.Caching;
using ZayniFramework.Common;

Add CachingSettings config section in your app.config or web.config file.


<CachingSettings managerMode="Redis">
    <CachePool resetEnable="true" cleanerIntervalSecond="3" maxCapacity="10000" refreshIntervalMinute="1" />
    <CacheData timeoutInterval="0" />
    <RedisCache>
        <add name="XXXRedisService" isDefault="true" dbActionLog="true" host="XXX.XXX.XXX.XXX" port="6379" account="" password="" dbNumber="10" connectTimeout="1000" responseTimeout="3500" />
        
    </RedisCache>
    <RemoteCache defaultCacheClientName="RemoteCacheTest1"></RemoteCache>
    
</CachingSettings>

Put data into CacheManager. Use CacheManager.Put() static method.

public void PutDataTest()
{
    string key = "somekey";

    var model = new
    {
        Name   = "Amber",
        Age    = 23,
        Sex    = "F",
        Emails = new List<string>()
        {
            "amber@gmail.com",
            "amber@hotmail.com"
        },
        Profile = new
        {
            Token   = Guid.NewGuid().ToString(),
            DoB     = new DateTime( 1998, 2, 14 ),
            Comment = "Hello, this is Amber."
        }
    };

    var cacheProp = new CacheProperty()
    {
        CacheId         = key,
        Data            = model,
        RefreshCallback = () => new
        {
            Name   = "Belle Claire",
            Age    = 23,
            Sex    = "F",
            Emails = new List<string>()
            {
                "belle.claire@gmail.com",
                "belle.claire@hotmail.com"
            },
            Profile = new
            {
                Token   = Guid.NewGuid().ToString(),
                DoB     = new DateTime( 1998, 2, 14 ),
                Comment = "Hi"
            }
        }
    };

    bool success = CacheManager.Put( cacheProp );
    Assert.IsTrue( success );
}

Put data into CacheManager in a HashProperty data structure.<br/> Get HashProperty data from CacheManager.

var hashs = new HashProperty[] 
{
    new HashProperty( "a1", "Hello Fiona!" ),
    new HashProperty( "a2", true ),
    new HashProperty( "a3", new DateTime( 2018, 2, 7 ) ),
    new HashProperty( "a4", 45.26 ),
    new HashProperty( "a5", 500 ),
    new HashProperty( "a6", 3333.77M ),
};

bool success = CacheManager.PutHashProperty( "aaa", hashs );

var a1 = CacheManager.GetHashProperty( "aaa", "a1" );
Assert.AreEqual( "Hello Fiona", a1.Data + "" );

var a2 = CacheManager.GetHashProperty( "aaa", "a2" );
Assert.AreEqual( true, Convert.ToBoolean( a2.Data + "" ) );

var a3 = CacheManager.GetHashProperty( "aaa", "a3" );
Assert.AreEqual( new DateTime( 2018, 2, 7 ), Convert.ToDateTime( a3.Data ) );

// Get all hash properties with the main cacheId.
var gp = CacheManager.GetHashProperties( "aaa" );

Put and Get data with CacheManager.

var model = new UserTestModel()
{
    Name = "Amber",
    Age  = 23,
    Sex  = "F"
};

bool success = CacheManager.Put( new CacheProperty() { CacheId = "test02", Data = model } );
var r = CacheManager.Get<UserTestModel>( "test02" );

Clear all the data in CacheManager. User CacheManager.Clear() static method.

CacheManager.Clear();

More detail sample code. You can go to Test/UnitTests/Zayni.Caching.Test directory.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ZayniFramework.Caching:

Package Downloads
ZayniFramework.DataAccess.LightORM

This is a lightweight CRUD ORM template for .NET data access application. You can use the DataContext to execute Insert, Update, Delete and Select action to database. Currently only support the MSSQL and MySQL database. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework

ZayniFramework.Caching.RemoteCache

This is a ZayniFramework build-in Remote Share Data Service. You can use the ZayniFramework.Caching module to store data into this service. Also it support telnent service commands. GitLab Repository: https://gitlab.com/ponylin1985/ZayniFramework

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.142 96 3/19/2024
8.0.141 111 1/4/2024
8.0.140 126 12/17/2023
6.0.138 113 3/19/2024
6.0.137 177 9/20/2023
6.0.136 151 9/14/2023
6.0.135 174 9/10/2023
6.0.134 205 7/12/2023
6.0.133 211 7/10/2023
6.0.132 210 7/7/2023
6.0.131 231 6/19/2023
6.0.130 227 6/19/2023
6.0.129 10,149 7/2/2022
6.0.128 697 1/16/2022
6.0.127 715 1/15/2022
6.0.126 728 1/15/2022
6.0.125 425 1/8/2022
6.0.125-hotfix1 250 1/8/2022
6.0.124 402 1/7/2022
6.0.123 572 11/14/2021
5.0.129 867 7/2/2022
5.0.128 837 1/16/2022
5.0.125 458 1/8/2022
5.0.124 457 1/7/2022
5.0.123 640 11/14/2021
5.0.122 741 10/11/2021
5.0.121 760 5/1/2021
3.1.137 248 9/20/2023
3.1.136 163 9/14/2023
3.1.135 216 9/10/2023
3.1.134 225 7/12/2023
3.1.133 253 7/11/2023
3.1.132 247 7/8/2023
3.1.131 223 6/19/2023
3.1.130 550 2/1/2023
3.1.129 1,064 7/2/2022
3.1.128 1,135 1/16/2022
3.1.125 549 1/8/2022
3.1.124 530 1/7/2022
3.1.123 762 11/14/2021
3.1.122 771 10/11/2021
3.1.121 886 5/1/2021
2.31.120 721 3/14/2021
2.30.115 3,532 3/6/2021
2.30.114 665 3/6/2021
2.20.101 1,338 3/1/2021
2.19.3 721 2/11/2021
2.19.2 10,312 2/6/2021
2.19.1 880 1/6/2021
2.19.0 930 1/1/2021
2.18.3 1,016 12/27/2020
2.18.2 1,722 8/29/2020
2.18.1 1,005 8/26/2020
2.18.0 5,283 8/20/2020
2.17.135 1,075 8/19/2020
2.17.134 1,100 7/28/2020
2.17.133 1,113 7/27/2020
2.17.132 1,094 7/18/2020
2.17.131 1,290 7/11/2020
2.16.130 1,192 6/13/2020
2.15.128 1,166 6/3/2020
2.15.127 1,189 5/31/2020
2.15.126 2,094 4/30/2020
2.14.122 1,059 4/13/2020
2.13.100 1,256 3/12/2020
2.12.51 1,265 2/18/2020
2.11.50 2,930 2/10/2020
2.10.44 2,903 1/30/2020
2.9.43 3,158 1/11/2020
2.8.42 2,932 1/10/2020
2.8.41 3,027 1/5/2020
2.7.40 2,948 1/2/2020
2.7.39 2,938 1/2/2020
2.7.38 3,019 1/1/2020
2.6.37 2,834 12/23/2019
2.6.35 3,189 12/4/2019
2.6.1 2,849 12/2/2019
2.6.0 2,828 11/28/2019
2.5.2 3,123 11/26/2019
2.5.1 2,892 11/12/2019
2.5.0 2,873 11/9/2019
2.4.3 3,119 10/16/2019
2.4.2 2,906 10/16/2019
2.4.1 3,074 9/20/2019
2.3.113 704 3/6/2021
2.3.112 630 3/6/2021
2.3.28 2,920 9/19/2019
2.3.27 3,127 8/30/2019
2.3.26 2,931 8/20/2019
2.3.25 2,883 8/12/2019
2.3.22 2,853 7/31/2019
2.3.21 3,177 7/20/2019
2.3.20 2,907 6/22/2019
2.3.19 2,899 6/14/2019
2.3.18 2,917 6/13/2019
2.3.17 2,922 6/13/2019
2.3.15 3,001 6/8/2019
2.3.14 2,917 6/8/2019
2.3.13 3,015 5/30/2019
2.3.12 1,330 5/24/2019
2.3.11 1,322 5/24/2019
2.3.10 1,268 5/21/2019
2.3.9 1,250 5/9/2019
2.3.8 1,277 5/8/2019
2.3.7 1,322 4/30/2019
2.3.6 1,338 4/23/2019
2.3.5 1,322 4/19/2019
2.3.4 1,208 4/18/2019
2.3.3 1,288 4/17/2019
2.3.2 1,301 4/6/2019
2.3.1 1,327 12/15/2018
2.3.0 1,375 12/7/2018
2.2.6 1,450 11/25/2018
2.2.1 1,727 11/17/2018
2.2.0 1,355 11/16/2018
2.1.0 1,395 11/15/2018
2.0.1 1,361 11/6/2018
2.0.0 1,468 11/4/2018