SimpleProxyCache 1.0.2
See the version list below for details.
dotnet add package SimpleProxyCache --version 1.0.2
NuGet\Install-Package SimpleProxyCache -Version 1.0.2
<PackageReference Include="SimpleProxyCache" Version="1.0.2" />
paket add SimpleProxyCache --version 1.0.2
#r "nuget: SimpleProxyCache, 1.0.2"
// 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
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 | Versions 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. |
-
.NETCoreApp 2.2
- Castle.Core.AsyncInterceptor (>= 1.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Bug fixes