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


Java Cache.get方法代码示例

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


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

示例1: getSubteKeys

import net.sf.jsr107cache.Cache; //导入方法依赖的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

示例2: getTrainKeys

import net.sf.jsr107cache.Cache; //导入方法依赖的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

示例3: getPointsToDisplayForLine

import net.sf.jsr107cache.Cache; //导入方法依赖的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

示例4: getSearchPointsForLine

import net.sf.jsr107cache.Cache; //导入方法依赖的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

示例5: addAndCheckSearchForIp

import net.sf.jsr107cache.Cache; //导入方法依赖的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

示例6: getUserFavouritePositions

import net.sf.jsr107cache.Cache; //导入方法依赖的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

示例7: getTrainNodes

import net.sf.jsr107cache.Cache; //导入方法依赖的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


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