This is a migrated thread and some comments may be shown as answers.

Maintain caches after ReplaceMetadata?

0 Answers 13 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Cory
Top achievements
Rank 1
Cory asked on 09 Mar 2016, 02:49 PM

Hi,

I've posted about my situation before and I've had a lot of success with the Fluent API so far, but I've run into a problem. Due to the dynamic nature of my database, I've been making regular calls to ReplaceMetadata. The main problem with that seems to be that my caches are being wiped out every time, specifically the prepared statements cache, which is causing some of my GetAll() calls to perform extremely slowly. A query that normally takes seconds is taking over a minute. It's my understanding that after the initial run-through, it should perform much quicker, assuming it's been cached.

Another major issue in my setup is that the data is being exposed through OData controllers, meaning new context instances are being created with each request. However, this is more of an internal issue so I'll focus my questions around the ReplaceMetadata call.

Why am I calling ReplaceMetadata so much? Well, our database contains tables that describe other, user-defined tables. This means we need access to the description table data before we can configure the mapping for the user-defined tables. We've added collection properties in the FluentMetadataSource class to help us do that. The current process goes something like:

1. PrepareMapping() for the tables we know about

2. Within OnContextCreated(), create a new MetadataSource object and populate our collection properties (description table data) using our current model

3. Replace our current metadata with the newly populated object

4. PrepareMapping() for ALL tables, using the now populated collections to map the user-defined tables

 

I hope I explained that well enough. 

Based on this setup, is there any way to maintain the prepared statements and/or level 2 caches? Any tips in general?

As always, your input is greatly appreciated,

-Cory

 

Tags
Development (API, general questions)
Asked by
Cory
Top achievements
Rank 1
Share this question
or