This project is read-only.

Cache

Turn on caching of entities

<configuration>
  <configSections> 
    <sectionGroup name="fuse8.domainframework">
      <section name="cache" type="Fuse8.DomainFramework.Configuration.Cache.CacheServiceConfigurationHandler, Fuse8.DomainFramework" />
    </sectionGroup>    
  </configSections>
  
  <fuse8.domainframework>
    <cache keyPrefix="MyProject">
      <cacheContainers>
        <add name="ArticleCategory" enabled="true" async="false" forType="ArticleCategory" containerType="Fuse8.DomainFramework.CacheService.TagHttpCacheService" />
        <add name="Article" enabled="true" async="false" forType="Article" containerType="Fuse8.DomainFramework.CacheService.TagHttpCacheService" />
        <add name="ArticleTag" enabled="true" async="false" forType="ArticleTag" containerType="Fuse8.DomainFramework.CacheService.TagHttpCacheService" />
        <add name="Tag" enabled="true" async="false" forType="Tag" containerType="Fuse8.DomainFramework.CacheService.TagHttpCacheService" />        
      </cacheContainers>
    </cache>
  </fuse8.domainframework>
	...
</configuration>	
'forType' attribute is used to specify domain entity class name.

Cache with related items

public static class CachePolicy
{
	 public static void Init()
	 {
		 new CacheDependencyConfigurator<Article>().DependOn<ArticleCategory>().DependOn<ArticleTag>();
		 new CacheDependencyConfigurator<ArticleTag>().DependOn<Tag>();		 
	 }
}

public class CacheDependencyConfigurator<TMain> where TMain : class, IEntityObject<int>, new()
{
	private readonly CacheFacade facade = CacheFacade.GetInstance();

	public CacheDependencyConfigurator<TMain> DependOn<TDepend>() where TDepend : class, IEntityObject<int>, new()
	{
		facade.RegisterTypeDependency<TMain, int, TDepend, int>();
		return this;
	}
}

Last edited Apr 2, 2013 at 11:58 AM by SergeiP, version 5

Comments

No comments yet.