package ${packageName};

import cc.smtweb.framework.core.annotation.SwCache;
import cc.smtweb.framework.core.cache.AbstractEntityCache;
import cc.smtweb.framework.core.cache.CacheManager;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;

/**
 * Created by ${user} at ${sysTime}
 * 实体【[${tableTitle}](${tableName})】的缓存类
 */
@SwCache(ident = "${tableName}", title = "${tableTitle}")
public class ${beanName}Cache extends AbstractEntityCache<${beanName}> {
<#list caches as cache>
    //缓存key：${cache.title}
    public final static String mk_${cache.name} = "${cache.name}";
</#list>

    public static ${beanName}Cache getInstance() {
        return CacheManager.getIntance().getCache(${beanName}Cache.class);
    }

    public ${beanName}Cache() {
<#list caches as cache>
        //缓存key：${cache.title}
        <#if cache.type=="M">
        regMap(mk_${cache.name}, "${cache.fields}");
        <#else>
        regList(mk_${cache.name}, "${cache.fields}");
        </#if>
</#list>
    }

<#list caches as cache>
        <#if cache.type=="M">
    //缓存key：${cache.title}
    public final ${beanName} getBy${cache.nameUF}(String key) {
        return getByKey(mk_${cache.name}, key);
    }
        <#else>
    //缓存key：${cache.title}
    public final Set<${beanName}> getBy${cache.nameUF}(String key) {
        return getListByKey(mk_${cache.name}, key);
    }
        </#if>
</#list>
}
