Skip to content

RegionOrebroLan/.NET-Caching-Extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET-Caching-Extensions

Additions and extensions for .NET caching.

NuGet

1 Features

1.1 Configurable distributed cache

  • Configuring caching through AppSettings.json

1.1.1 Examples

1.1.1.1 Redis

Setup Redis locally with Docker:

docker run --rm -it -p 6379:6379 redis

1.2 EntityFramework distributed cache

  • IDistributedCache-implementation with EntityFramework

May be used for development and test. May not be suted for production (regarding speed). But the database-context implementations can be used with a custom implementation of a database-driven cache built with sql-queries. That may speed it up. In that scenario the database-context is used for migrations. See the setup of SqlServerCache in this solution:

1.2.1 Sqlite

1.2.2 Base-classes

2 Development

2.1 Migrations

We might want to create/recreate migrations. If we can accept data-loss we can recreate the migrations otherwhise we will have to update them.

Copy all the commands below and run them in the Package Manager Console for the affected database-context.

If you want more migration-information you can add the -Verbose parameter:

Add-Migration TheMigration -Context TheDatabaseContext -OutputDir Data/Migrations -Project Project -StartupProject Application -Verbose;

2.1.1 CacheContext (Distributed)

2.1.1.1 Create migrations
Write-Host "Removing migrations...";
Remove-Migration -Context SqliteCacheContext -Force -Project Project -StartupProject Application;
Remove-Migration -Context SqlServerCacheContext -Force -Project Project -StartupProject Application;
Write-Host "Removing current migrations-directory...";
Remove-Item "Project\Distributed\Data\Migrations" -ErrorAction Ignore -Force -Recurse;
Write-Host "Creating migrations...";
Add-Migration SqliteCacheContextMigration -Context SqliteCacheContext -OutputDir Distributed/Data/Migrations/Sqlite -Project Project -StartupProject Application;
Add-Migration SqlServerCacheContextMigration -Context SqlServerCacheContext -OutputDir Distributed/Data/Migrations/SqlServer -Project Project -StartupProject Application;
Write-Host "Finnished";
2.1.1.2 Update migrations
Write-Host "Updating migrations...";
Add-Migration SqliteCacheContextMigrationUpdate -Context SqliteCacheContext -OutputDir Distributed/Data/Migrations/Sqlite -Project Project -StartupProject Application;
Add-Migration SqlServerCacheContextMigrationUpdate -Context SqlServerCacheContext -OutputDir Distributed/Data/Migrations/SqlServer -Project Project -StartupProject Application;
Write-Host "Finnished";

About

Additions and extensions for .NET caching.

Resources

License

Stars

Watchers

Forks

Packages

No packages published