当前位置: 首页>>代码示例>>Java>>正文


Java CacheManager类代码示例

本文整理汇总了Java中net.sf.jsr107cache.CacheManager的典型用法代码示例。如果您正苦于以下问题:Java CacheManager类的具体用法?Java CacheManager怎么用?Java CacheManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CacheManager类属于net.sf.jsr107cache包,在下文中一共展示了CacheManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cache1

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
@Test
public void cache1 () {

    Cache cache;

    try {
        CacheFactory cacheFactory = CacheManager.getInstance()
                .getCacheFactory();
        cache = cacheFactory.createCache(Collections.emptyMap());
    }

    catch (CacheException e) {
        // ...
        return;
    };

    cache.put("beispiel1", "Das ist ein Test");
    cache.put("beispiel2", "Das ist ein Versuch");
    cache.put("beispiel3", "Das ist ein Beispiel");

    assertEquals(cache.get("beispiel1"), "Das ist ein Test");
    assertEquals(cache.get("beispiel2"), "Das ist ein Versuch");
    assertEquals(cache.get("beispiel3"), "Das ist ein Beispiel");
}
 
开发者ID:KorAP,项目名称:Krill,代码行数:25,代码来源:TestCache.java

示例2: getSubteKeys

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static synchronized List<Key<Line>> getSubteKeys() {
	String functionName = "getSubteKeys()";
	if(subteKeys == null || subteKeys.size() == 0) {
		Objectify ofy = ObjectifyService.begin();
		Query<Line> q = ofy.query(Line.class).filter("type", 11);
		List<Key<Line>> keys;
		try {
        	Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
        	keys = (List<Key<Line>>)cache.get(q.toString());
        	if(keys == null) {
				keys = q.listKeys();
				cache.put(q.toString(), keys);
			}
        } catch (CacheException e) {
        	keys = q.listKeys();
        	Logger.getLogger(location).log(Level.SEVERE, functionName + ": Cache error: " + e);
        	e.printStackTrace();
        }
		subteKeys = keys;
		Logger.getLogger(location).log(Level.INFO, functionName + ": served new subteKeys. #" + subteKeys.size());
	}
	return subteKeys;
}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:25,代码来源:Dao.java

示例3: getTrainKeys

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static synchronized List<Key<Line>> getTrainKeys() {
	String functionName = "getTrainKeys()";
	if(trainKeys == null || trainKeys.size() == 0) {
		Objectify ofy = ObjectifyService.begin();
		Query<Line> q = ofy.query(Line.class).filter("type", 21);
		List<Key<Line>> keys;
		try {
        	Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
        	keys = (List<Key<Line>>)cache.get(q.toString());
        	if(keys == null) {
				keys = q.listKeys();
				cache.put(q.toString(), keys);
			}
        } catch (CacheException e) {
        	keys = q.listKeys();
        	Logger.getLogger(location).log(Level.SEVERE, functionName + ": Cache error: " + e);
        	e.printStackTrace();
        }
		trainKeys = keys;
		Logger.getLogger(location).log(Level.INFO, functionName + ": served new trainKeys. #" + trainKeys.size());
	}
	return trainKeys;
}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:25,代码来源:Dao.java

示例4: getPointsToDisplayForLine

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Collection<Point> getPointsToDisplayForLine(Line l, Objectify ofy) {
	String functionName = "getPointsForLine()";
       List<Key<Point>> keys;
       Query<Point> q = ofy.query(Point.class).ancestor(l).filter("forSearchOnly", false).order("index");
       try {
       	Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
       	keys = (List<Key<Point>>)cache.get(q.toString());
		if(keys == null) {
			keys = q.listKeys();
			cache.put(q.toString(), keys);
		}
       } catch (CacheException e) {
       	keys = q.listKeys();
       	Logger.getLogger(location).log(Level.SEVERE, functionName + ": Cache error: " + e);
       	e.printStackTrace();
       }
       Map<Key<Point>, Point> points = ofy.get(keys);
	return points.values();
}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:21,代码来源:Dao.java

示例5: getSearchPointsForLine

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Collection<Point> getSearchPointsForLine(Key<Line> l, int middleIndex, int plusMinusIndex, Objectify ofy) {
       String functionName = "getSearchPointsForLine(int plusMinusIndex)";
       List<Key<Point>> keys;
       plusMinusIndex++; // query is exclusive, therefore we expand by one to return the expected number of results
       Query<Point> q = ofy.query(Point.class).ancestor(l).filter("ignore", false).filter("index <", middleIndex + plusMinusIndex).filter("index >", middleIndex - plusMinusIndex);
       try {
       	Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
       	keys = (List<Key<Point>>)cache.get(q.toString());
       	if(keys == null) {
			keys = q.listKeys();
			cache.put(q.toString(), keys);
		}
       } catch (CacheException e) {
       	keys = q.listKeys();
       	Logger.getLogger(location).log(Level.SEVERE, functionName + ": Cache error: " + e);
       	e.printStackTrace();
       }
       Map<Key<Point>, Point> points = ofy.get(keys);
       return points.values();
}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:22,代码来源:Dao.java

示例6: addAndCheckSearchForIp

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
public int addAndCheckSearchForIp(String ip, int mode) {
		String functionName = "addAndCheckSearchForIp()";
		Cache cache;
		Map<String, Integer> props = new HashMap<String, Integer>();
        props.put(GCacheFactory.EXPIRATION_DELTA, 600); // 10 minutes
        if(Utils.isUserInSpecialACL()) {
//        	System.err.println("No limit for user: " + Utils.getUser().getEmail() + "(" + Utils.getUser().getNickname() + ")");
        	Logger.getLogger(location).log(Level.INFO, functionName + ": No limit for user: " + Utils.getUser().getEmail() + "(" + Utils.getUser().getNickname() + ")");
        	return 1;
        }
        try {
        	String key = "requestCounter:" + mode + ":" + ip;
        	CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
            cache = cacheFactory.createCache(props);
            Integer counter = new Integer(1);
            Integer o = (Integer)cache.get(key);
            if(o != null) {
            	counter = counter + o;
            }
            cache.put(key, counter);
            return counter;
        } catch (CacheException e) {
        	Logger.getLogger(location).log(Level.SEVERE, functionName + ": caching error: " + e);
        	return -1;
        }
	}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:27,代码来源:Dao.java

示例7: getUserFavouritePositions

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Collection<UserFavouritePosition> getUserFavouritePositions(User user, Objectify ofy) {
	String functionName = "getUserFavouritePositions()";
	Query<UserFavouritePosition> q = ofy.query(UserFavouritePosition.class).filter("user", user);
	List<Key<UserFavouritePosition>> keys;
	try {
       	Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
       	keys = (List<Key<UserFavouritePosition>>)cache.get(q.toString());
       	if(keys == null) {
			keys = q.listKeys();
			cache.put(q.toString(), keys);
		}
       } catch (CacheException e) {
       	Logger.getLogger(location).log(Level.SEVERE, functionName + ": caching error: " + e);
       	keys = q.listKeys();
       }
       return ofy.get(keys).values();
}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:19,代码来源:Dao.java

示例8: doGet

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

		CacheFactory cacheFactory;
		try {
			cacheFactory = CacheManager.getInstance().getCacheFactory();
			Cache cache;
			cache = cacheFactory.createCache(Collections.emptyMap());
			
			cache.clear();
			
			DataService.getInstance().saveConfig();
		} catch (CacheException e) {
			log.log(Level.SEVERE, "Error instantiating Cache");
		}
		log.log(Level.WARNING, "Cleared the Cache");
	}
 
开发者ID:Rise-Vision,项目名称:rva,代码行数:17,代码来源:MemCacheClearServlet.java

示例9: resetTrainNodes

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
public String resetTrainNodes() throws IllegalArgumentException {
	try {
		Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
		cache.clear();
	} catch (CacheException e) {
		e.printStackTrace();
	}
	Dao.resetTrainNodes();
	Dao.getTrainNodes();
	Dao.getTrainNodeKeyMap();
	Dao.getSubteKeys();
	Dao.getTrainKeys();
	return "done";
}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:15,代码来源:LineListServiceImpl.java

示例10: getTrainNodes

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
	public static synchronized HashMap<String,Set<TrainNode>> getTrainNodes() {
		String functionName = "getTrainNodes()";
		if(trainNodes == null || trainNodes.size() == 0) {
			trainNodes = new HashMap<String,Set<TrainNode>>();
			Objectify ofy = ObjectifyService.begin();
			Query<TrainNode> q = ofy.query(TrainNode.class);
			List<Key<TrainNode>> keys;
			try {
	        	Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
	        	keys = (List<Key<TrainNode>>)cache.get(q.toString());
	        	if(keys == null) {
					keys = q.listKeys();
					cache.put(q.toString(), keys);
				}
	        } catch (CacheException e) {
	        	keys = q.listKeys();
	        	Logger.getLogger(location).log(Level.SEVERE, functionName + ": Cache error: " + e);
	        	e.printStackTrace();
	        }
	        Map<Key<TrainNode>, TrainNode> res = ofy.get(keys);
			Collection<TrainNode> tns = res.values();
			Logger.getLogger(location).log(Level.INFO, functionName + ": Got " + res.size() + " TrainNodes. keys.size(): " + keys.size());			
//			String m = "";
			for(TrainNode tn : tns) {
				if(!trainNodes.containsKey(tn.getGeoCell())) {
					trainNodes.put(tn.getGeoCell(), new HashSet<TrainNode>());
				}
				trainNodes.get(tn.getGeoCell()).add(tn);
/*				if(tn.getLineKey().equals(new Key<Line>(Line.class, 155))) {
//				if(tn.getLineType() == 11) {
					System.err.print("\"" + tn.getGeoCell() + "\", ");
				}*/
			}
//			Utils.eMailGeneric(m, "DaoTemp");
		}
		return trainNodes;
	}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:39,代码来源:Dao.java

示例11: removeFromCache

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
private void removeFromCache(Object key) {
	try {
		Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
       	cache.remove(key);
       } catch (CacheException e) {
       	Logger.getLogger(location).log(Level.SEVERE, "removeFromCache(): Cache error: " + e);
       	e.printStackTrace();
       }
}
 
开发者ID:Hellek1,项目名称:viaja-facil,代码行数:10,代码来源:Dao.java

示例12: GenericCache

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
protected GenericCache() {
	if (cache == null) {
		try {
			cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
		} catch (CacheException e) {
			logger.severe(e.getMessage());
		}
	}
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:10,代码来源:GenericCache.java

示例13: FusionCache

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
private FusionCache(){
	try {
           cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
       } catch (CacheException e) {
       	logger.severe(e.getMessage());
       }
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:8,代码来源:FusionCache.java

示例14: init

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void init() {
	log.log(Level.INFO, "REST servlet initialized");

       try {
           CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
           cache = cacheFactory.createCache(Collections.emptyMap());
       } catch (CacheException e) {
           log.severe("Unable to initialize MemCache!");
       }
       
	this.userService = UserServiceFactory.getUserService();
	this.persistence = new GaePersistence();
	
	this.gson = new Gson();		
	
	repositoryPath2backupClass=new HashMap<String, Class>();
	repositoryPath2backupClass.put("check-list-answers", BackupCheckListAnswerBean.class);
	repositoryPath2backupClass.put("grows", BackupGrowBean.class);
	repositoryPath2backupClass.put("grow-question-answers", BackupQuestionAnswerBean.class);
	repositoryPath2backupClass.put("grow-questions", BackupQuestionBean.class);
	repositoryPath2backupClass.put("users", BackupUserBean.class);
	repositoryPath2backupClass.put("whitelist-entries", BackupWhitelistEntryBean.class);
	repositoryPath2backupClass.put("life-visions", BackupLifeVisionBean.class);
	repositoryPath2backupClass.put("friends", BackupFriendBean.class);
	repositoryPath2backupClass.put("permissions", BackupPermissionBean.class);
	repositoryPath2backupClass.put("question-comments", BackupQuestionBean.class);
	repositoryPath2backupClass.put("user-settings", BackupUserSettingsBean.class);
	repositoryPath2backupClass.put("note-attachments", BackupAttachmentBean.class);
}
 
开发者ID:dvorka,项目名称:coaching-notebook,代码行数:32,代码来源:RestServlet.java

示例15: MindForgerMemcache

import net.sf.jsr107cache.CacheManager; //导入依赖的package包/类
public MindForgerMemcache() {
       try {
       	// cluster > memcache (use of application cache makes no sense: cross cluster node, size, ...)
           CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
           memcache = cacheFactory.createCache(Collections.emptyMap());
       } catch (CacheException e) {
           LOG.severe("Unable to initialize MemCache!");
       }
}
 
开发者ID:dvorka,项目名称:coaching-notebook,代码行数:10,代码来源:MindForgerMemcache.java


注:本文中的net.sf.jsr107cache.CacheManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。