LazyCacheHelpers 1.0.0.1

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

// Install LazyCacheHelpers as a Cake Tool
#tool nuget:?package=LazyCacheHelpers&version=1.0.0.1

LazyCacheHelpers

Library for leveraging the power of Lazy<T> for caching at all layers of an application with support for both Sync & Async Lazy operations to maximize server utilization and performance!

The use of Lazy<T> for loading/initializing of data facilitates a self-populating cache, so that the long running processes are never executed more than once. And, even if they are triggered at the exact same time, no more than one thread will ever perform the work, dramatically decreasing server utilization under high load.

This class provides a completely ThreadSafe cache with Lazy loading/initialization capability in an easy to use implementation that can work at all levels of an application (classes, controllers, etc.). It also supports changing the underlying Cache Repository with different implementations via ILazyCacheRepository implementation.

NOTE: A default implementation using .Net MemoryCache is implemented (via default ICacheRepository implementation as LazyDotNetMemoryCacheRepository) to enable working with MemoryCache with greatly simplified support for self-populating (Lazy) initialization.

It's as easy as . . .

Synchronous Caching:

private static readonly string _cacheTTLConfigKey = "CacheTTL.LongRunningProcess";

function ComplexData GetComplexData(string variable)
{
	return DefaultLazyCache.GetOrAddFromCache($"CacheKey::{variable}", 
		() => {
			return BuildVeryComplexData();
		},
		LazyCachePolicy.NewAbsoluteExpirationPolicy(_cacheTTLConfigKey)
	);
}

Aynchronous Caching:

private static readonly string _cacheTTLConfigKey = "CacheTTL.LongRunningProcess";

function async Task<ComplexData> GetComplexDataAsync(string variable)
{
	return await DefaultLazyCache.GetOrAddFromCache($"CacheKey::{variable}", 
		async () => {
			return await BuildVeryComplexDataAsync();
		},
		LazyCachePolicy.NewAbsoluteExpirationPolicy(_cacheTTLConfigKey)
	);
}
/*
MIT License

Copyright (c) 2018

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on LazyCacheHelpers:

Package Downloads
SqlBulkHelpers

A library for easy, efficient and high performance bulk insert and update of data, into a Sql Database, from .Net applications. By leveraging the power of the SqlBulkCopy classes with added support for Identity primary key table columns this library provides a greatly simplified interface to process Identity based Entities with Bulk Performance with the wide compatibility of .NetStandard 2.0.

LazyCacheHelpers.ConfigurationManager

Extension package for the LazyCacheHelpers Library to provide easy to use helpers to read cache configuration values from App.Config or Web.config files using System.Configuration; making things like enabling/disabling and dynamic fallback from specialized to generalized config values much easier to implement.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.2 13,383 11/16/2022
1.3.1 2,857 10/11/2022
1.3.0 368 10/11/2022
1.2.0 2,405 9/30/2022
1.1.0 3,512 7/29/2022
1.0.4 11,289 5/17/2022
1.0.3 7,054 8/1/2021
1.0.2 702 1/23/2021
1.0.0.1 490 10/22/2019

Initial nuget release.