MemoizeRedis 1.2.1

dotnet add package MemoizeRedis --version 1.2.1                
NuGet\Install-Package MemoizeRedis -Version 1.2.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="MemoizeRedis" Version="1.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MemoizeRedis --version 1.2.1                
#r "nuget: MemoizeRedis, 1.2.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 MemoizeRedis as a Cake Addin
#addin nuget:?package=MemoizeRedis&version=1.2.1

// Install MemoizeRedis as a Cake Tool
#tool nuget:?package=MemoizeRedis&version=1.2.1                

MemoizeRedis

This project enables the Memoization (caching) of Method calls to a redis database. It is very basic at the moment meant mostly for internal usage but I decided to publish as it might be helpful for others as I had to overcome some trouble.

The project is not performance optimized and relies on some slow things (reflection).

It will probably undergo rewrites as I'd like to move this to a sourcecode generated Attribute (AOS) style caching of method calls but haven't had the time.

Memoization Settings can be passed to the instance, or they will be loaded by default from appsettings.json to point toward your redis cache.

{
  "cache": {
    "server": "172.18.39.138",
    "ttl": 24
    }
}

The program relies on some lazy "singleton" creation just to make my usage of it easier in various projects.

Setup your appsettings.json like above, and then you can call any function like:

using MemoizeRedis;

var returnValue = await Memoize.WithRedisAsync(() => AnyFunction(someParam, someParam2));

MemoizeRedis will check the Redis for a cached copy with the key based on the function name and parameters passed in to the function. If no cached copy exists, it will run the function. Once a return from the function occurs it will Serialize to JSON the results, and save that to Redis for future usage in calls with the same function/params.

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 (1)

Showing the top 1 NuGet packages that depend on MemoizeRedis:

Package Downloads
cnmWebApi

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 144 6/14/2023

Fixed a major issue for when the expression we're passing has non MemberExpression or Unary Arguments.