Skip to content

bariskisir/QuickRedis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuickRedis

QuickRedis

QuickRedis is a library that help you implement Redis quickly with useful methods.

Nuget Nuget License: MIT

How to use

Install QuickRedis from Nuget

dotnet add package QuickRedis
nuget install QuickRedis
builder.Services.AddQuickRedis(options => {
	options.Configuration = "localhost";
	options.InstanceName = "main_";
});
private readonly IQuickRedisService _quickRedisService;

public TestController(IQuickRedisService quickRedisService)
{
    _quickRedisService = quickRedisService;
}

Run redis from docker

# w/ gui
docker run -d --name redis_stack --restart unless-stopped -p 6379:6379 -p 8001:8001 -v redis_data:/data redis/redis-stack:latest

# w/o gui
docker run -d --name redis_stack_server --restart unless-stopped -p 6379:6379 -v redis_data:/data redis/redis-stack-server:latest

Methods

// GetAsync
var product = await _quickRedisService.GetAsync<Product>("unique_product_id");
var product = _quickRedisService.GetAsync<Product>("unique_product_id").Result;

// SetAsync
await _quickRedisService.SetAsync("unique_product_id", product);
_quickRedisService.SetAsync("unique_product_id", product).Wait();

// RemoveAsync
await _quickRedisService.RemoveAsync("unique_product_id");
_quickRedisService.RemoveAsync("unique_product_id").Wait();

// AddOrGetFuncAsync
List<string> TestMethod();
var methodResult = await _quickRedisService.AddOrGetFuncAsync<List<string>>("result_unique_key", () => TestMethod());
var methodResult = _quickRedisService.AddOrGetFuncAsync<List<string>>("result_unique_key", () => TestMethod()).Result;

Samples

Web Api

Console App

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages