This repo is no longer supported and will not receive any updates nor bug fixes, This code has been moved to the main Liquid repository and will be maintained there.
This repository is part of the Liquid Application Framework, a modern Dotnet Core Application Framework for building cloud native microservices.
The main repository contains the examples and documentation on how to use Liquid.
This package contains the caching subsystem of Liquid, along with several caching implementation. In order to use it, add the main package (Liquid.Cache) to your project, along with the specific implementation that you will need. Liquid takes care of the serialization
Available implementations:
Available Cartridges | Badges | |
---|---|---|
Liquid.Cache.Redis | Cache implementation using Redis as a backing service. | |
Liquid.Cache.Ignite | Cache implementation using Apache Ignite as a backing service. | |
Liquid.Cache.Memory | Local in memory cache. Primarily to be used for mocking / testing. | |
Liquid.Cache.NCache | Caching implementation based on NCache distributed caching. |
This is a sample usage with the main methods of the cache.
using Liquid.Cache;
namespace Liquid.Samples.Cache
{
public class SampleCache
{
// Obtain your copy of the configured cache via Dependency Injection
private readonly ILightCache _cache;
public SampleCache(ILightCache cache)
{
_cache = cache;
}
public async CacheUsage() {
// obtains a value from the cache
var myvalue = await _cache.RetrieveAsync<string>("mycacheKey");
var myvalue2 = await _cache.RetrieveAsync<string>("mycacheKey2") ?? "defaultValue";
// add a value to the cache, with 1 minute expiration time
await _cache.AddAsync("mycacheKey", "my value", TimeSpan.FromMinutes(1));
// checks for existence of key
var exists = await _cache.ExistsAsync("mycachekey");
}
}
}
Dependency Injection (sample using Redis Cartridge)
using Liquid.Cache.Memory;
services.AddDefaultTelemetry();
services.AddDefaultContext();
services.AddLightRedisCache();
appsettings.json
{
"liquid": {
"cache": {
"redis": {
"connectionString": "localhost:6379,ssl=false,allowAdmin=true, asyncTimeout=10000"
}
}
}
}