All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.gdface.facelog.db.mysql.FeatureCache Maven / Gradle / Ivy

There is a newer version: 2.5.1
Show newest version
// ______________________________________________________
// Generated by sql2java - https://github.com/10km/sql2java-2-6-7 (custom branch) 
// modified by guyadong from
// sql2java original version https://sourceforge.net/projects/sql2java/ 
// JDBC driver used at code generation time: com.mysql.jdbc.Driver
// template: cache.java.vm
// ______________________________________________________
package net.gdface.facelog.db.mysql;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import net.gdface.facelog.db.BaseTableLoadCaching;
import net.gdface.facelog.db.FeatureBean;

/**
 * cache manager for FeatureBean base {@link com.google.common.cache.LoadingCache}
* primary key (fl_feature.md5) is key * @author guyadong * */ public class FeatureCache extends BaseTableLoadCaching { private final FeatureManager manager = FeatureManager.getInstance(); /** constructor
* @see BaseTableLoadCaching#BaseTableLoadCaching(UpdateStrategy ,long , long , TimeUnit ) */ public FeatureCache(UpdateStrategy updateStrategy,long maximumSize, long duration, TimeUnit unit) { super(updateStrategy,maximumSize, duration, unit); manager.bindForeignKeyListenerForDeleteRule(); } public FeatureCache(long maximumSize, long duration, TimeUnit unit) { this(DEFAULT_STRATEGY,maximumSize,duration,unit); } public FeatureCache(long maximumSize, long durationMinutes) { this(maximumSize, durationMinutes, DEFAULT_TIME_UNIT); } public FeatureCache(long maximumSize) { this(maximumSize,DEFAULT_DURATION,DEFAULT_TIME_UNIT); } public FeatureCache() { this(DEFAULT_CACHE_MAXIMUMSIZE,DEFAULT_DURATION,DEFAULT_TIME_UNIT); } @Override public void registerListener() { manager.registerListener(tableListener); } @Override public void unregisterListener() { manager.unregisterListener(tableListener); } @Override protected String returnKey(FeatureBean bean) { return null == bean ? null : bean.getMd5(); } @Override protected FeatureBean loadfromDatabase(String key)throws Exception { return manager.loadByPrimaryKeyChecked(key); } public FeatureBean getBeanByMd5(String md5) throws ExecutionException{ return getBean(md5); } public FeatureBean getBeanByMd5Unchecked(String md5){ return getBeanUnchecked(md5); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy