Turning off caching

Posts   
 
    
mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 15-May-2013 08:11:40   

Is there a way to globally turn off new caching feature. Useful when debugging.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-May-2013 08:47:30   

Not built-in. Out of my head, I can think of these options:

A. Manage your own AppSetting on your config and check for it when creating your QueryParameters:

// register caching
CacheController.RegisterCache(string.Empty, new ResultsetCache());

// determine globally whether or not to use caching
var cachingEnabled = GetCachingEnabledFlagFromConfig();
            
var customers = new EntityCollection<CustomerEntity>();         
using (var adapter = new DataAccessAdapter())
{
    var parameters = new QueryParameters()
    {
        CollectionToFetch = customers,
        FilterToUse = CustomerFields.Country == "USA",
        CacheResultset = cachingEnabled,
        CacheDuration = new TimeSpan(0, 0, 10)  // cache for 10 seconds
    };
    adapter.FetchEntityCollection(parameters);
}

B. Create your own version of ResultsetCache that checks for that AppSeting (see A), so it knows whether or not to turn on/off _purgeTimer.Enabled at the ctor.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 15-May-2013 09:22:12   

Didn't think of that scenario, would be a useful addition, though David's workaround might also work till the switch is added in a future version simple_smile

Frans Bouma | Lead developer LLBLGen Pro
mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 15-May-2013 09:55:40   

I think I'll just do .CacheResultset(TimeSpan.FromMinutes(x)) where x is going to be 0 when debugging for the time being (using LINQ to LLBLGenPro). But thanks for the other options.

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 15-May-2013 10:57:30   

Or even easier, when debugging, don't RegisterCache at all. simple_smile