Second Level Cache Beta-2 for EntityFramework 6.1+ shipped

When I published the Beta version of EFCache back in May I intentionally did not call it Beta-1 since at that time I did not plan to ship Beta-2. Instead, I wanted to go straight to the RTM. Alas! It turned out that EFCache could not be used with models where CUD (Create/Update/Delete) operations where mapped to stored procedures. Another problem was that in scenarios where there were multiple databases with the same schema EFCache returned cached results even if the database the app was connecting changed. I also got a pull request which I wanted to include. As a result I decided to ship Beta-2. Here is the full list of what’s included in this release:

  • support for models containing CUD operations mapped to stored procedures – invoking a CUD operation will invalidate cache items for the given entity set
  • CacheTransactionHandler.AddAffectedEntitySets is now protected – makes subclassing CacheTransactionHandler easier
  • database name is now part of the cache key – enables using the same cache across multiple databases with the same schema/structure
  • new Cached() extension method forces caching results for selected queries – results for queries marked with Cached() method will be cached regardless of caching policy, whether the query has been blacklisted or if it contains non-deterministic SQL functions. This feature started with a contribution from ragoster
  • new name – Second Level Cache for Entity Framework 6.1+ – (notice ‘+’) to indicate that EFCache works not only with Entity Framework 6.1 but also with newer point releases (i.e. all releases up to, but not including, the next major release)

The new version has been uploaded to NuGet, so update the package in your project and let me know of any issues. If I don’t hear back from you I will release the final version in a month or so.

Advertisements

11 thoughts on “Second Level Cache Beta-2 for EntityFramework 6.1+ shipped

  1. Casey says:

    I’m only just seeing this but it’s really exciting. Keep up the good work.

    Like

  2. […] is very exciting! Finally after some travelling and getting the beta-2 version of the Second Level Cache for EF 6.1+ out the door I was able to focus on store functions for EF Code First. I pushed quite hard for the […]

    Like

  3. Mike says:

    Hi Pawel,
    first I want to thank you for the hard work!

    I use your EfCache in my running webapplication and since there I get the following error sometimes:

    “Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries”

    StackTrace:
    bei System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    bei System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
    bei System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
    bei System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
    bei System.Data.SqlClient.SqlDataReader.get_MetaData()
    bei System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    bei System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
    bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
    bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
    bei System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
    bei System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
    bei EFCache.CachingCommand.ExecuteDbDataReader(CommandBehavior behavior)
    bei System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
    bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
    bei System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

    Thanks and and best regards!

    Like

    • Mike says:

      Sorry, the error has nothing to do with your EfCache.
      The problem came from this linq query:
      “query.Where(x => words.All(w => x.Title.Contains(w)))” // words.Length to big!

      Like

      • moozzyk says:

        I am glad you were able to resolve the issue. I was about to comment that it is unlikely the issue was introduced by the cache since the cache does not rewrite/change the SQL queries.

        Thanks,
        Pawel

        Like

  4. Mike says:

    Hi again, the EfCache definitly doesn’t work with Spatial columns.

    https://efcache.codeplex.com/discussions/546912
    Are there any news about it?

    Thanks and and best regards!

    Like

  5. Mike says:

    Hi Pawel, I tried to implement a custom CachingPolicy to exclude specific tables (contains spatial column).
    The problem is, that you declare the virtual method as internal:
    protected internal virtual bool CanBeCached
    Are threre any reasons you did that?
    Thanks

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: