Skip to content

Commit

Permalink
Changes in package naming and also documentation changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelJCamara committed Oct 28, 2023
1 parent 6e66a99 commit f812268
Show file tree
Hide file tree
Showing 35 changed files with 612 additions and 109 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,5 @@ FodyWeavers.xsd
.DS_Store
k8s/sp.sh
.vscode/settings.json

.idea/
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

Nebula.Caching is an Open-Source caching library that allows you to use caching in your projects with minimal configuration.

As of today, we support caching using Redis and InMemory, but in the future we hope to support your favourite caching provider!
As of today, we support caching using Redis, InMemory and Memcached, but in the future we hope to support your favourite caching provider!

## Nuget Package

| Name | Released Package |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Nebula-Caching-Redis | [![BotBuilder Badge](https://buildstats.info/nuget/Nebula-Caching-Redis?includePreReleases=true&dWidth=70)](https://www.nuget.org/packages/Nebula-Caching-Redis/) |
| Nebula-Caching-InMemory | [![BotBuilder Badge](https://buildstats.info/nuget/Nebula-Caching-InMemory?includePreReleases=true&dWidth=70)](https://www.nuget.org/packages/Nebula-Caching-InMemory/) |
| Nebula-Caching-Memcached | [![BotBuilder Badge](https://buildstats.info/nuget/Nebula-Caching-Memcached?includePreReleases=true&dWidth=70)](https://www.nuget.org/packages/Nebula-Caching-Memcached/) |
| NebulaCaching.Redis | [![BotBuilder Badge](https://buildstats.info/nuget/NebulaCaching.Redis?includePreReleases=true&dWidth=70)](https://www.nuget.org/packages/Caching.Nebula.Redis/) |
| NebulaCaching.InMemory | [![BotBuilder Badge](https://buildstats.info/nuget/NebulaCaching.InMemory?includePreReleases=true&dWidth=70)](https://www.nuget.org/packages/Caching.Nebula.InMemory) |
| NebulaCaching.Memcached | [![BotBuilder Badge](https://buildstats.info/nuget/NebulaCaching.Memcached?includePreReleases=true&dWidth=70)](https://www.nuget.org/packages/Caching.Nebula.Memcached/) |

## Usage

Expand All @@ -26,19 +26,19 @@ As of today, we support caching using Redis and InMemory, but in the future we h
Install the package via Package Manager:

```
Install-Package Nebula-Caching-Redis
Install-Package Nebula-Caching-InMemory
Install-Package Nebula-Caching-Memcached
Install-Package NebulaCaching.Redis
Install-Package NebulaCaching.InMemory
Install-Package NebulaCaching.Memcached
```

or

Via .NET CLI:

```
dotnet add package Nebula-Caching-Redis
dotnet add package Nebula-Caching-InMemory
dotnet add package Nebula-Caching-Memcached
dotnet add package NebulaCaching.Redis
dotnet add package NebulaCaching.InMemory
dotnet add package NebulaCaching.Memcached
```

### Step 2 : Register cache usage in the Program class (will change depending on which caching provider you are using, please refer to the package documentation)
Expand All @@ -52,7 +52,7 @@ public class Program
// ...
builder.Host.UseNebulaCaching();
builder.Services.AddRedisChache(new Configurations
builder.Services.AddRedisChache(new RedisConfigurations
{
//some amazing configuration options which can be see in the samples or documentation section
});
Expand Down
4 changes: 2 additions & 2 deletions docs/documentation/Redis/AttributeUsage/AttributeUsage.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Let's take a closer look at the structure of the second configuration cache key
//this is the key we are analyzing
Gorold-Payment-Attributes-RedisStuff--SomeMethod--{param1}--{param2}--{name}
Gorold-Payment-Attributes-RedisStuff -> Namespace where the interface, where the attribute was placed, implementation is located. Notice that we replaced all the '.' for '-'.
Gorold-Payment-Attributes-RedisStuff -> Namespace where the interface, on which the attributes were placed, implementation is located. Notice that we replaced all the namespace '.' for '-'.
--SomeMethod--{param1}--{param2}--{name} -> The remaining part of the key is constitued of the method where the attribute was placed, plus the methods it might contain. If no parameters exist, then we don't need to insert them on the cache key definition. If you notice closely, when you are adding cache duration for methods that take parameters, you must add such parameters inside the curly braces. You should add only the parameter name, not its value. Also notice that, unline above, we use double '-' to separate things.
```
Expand Down Expand Up @@ -153,7 +153,7 @@ An example of that can be seen below:

```json
"Redis": {
"CacheGroupSettings": {
"CacheSettings": {
"MyCustomCacheName" : "04:00:00"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Program
// ...
builder.Host.UseNebulaCaching();
builder.Services.AddRedisChache(new Configurations
builder.Services.AddRedisChache(new RedisConfigurations
{
//some amazing configuration options
});
Expand Down Expand Up @@ -112,7 +112,7 @@ public class Program
{
// ...
builder.Host.UseNebulaCaching();
builder.Services.AddRedisChache(new Configurations
builder.Services.AddRedisChache(new RedisConfigurations
{
ConfigurationSection = "RedisConfig",
ConfigurationFlavour = RedisConfigurationFlavour.Vanilla,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nebula.Caching.InMemorySample", "Nebula.Caching.InMemorySample\Nebula.Caching.InMemorySample.csproj", "{C0DBA380-6D13-4E31-8662-2897207F3AB0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0DBA380-6D13-4E31-8662-2897207F3AB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0DBA380-6D13-4E31-8662-2897207F3AB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0DBA380-6D13-4E31-8662-2897207F3AB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0DBA380-6D13-4E31-8662-2897207F3AB0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;

namespace Nebula.Caching.InMemorySample.Controllers;

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18977",
"sslPort": 44367
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5029",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7101;http://localhost:5029",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Nebula.Caching.InMemorySample;

public class WeatherForecast
{
public DateOnly Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string? Summary { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nebula.Caching.MemcachedSample", "Nebula.Caching.MemcachedSample\Nebula.Caching.MemcachedSample.csproj", "{2A8CC86B-2D17-4890-AFD2-BC67ACECF6CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A8CC86B-2D17-4890-AFD2-BC67ACECF6CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A8CC86B-2D17-4890-AFD2-BC67ACECF6CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A8CC86B-2D17-4890-AFD2-BC67ACECF6CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A8CC86B-2D17-4890-AFD2-BC67ACECF6CB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;

namespace Nebula.Caching.MemcachedSample.Controllers;

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
Loading

0 comments on commit f812268

Please sign in to comment.