Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

Liquid Application Framework - Cache base classes and supported cartridges

License

Notifications You must be signed in to change notification settings

ava-innersource/Liquid.Cache-Deprecated

Repository files navigation

DEPRECATED No Maintenance Intended

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.

Liquid Application Framework - Cache

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.

Liquid.Cache

Quality Gate Status

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 Quality Gate Status Cache implementation using Redis as a backing service.
Liquid.Cache.Ignite Quality Gate Status Cache implementation using Apache Ignite as a backing service.
Liquid.Cache.Memory Quality Gate Status Local in memory cache. Primarily to be used for mocking / testing.
Liquid.Cache.NCache Quality Gate Status Caching implementation based on NCache distributed caching.

Getting Started

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"
      }
    }
  }
}

About

Liquid Application Framework - Cache base classes and supported cartridges

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages