3
In an application I use sixteen times a code like
var cliente = db.Clientes.Find(id);
So that’s why 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 got extremely fast, but I’m caching the entire model, imagining that different id will be around 300, so it will be 300 x Model in memory on IIS. I remember that in the past it was not recommended to store entire Recordsets in Session, in theory I am not doing this?
Now I don’t know which is better, search 6000x in the database or store 300model in memory.
Is there any way to verify the memory used in the cache? will 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.
I do not see how bad practice, in case the memory of the machine where the IIS is not enough, you can still change the Preview of your Cache. I advise you to take a look at Redisoutputcacheprovider
– Tobias Mesquita
One more thing, a 10-hour cache may not be ideal. and try to invalidate the cache whenever the log changes.
– Tobias Mesquita