forked from dotnetcore/EasyCaching
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
267b120
commit 8206e26
Showing
24 changed files
with
562 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 21 additions & 21 deletions
42
...terceptor/Controllers/ValuesController.cs → ...spectCore/Controllers/ValuesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
namespace EasyCaching.Demo.Interceptor.Controllers | ||
{ | ||
using EasyCaching.Demo.Interceptor.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
[Route("api/[controller]")] | ||
public class ValuesController : Controller | ||
{ | ||
private readonly IDateTimeService _service; | ||
|
||
public ValuesController(IDateTimeService service) | ||
{ | ||
this._service = service; | ||
namespace EasyCaching.Demo.Interceptor.AspectCore.Controllers | ||
{ | ||
using EasyCaching.Demo.Interceptor.AspectCore.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
[Route("api/[controller]")] | ||
public class ValuesController : Controller | ||
{ | ||
private readonly IDateTimeService _service; | ||
|
||
public ValuesController(IDateTimeService service) | ||
{ | ||
this._service = service; | ||
} | ||
|
||
[HttpGet] | ||
public string Get() | ||
{ | ||
return _service.GetCurrentUtcTime(); | ||
} | ||
} | ||
} | ||
|
||
[HttpGet] | ||
public string Get() | ||
{ | ||
return _service.GetCurrentUtcTime(); | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace EasyCaching.Demo.Interceptor.AspectCore | ||
{ | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
|
||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
BuildWebHost(args).Run(); | ||
} | ||
|
||
public static IWebHost BuildWebHost(string[] args) => | ||
WebHost.CreateDefaultBuilder(args) | ||
.UseStartup<Startup>() | ||
.UseUrls("http://localhost:55555") | ||
.Build(); | ||
} | ||
} |
6 changes: 4 additions & 2 deletions
6
...Interceptor/Services/IDatetimeServices.cs → ....AspectCore/Services/IDatetimeServices.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 37 additions & 37 deletions
74
...e/EasyCaching.Demo.Interceptor/Startup.cs → ...ng.Demo.Interceptor.AspectCore/Startup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
namespace EasyCaching.Demo.Interceptor | ||
namespace EasyCaching.Demo.Interceptor.AspectCore | ||
{ | ||
using System; | ||
using EasyCaching.Demo.Interceptor.Services; | ||
using EasyCaching.InMemory; | ||
using EasyCaching.Interceptor.AspectCore; | ||
using System; | ||
using EasyCaching.Demo.Interceptor.AspectCore.Services; | ||
using EasyCaching.InMemory; | ||
using EasyCaching.Interceptor.AspectCore; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
public class Startup | ||
{ | ||
public Startup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
public IServiceProvider ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMvc(); | ||
|
||
services.AddScoped<IDateTimeService,DateTimeService>(); | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
public class Startup | ||
{ | ||
public Startup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
public IServiceProvider ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddScoped<IDateTimeService, DateTimeService>(); | ||
|
||
services.AddDefaultInMemoryCache(); | ||
|
||
return services.ConfigureAspectCoreInterceptor(); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.UseMvc(); | ||
} | ||
} | ||
} | ||
|
||
services.AddMvc(); | ||
|
||
return services.ConfigureAspectCoreInterceptor(); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.UseMvc(); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
sample/EasyCaching.Demo.Interceptor.Castle/Controllers/ValuesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace EasyCaching.Demo.Interceptor.Castle.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
public class ValuesController : Controller | ||
{ | ||
private readonly IDateTimeService _service; | ||
|
||
public ValuesController(IDateTimeService service) | ||
{ | ||
this._service = service; | ||
} | ||
|
||
[HttpGet] | ||
public string Get() | ||
{ | ||
return _service.GetCurrentUtcTime(); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
sample/EasyCaching.Demo.Interceptor.Castle/EasyCaching.Demo.Interceptor.Castle.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Services\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\EasyCaching.Core\EasyCaching.Core.csproj" /> | ||
<ProjectReference Include="..\..\src\EasyCaching.Interceptor.Castle\EasyCaching.Interceptor.Castle.csproj" /> | ||
<ProjectReference Include="..\..\src\EasyCaching.InMemory\EasyCaching.InMemory.csproj" /> | ||
</ItemGroup> | ||
</Project> |
2 changes: 1 addition & 1 deletion
2
...e/EasyCaching.Demo.Interceptor/Program.cs → ...aching.Demo.Interceptor.Castle/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
sample/EasyCaching.Demo.Interceptor.Castle/Services/IDatetimeServices.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace EasyCaching.Demo.Interceptor.Castle | ||
{ | ||
using EasyCaching.Core.Internal; | ||
|
||
public interface IDateTimeService | ||
{ | ||
string GetCurrentUtcTime(); | ||
} | ||
|
||
public class DateTimeService : IDateTimeService , IEasyCaching | ||
{ | ||
[EasyCachingInterceptor(Expiration = 10)] | ||
public string GetCurrentUtcTime() | ||
{ | ||
return System.DateTime.UtcNow.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace EasyCaching.Demo.Interceptor.Castle | ||
{ | ||
using EasyCaching.InMemory; | ||
using EasyCaching.Interceptor.Castle; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
|
||
public class Startup | ||
{ | ||
public Startup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
public IServiceProvider ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMvc(); | ||
|
||
services.AddTransient<IDateTimeService,DateTimeService>(); | ||
|
||
services.AddDefaultInMemoryCache(); | ||
|
||
return services.ConfigureCastleInterceptor(); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.UseMvc(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
sample/EasyCaching.Demo.Interceptor.Castle/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"LogLevel": { | ||
"Default": "Debug", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
sample/EasyCaching.Demo.Interceptor.Castle/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"Debug": { | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
}, | ||
"Console": { | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/EasyCaching.Core/Internal/EasyCachingInterceptorAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace EasyCaching.Core.Internal | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Easycaching interceptor attribute. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method, Inherited = true)] | ||
public class EasyCachingInterceptorAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Gets or sets the expiration. | ||
/// </summary> | ||
/// <value>The expiration.</value> | ||
public int Expiration { get; set; } = 30; | ||
|
||
/// <summary> | ||
/// Gets or sets the parameter count. | ||
/// </summary> | ||
/// <value>The parameter count.</value> | ||
public int ParamCount { get; set; } = 5; | ||
} | ||
} |
Oops, something went wrong.