All Projects → SteffenMangold → Entityframeworkcore.cacheable

SteffenMangold / Entityframeworkcore.cacheable

Licence: apache-2.0
EntityFrameworkCore second level cache

Projects that are alternatives of or similar to Entityframeworkcore.cacheable

Efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
Stars: ✭ 10,838 (+7753.62%)
Mutual labels:  orm, entity-framework, database, dotnet-standard, dotnet-framework, dotnet-core
Entityframework Extensions
Entity Framework Bulk Operations | Improve Entity Framework performance with Bulk SaveChanges, Insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL and SQLite.
Stars: ✭ 215 (+55.8%)
Mutual labels:  entity-framework, database, dotnet-standard, dotnet-core
Pomelo.entityframeworkcore.mysql
Entity Framework Core provider for MySQL and MariaDB built on top of MySqlConnector
Stars: ✭ 2,099 (+1421.01%)
Mutual labels:  orm, entity-framework, database, dotnet-core
Mockqueryable
Moking Entity Framework Core operations such ToListAsync, FirstOrDefaultAsync etc
Stars: ✭ 281 (+103.62%)
Mutual labels:  entity-framework, dotnet-standard, dotnet-framework, dotnet-core
Ef6
This is the codebase for Entity Framework 6 (previously maintained at https://entityframework.codeplex.com). Entity Framework Core is maintained at https://github.com/dotnet/efcore.
Stars: ✭ 1,218 (+782.61%)
Mutual labels:  orm, entity-framework, database, dotnet-framework
Sharpsnmplib
Sharp SNMP Library- Open Source SNMP for .NET and Mono
Stars: ✭ 247 (+78.99%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Devicemanager.api
Web API Framework demonstrates scalable, multitenant, architecture and allows building its own solution in the minutes. Uses: Entity Framework, UnitOfWork, Repository patterns. Wrapped in Docker, Kubernetes
Stars: ✭ 168 (+21.74%)
Mutual labels:  entity-framework, database, dotnet-core
Theraot
Backporting .NET and more: LINQ expressions in .net 2.0 - nuget Theraot.Core available.
Stars: ✭ 112 (-18.84%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Etl.net
Mass processing data with a complete ETL for .net developers
Stars: ✭ 129 (-6.52%)
Mutual labels:  entity-framework, dotnet-standard, dotnet-core
Linq2db.entityframeworkcore
Bring power of Linq To DB to Entity Framework Core projects
Stars: ✭ 166 (+20.29%)
Mutual labels:  orm, entity-framework, dotnet-core
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+461.59%)
Mutual labels:  orm, cache, dotnet-core
Dotnet Etcd
A C# .NET (dotnet) GRPC client for etcd v3 +
Stars: ✭ 157 (+13.77%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Appmetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
Stars: ✭ 1,986 (+1339.13%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Linqtotwitter
LINQ Provider for the Twitter API (C# Twitter Library)
Stars: ✭ 401 (+190.58%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Tweetinvi
Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...
Stars: ✭ 812 (+488.41%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Entityworker.core
EntityWorker is an object-relation mapper(ORM) that enable .NET developers to work with relations data using objects. EntityWorker is an alternative to entityframwork. is more flexible and much faster than entity framework.
Stars: ✭ 91 (-34.06%)
Mutual labels:  orm, entity-framework, database
Minion
Background job system for .NET applications
Stars: ✭ 94 (-31.88%)
Mutual labels:  dotnet-standard, dotnet-framework, dotnet-core
Tornado Sqlalchemy
SQLAlchemy support for Tornado
Stars: ✭ 112 (-18.84%)
Mutual labels:  orm, database
Maikebing.entityframeworkcore.taos
Entity, Framework, EF, Core, Data, O/RM, entity-framework-core,TDengine
Stars: ✭ 113 (-18.12%)
Mutual labels:  orm, entity-framework
Reinforced.tecture
Aspect-based architectural framework for .NET business applications involving some FP and CQRS principles.
Stars: ✭ 113 (-18.12%)
Mutual labels:  database, dotnet-core

EntityFrameworkCore.Cacheable

A high performance second level query cache for Entity Framework Core.



What is EF Core Cacheable?

Entity Framework (EF) Core Cacheable is an extention library for the popular Entity Framework data access technology.

It provides caching functionality for all types of query results. Based on expression tree and parameters, the context decide rather to execute query against database or returning result from memory.

How caching affects performance

This a sample result of 1,000 iterations of an uncached and cached query, called agains a really good performing MSSQL-database.

Average database query duration [+00:00:00.1698972].
Average cache query duration [+00:00:00.0000650].
Cached queries are x2,611 times faster.

Even with a InMemory test database, the results are significant faster.

Average database query duration [+00:00:00.0026076].
Average cache query duration [+00:00:00.0000411].
Cached queries are x63 times faster.

The performance gain can be even higher, depending on the database performance.

Install via NuGet

You can view the package page on NuGet.

To install EntityFrameworkCore.Cacheable, run the following command in the Package Manager Console:

PM> Install-Package EntityFrameworkCore.Cacheable

This library also uses the Data.HashFunction and aspnet.Extensions as InMemory cache.

Configuring a DbContext

There are three types of configuring the DbContext to support Cachable. Each sample use UseSqlite as option only for showing the pattern.

For more information about this, please read configuring DbContextOptions.

Constructor argument

Application code to initialize from constructor argument:

var optionsBuilder = new DbContextOptionsBuilder<CacheableBloggingContext>();
optionsBuilder
    .UseSqlite("Data Source=blog.db")
    .UseSecondLevelCache();

using (var context = new CacheableBloggingContext(optionsBuilder.Options))
{
    // do stuff
}

OnConfiguring

Context code with OnConfiguring:

public partial class CacheableBloggingContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        if (!optionsBuilder.IsConfigured)
        {
            optionsBuilder.UseSqlite("Data Source=blog.db");
            optionsBuilder.UseSecondLevelCache();
        }
    }
}

Using DbContext with dependency injection

Adding the Dbcontext to dependency injection:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<CacheableBloggingContext>(options => options
        .UseSqlite("Data Source=blog.db"))
        .UseSecondLevelCache();
}

This requires adding a constructor argument to your DbContext type that accepts DbContextOptions.

Usage

To get in use of result caching, you simply need to add .Cacheable(... to your query and define a TTL parameter.

var cacheableQuery = cacheableContext.Books
	.Include(d => d.Pages)
	.ThenInclude(d => d.Lines)
	.Where(d => d.ID == 200)
	.Cacheable(TimeSpan.FromSeconds(60));

Custom Cache Provider

Alternatively you can provide a custom implementation of ICachingProvider (default is MemoryCacheProvider). This provides a easy option for supporting other caching systems like redis or Memcached.

optionsBuilder.UseSecondLevelCache(new MyCachingProvider());

Contributors

The following contributors have either created (thats only me 😜) the project, have contributed code, are actively maintaining it (including documentation), or in other ways being helpfull contributors to this project.

Name GitHub
Steffen Mangold @SteffenMangold
Smit Patel @smitpatel
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].