Skip to content

ABNERMATHEUS/DevelopmentFast.CacheRedis

Repository files navigation

DevelopmentFast.Cache

Uma biblioteca para ajudar no rápido desenvolvimento para aplicar camada de Cache utilizando Redis, usando Repository Pattern.

Logo

Development Fast - Cache

Package Version Popularity
DevelopmentFast.Cache NuGet Nuget

What is it ?

📌 It is a .NET library with the responsibility to help in the fast development to apply Cache layer using Redis, using Repository Pattern.

Why i created ?

📌 To make development easier and save the time I had to configure a cache layer to apply anywhere in the project.

Where is it available ?

📌 It is available on .Nuget.org
Nuget Link

Install-Package DevelopmentFast.CacheRedis -Version 1.0.1

How to use ?

Dependency and connection injections

builder.Services.AddSingleton<IDistributedCache, RedisCache>();
builder.Services.AddStackExchangeRedisCache(x => x.Configuration = "localhost:6379");

Or

//Scoped
  services.AddScopedRedisCacheDF(x =>
  {
      x.Configuration = "localhost:6379";
  });

//Transient
  services.AddTransientRedisCacheDF(x =>
  {
      x.Configuration = "localhost:6379";
  });

//Singleton
  services.AddSingletonRedisCacheDF(x =>
  {
      x.Configuration = "localhost:6379";
  });

Constructor

private readonly IBaseRedisRepositoryDF _baseRedisRepositoryDF;

public StudentController(IBaseRedisRepositoryDF baseRedisRepositoryDF)
{
    this._baseRedisRepositoryDF = baseRedisRepositoryDF;
}

Create or Update asynchronous

var student = new Student("name_student");
await _baseRedisRepositoryDF.CreateOrUpdateAsync<Student>("key_example", student , TimeSpan.FromMinutes(1));

Create or Update synchronous

var student = new Student("name_student");
_baseRedisRepositoryDF.CreateOrUpdate<Student>("key_example", student , TimeSpan.FromMinutes(1));

Get asynchronous

var student = await _baseRedisRepositoryDF.GetAsync<Student>("key_example");

Get synchronous

var student =  _baseRedisRepositoryDF.Get<Student>("key_example");

Remove synchronous

_baseRedisRepositoryDF.Remove("key_example");

Remove asynchronous

_baseRedisRepositoryDF.RemoveAsync("key_example");

Refresh synchronous

_baseRedisRepositoryDF.Refresh("key_example");

Refresh asynchronous

_baseRedisRepositoryDF.RefreshAsync("key_example");

About

Uma biblioteca para ajudar no rápido desenvolvimento para aplicar camada de Cache utilizando Redis, usando Repository Pattern.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages