-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Setting up persistence caching example.
- Loading branch information
1 parent
2a1071f
commit 726941d
Showing
17 changed files
with
132 additions
and
22 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
9 changes: 9 additions & 0 deletions
9
Examples/Caching/Examples.Caching.PersistenceCaching/ITestApplicationService.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,9 @@ | ||
using RCommon.TestBase.Entities; | ||
|
||
namespace Examples.Caching.PersistenceCaching | ||
{ | ||
public interface ITestApplicationService | ||
{ | ||
Task<ICollection<Customer>> GetCustomers(object cacheKey); | ||
} | ||
} |
56 changes: 48 additions & 8 deletions
56
Examples/Caching/Examples.Caching.PersistenceCaching/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
21 changes: 15 additions & 6 deletions
21
Examples/Caching/Examples.Caching.PersistenceCaching/TestApplicationService.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,20 +1,29 @@ | ||
using System; | ||
using RCommon.Persistence.Crud; | ||
using RCommon.TestBase.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using RCommon.Persistence.Caching.Crud; | ||
|
||
namespace Examples.Caching.PersistenceCaching | ||
{ | ||
public class TestApplicationService | ||
public class TestApplicationService : ITestApplicationService | ||
{ | ||
|
||
private readonly ICachingGraphRepository<Customer> _customerRepository; | ||
|
||
public TestApplicationService() | ||
public TestApplicationService(ICachingGraphRepository<Customer> customerRepository) | ||
{ | ||
|
||
_customerRepository = customerRepository; | ||
_customerRepository.DataStoreName = "TestDbContext"; | ||
} | ||
|
||
|
||
public async Task<ICollection<Customer>> GetCustomers(object cacheKey) | ||
{ | ||
return await _customerRepository.FindAsync(cacheKey, x => x.LastName == "Potter"); | ||
} | ||
|
||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Examples/Caching/Examples.Caching.PersistenceCaching/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,18 @@ | ||
{ | ||
"ConnectionStrings": { | ||
"TestDbContext": "Server=(localdb)\\mssqllocaldb;Database=RCommon_TestDatabase;Trusted_Connection=True;MultipleActiveResultSets=true", | ||
"TestDbConnection": "Server=(localdb)\\mssqllocaldb;Database=RCommon_TestDatabase;Trusted_Connection=True;MultipleActiveResultSets=true" | ||
}, | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Debug", | ||
"Microsoft": "Information", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"Serilog": { | ||
"MinimumLevel": { | ||
"Default": "Debug" | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
21 changes: 21 additions & 0 deletions
21
Src/RCommon.Persistence.Caching/IPersistenceBuilderExtensions.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,21 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using RCommon.Persistence.Caching.Crud; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace RCommon.Persistence.Caching | ||
{ | ||
public static class IPersistenceBuilderExtensions | ||
{ | ||
public static IPersistenceBuilder EnablePersistenceCaching(this IPersistenceBuilder builder) | ||
{ | ||
builder.Services.AddTransient(typeof(ICachingGraphRepository<>), typeof(CachingGraphRepository<>)); | ||
builder.Services.AddTransient(typeof(ICachingLinqRepository<>), typeof(CachingLinqRepository<>)); | ||
builder.Services.AddTransient(typeof(ICachingSqlMapperRepository<>), typeof(CachingSqlMapperRepository<>)); | ||
return builder; | ||
} | ||
} | ||
} |
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
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