SimpleProxyCache 1.0.2

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

// Install SimpleProxyCache as a Cake Tool
#tool nuget:?package=SimpleProxyCache&version=1.0.2                

Simple-proxy-cache

NuGet

Description

Using AOP and proxy pattern to cache method result (both sync and async) all using attributes over method. Under the hood, this library will cache result of method given a sequence of arguments. So if we call the method with the same sequence of arguments for the second time then we just use the cached result instead.

Example

Add [CacheResult] or [InvalidateCache] attribute over interface methods:

public interface IFoo
{
    [CacheResult]
    string Get(string id);

    [CacheResult]
    Task<string> GetAsync(string id);
    
    [InvalidateCache]
    void Delete(string id);

    [InvalidateCache]
    Task DeleteAsync(string id);
}

Create a cache proxy instance (use SimpleMethodMemoryCache or an interface that implements ICacheMethodUtility)

// Re-use the same instance
var proxyGenerator = new ProxyGenerator();

// Create instance of Foo
Foo target = new Foo();

// Create cached proxy instance
var cachedFoo = CacheInterceptorBuilder.New<IFoo>()
  .WithProxyGenerator(proxyGenerator)
  .WithStore(new SimpleMethodMemoryCache())
  .Build(target);
  
// This will call the target method
cachedFoo.Get("Hello world!");

// The target method will not get called because we cached this method with "Hello world!" argument
cachedFoo.Get("Hello world!");

Notes

  • Note that if method does not have any attributes then it will not be proxied or caches.
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.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 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
1.0.3 593 6/30/2019
1.0.2 529 6/30/2019
1.0.1 496 6/28/2019
1.0.0 494 6/27/2019

Bug fixes