Is it a bad practice to leave an entire Cache Model in IIS?

3

In an application I use several times a code like

var cliente = db.Clientes.Find(id);

So I created a controller that returns me:

[OutputCache(Duration = (10 * 60 * 60), VaryByParam = "id")]
    public static Cliente ClienteInfo(int id)
    {
        using (WMBContext db = new WMBContext())
        {
            return db.Clientes.Find(id);
        }
    }

It has been extremely fast, however I am writing the entire model cached, imagining that different ids will be around 300, so they will be 300 x Model in memory in IIS. I remember that it was not advisable to store whole RecordSets in Session, in theory I'm not doing this?

Now I do not know what's best, fetching 6000x in the database or storing 300model in memory.

Is there a way to check the memory used in the cache? will it be linked to the pool? (the code is not yet in production)

Edit OBS: This model has relationships with other models and has more than 30 properties.

    
asked by anonymous 18.07.2016 / 14:57

1 answer

1

So here , Outputcache stores just the return of your action (be html, json, etc) and not objects.

In your case, you are avoiding a query in the database (which is always good, even using entity, which uses a lot of memory resources).

Whenever possible by the logic of your application, use Outputcache to decrease the use of server resources.

About change options of Outputcache or monitor your memory usage .

    
19.07.2016 / 13:31