Castle Active Record - Working with the cache
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2010-04-12T10:12:04Z
Indexed on
2010/04/12
12:53 UTC
Read the original article
Hit count: 353
c#
|castle-activerecord
Hi All, im new to the Castle Active Record Pattern and Im trying to get my head around how to effectivley use cache. So what im trying to do (or want to do) is when calling the GetAll, find out if I have called it before and check the cache, else load it, but I also want to pass a bool paramter that will force the cache to clear and requery the db.
So Im just looking for the final bits. thanks
public static List<Model.Resource> GetAll(bool forceReload)
{
List<Model.Resource> resources = new List<Model.Resource>();
//Request to force reload
if (forceReload)
{
//need to specify to force a reload (how?)
XmlConfigurationSource source = new XmlConfigurationSource("appconfig.xml");
ActiveRecordStarter.Initialize(source, typeof(Model.Resource));
resources = Model.Resource.FindAll().ToList();
}
else
{
//Check the cache somehow and return the cache?
}
return resources;
}
public static List<Model.Resource> GetAll()
{
return GetAll(false);
}
© Stack Overflow or respective owner