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


Java Cache.set方法代码示例

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


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

示例1: getAutoCompleteList

import play.cache.Cache; //导入方法依赖的package包/类
public static List<String> getAutoCompleteList()
{
	//Logger.debug("=== Entering SearchDAO.java:getAutoCompleteList()");
	List<String> cachedAutoCompleteList = (List<String>)Cache.get(SEARCH_AUTOCOMPLETE_LIST);
		//Logger.debug("=== Run first query in SearchDAO.java:getAutoCompleteList()");
	if (cachedAutoCompleteList == null || cachedAutoCompleteList.size() == 0)
	{
		//List<String> metricList = getJdbcTemplate().queryForList(GET_METRIC_AUTO_COMPLETE_LIST, String.class);
		//List<String> flowList = getJdbcTemplate().queryForList(GET_FLOW_AUTO_COMPLETE_LIST, String.class);
		//Logger.debug("=== Run second query in SearchDAO.java:getAutoCompleteList()");
		//List<String> jobList = getJdbcTemplate().queryForList(GET_JOB_AUTO_COMPLETE_LIST, String.class);
		//Logger.debug("=== Run third query in SearchDAO.java:getAutoCompleteList()");
		List<String> datasetList = getJdbcTemplate().queryForList(GET_DATASET_AUTO_COMPLETE_LIST, String.class);
		//Logger.debug("=== Run fourth query in SearchDAO.java:getAutoCompleteList()");
		//Logger.debug("=== Run all queries in SearchDAO.java:getAutoCompleteList()");
		cachedAutoCompleteList = datasetList;
		Collections.sort(cachedAutoCompleteList);
		Cache.set(SEARCH_AUTOCOMPLETE_LIST, cachedAutoCompleteList, 60*60);
	}
	Logger.trace("=== Exiting SearchDAO.java:getAutoCompleteList()");

	return cachedAutoCompleteList;
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:24,代码来源:SearchDAO.java

示例2: getAutoCompleteList

import play.cache.Cache; //导入方法依赖的package包/类
public static List<String> getAutoCompleteList()
{
	List<String> cachedAutoCompleteList = (List<String>)Cache.get(SEARCH_AUTOCOMPLETE_LIST);
	if (cachedAutoCompleteList == null || cachedAutoCompleteList.size() == 0)
	{
		//List<String> metricList = getJdbcTemplate().queryForList(GET_METRIC_AUTO_COMPLETE_LIST, String.class);
		List<String> flowList = getJdbcTemplate().queryForList(GET_FLOW_AUTO_COMPLETE_LIST, String.class);
		List<String> jobList = getJdbcTemplate().queryForList(GET_JOB_AUTO_COMPLETE_LIST, String.class);
		List<String> datasetList = getJdbcTemplate().queryForList(GET_DATASET_AUTO_COMPLETE_LIST, String.class);
		cachedAutoCompleteList =
				Stream.concat(datasetList.stream(),
						Stream.concat(flowList.stream(), jobList.stream())).collect(Collectors.toList());
		Collections.sort(cachedAutoCompleteList);
		Cache.set(SEARCH_AUTOCOMPLETE_LIST, cachedAutoCompleteList, 60*60);
	}


	return cachedAutoCompleteList;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:20,代码来源:SearchDAO.java

示例3: getSearchAutoComplete

import play.cache.Cache; //导入方法依赖的package包/类
public static Result getSearchAutoComplete() {
  // if not input, then get all search names (without limit).
  String input = request().getQueryString("input");
  int size = 0;  // size 0 means no limit
  if (isNotBlank(input)) {
    size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
  }

  String cacheKey = AUTOCOMPLETE_ALL_KEY + (isNotBlank(input) ? "." + input : "-all");
  List<String> names = (List<String>) Cache.get(cacheKey);
  if (names == null || names.size() == 0) {
    names = SearchDAO.getAutoCompleteList(input, size);
    Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
  }

  ObjectNode result = Json.newObject();
  result.put("status", "ok");
  result.put("input", input);
  result.set("source", Json.toJson(names));
  return ok(result);
}
 
开发者ID:linkedin,项目名称:WhereHows,代码行数:22,代码来源:Search.java

示例4: getSearchAutoCompleteForDataset

import play.cache.Cache; //导入方法依赖的package包/类
public static Result getSearchAutoCompleteForDataset() {
  // if not input, then get all search names (without limit).
  String input = request().getQueryString("input");
  int size = 0;  // size 0 means no limit
  if (isNotBlank(input)) {
    size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
  }

  String cacheKey = AUTOCOMPLETE_DATASET_KEY + (isNotBlank(input) ? "." + input : "-all");
  List<String> names = (List<String>) Cache.get(cacheKey);
  if (names == null || names.size() == 0) {
    names = SearchDAO.getAutoCompleteListDataset(input, size);
    Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
  }

  ObjectNode result = Json.newObject();
  result.put("status", "ok");
  result.put("input", input);
  result.set("source", Json.toJson(names));
  return ok(result);
}
 
开发者ID:linkedin,项目名称:WhereHows,代码行数:22,代码来源:Search.java

示例5: getSearchAutoCompleteForMetric

import play.cache.Cache; //导入方法依赖的package包/类
public static Result getSearchAutoCompleteForMetric() {
  // if not input, then get all search names (without limit).
  String input = request().getQueryString("input");
  int size = 0;  // size 0 means no limit
  if (isNotBlank(input)) {
    size = NumberUtils.toInt(request().getQueryString("size"), DEFAULT_AUTOCOMPLETE_SIZE);
  }

  String cacheKey = AUTOCOMPLETE_METRIC_KEY + (isNotBlank(input) ? "." + input : "-all");
  List<String> names = (List<String>) Cache.get(cacheKey);
  if (names == null || names.size() == 0) {
    names = SearchDAO.getAutoCompleteListMetric(input, size);
    Cache.set(cacheKey, names, DEFAULT_AUTOCOMPLETE_CACHE_TIME);
  }

  ObjectNode result = Json.newObject();
  result.put("status", "ok");
  result.put("input", input);
  result.set("source", Json.toJson(names));
  return ok(result);
}
 
开发者ID:linkedin,项目名称:WhereHows,代码行数:22,代码来源:Search.java

示例6: getLocationByCoordinates

import play.cache.Cache; //导入方法依赖的package包/类
/**
 * Retrieve location by coordinates
 * Example URL http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=false&language=en
 * @param sLon
 * @param sLat
 * @return
 * @throws UnsupportedEncodingException
 */
public static Promise<Location> getLocationByCoordinates(String sLon, String sLat) throws UnsupportedEncodingException{
   	@SuppressWarnings("unchecked")
	Promise<Location> loc = (Promise<Location>) Cache.get(CACHE_GEO+sLat+sLon);
	if(loc == null)
		loc = getLocationByURL("http://maps.googleapis.com/maps/api/geocode/xml?latlng="+sLon+","+sLat+"&sensor=false&language=en");

	Cache.set(CACHE_GEO+sLat+sLon, loc);
	return loc;
}
 
开发者ID:Localizr,项目名称:Localizr,代码行数:18,代码来源:GoogleAPI.java

示例7: local

import play.cache.Cache; //导入方法依赖的package包/类
/**
 * Get a local asset by url.
 * 
 * @param url
 *            the relative url of the asset
 */
public static String local(String url) {

    String cacheKey = CACHE_PREFIX + url;

    String fileChecksum = (String) Cache.get(cacheKey);

    if (fileChecksum == null) {

        try {
            fileChecksum = getFileChecksumByUrl(Play.application().configuration().getString("maf.private.url") + url);
        } catch (Exception e) {
            Logger.error("AssetsVersion/local: error when getting the checksum for the url " + url, e);
            fileChecksum = UUID.randomUUID().toString();
        }
        Cache.set(cacheKey, fileChecksum);
    }

    return url + "?" + fileChecksum;
}
 
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:26,代码来源:AssetsProvider.java

示例8: getNumberOfUnreadMessages

import play.cache.Cache; //导入方法依赖的package包/类
/**
 * Get number of unread messages for the current user
 * @return
 */
public int getNumberOfUnreadMessages() {
    // TODO: use injected context for this
    int userId = CurrentUser.getId();
    String key = String.format(MESSAGE_NUMBER_BY_ID, userId);
    Object obj = Cache.get(key);
    if (obj == null || !(obj instanceof List)) {
        try (DataAccessContext context = provider.getDataAccessContext()) {
            int unread_number = context.getMessageDAO().countUnreadMessagesTo(userId);
            Cache.set(key, unread_number);
            return unread_number;
        }
    } else {
        return (Integer) obj; //Type erasure problem from Java, works at runtime
    }
}
 
开发者ID:degage,项目名称:degapp,代码行数:20,代码来源:CommunicationProvider.java

示例9: getMainCache

import play.cache.Cache; //导入方法依赖的package包/类
/**
    * This is the main cache object. It contains a single entry for every
    * scope. The values of these entries are another map, containing key/value
    * entries for that scope
    */
   private static Map<Scope, Map<UUID, Map<Object, CacheValue>>> getMainCache()
   {
Map<Scope, Map<UUID, Map<Object, CacheValue>>> retVal = (Map<Scope, Map<UUID, Map<Object, CacheValue>>>) Cache.get(SERVER_CACHE_MAP_KEY);

// bootstrap an empty cache if it's not present (eg. after a server
// reboot)
if (retVal == null) {
    retVal = new HashMap<Scope, Map<UUID, Map<Object, CacheValue>>>();
    retVal.put(Scope.REQUEST, new HashMap<UUID, Map<Object, CacheValue>>());
    retVal.put(Scope.SESSION, new HashMap<UUID, Map<Object, CacheValue>>());
    retVal.put(Scope.APPLICATION, new HashMap<UUID, Map<Object, CacheValue>>());

    // store our new cache in the Cache API
    Cache.set(SERVER_CACHE_MAP_KEY, retVal);
}

// let's use this opportunity to purge the cache
Cacher.checkPurgeCache(retVal);

return retVal;
   }
 
开发者ID:beligum,项目名称:com.beligum.core.play,代码行数:27,代码来源:Cacher.java

示例10: wsCall

import play.cache.Cache; //导入方法依赖的package包/类
public static WebSocket<String> wsCall() {
    return new WebSocket<String>() {
        @SuppressWarnings("unchecked")
        public void onReady(final WebSocket.In<String> in,
                            final WebSocket.Out<String> out) {

            if (Cache.get("channels") == null) {
                List<Out> outs = new ArrayList<Out>();
                outs.add(out);
                Cache.set("channels", outs);
            } else ((List<Out>) Cache.get("channels")).add(out);
            System.out.println("<" + Cache.get("channels"));
            in.onClose(new F.Callback0() {
                @Override
                public void invoke() throws Throwable {
                    ((List<Out>) Cache.get("channels")).remove(out);
                    out.close();
                }
            });
        }
    };
}
 
开发者ID:dhinojosa,项目名称:play-workshop,代码行数:23,代码来源:FitnessController.java

示例11: testVerify_new_user_agreed

import play.cache.Cache; //导入方法依赖的package包/类
@Test
public void testVerify_new_user_agreed() {
    //Prepare data
    mockVerify();
    user.charterAgree = true;
    Cache.set( UUID + "connectedUser", user );

    //fake the session
    fakeSession();
    Http.Context.current().session().put("email", user.email);

    // call the action
    Result result = AuthenticationController.verify( userInfo );

    // Tests
    assertThat(status(result)).isEqualTo(SEE_OTHER);
    User userSaved = User.find.where().eq("email", user.email).findUnique();
    assertThat( userSaved ).isNotNull();
}
 
开发者ID:sqlilabs,项目名称:WorkshopManager,代码行数:20,代码来源:AuthenticationControllerTest.java

示例12: getSessionPrivileges

import play.cache.Cache; //导入方法依赖的package包/类
public static HashSet<String> getSessionPrivileges() throws DisconnectedUser {
	String username = connected();
	if (username == null) {
		throw new DisconnectedUser("(No set)");
	}
	
	@SuppressWarnings("unchecked")
	HashSet<String> privileges = Cache.get("user:" + username + ":privileges", HashSet.class);
	
	if (privileges != null) {
		Cache.set("user:" + username + ":privileges", privileges, MyDMAM.getPlayBootstrapper().getSessionTTL());
		return privileges;
	}
	
	Session.current().clear();
	
	throw new DisconnectedUser(username);
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:19,代码来源:Secure.java

示例13: getAutoCompleteListForDataset

import play.cache.Cache; //导入方法依赖的package包/类
public static List<String> getAutoCompleteListForDataset()
{
	//Logger.debug("Entering SearchDAO.java:getAutoCompleteListForDataset()");
	List<String> cachedAutoCompleteListForDataset = (List<String>)Cache.get(SEARCH_AUTOCOMPLETE_LIST_DATASET);
	if (cachedAutoCompleteListForDataset == null || cachedAutoCompleteListForDataset.size() == 0)
	{
		List<String> datasetList = getJdbcTemplate().queryForList(GET_DATASET_AUTO_COMPLETE_LIST, String.class);
		cachedAutoCompleteListForDataset = datasetList.stream().collect(Collectors.toList());
		Collections.sort(cachedAutoCompleteListForDataset);
		Cache.set(SEARCH_AUTOCOMPLETE_LIST_DATASET, cachedAutoCompleteListForDataset, 60*60);
	}

	return cachedAutoCompleteListForDataset;
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:15,代码来源:SearchDAO.java

示例14: getSubordinatesAsId

import play.cache.Cache; //导入方法依赖的package包/类
/**
 * Get the list of subordinates id of an actor.
 * 
 * note: this method uses cache
 * 
 * @param actorId
 *            the actor id
 */
public static Set<Long> getSubordinatesAsId(Long actorId) {

    String cacheKey = ACTOR_HIERARCHY_CACHE_PREFIX + "subordinates.asid." + actorId;
    @SuppressWarnings("unchecked")
    Set<Long> subordinatesId = (Set<Long>) Cache.get(cacheKey);
    if (subordinatesId != null) {
        Logger.debug("actor hierarchy: '" + cacheKey + "' read from cache");
        return subordinatesId;
    }

    subordinatesId = new HashSet<>();
    for (ActorHierarchy actorHierarchy : getSubordinatesAsActorHierarchy(actorId)) {
        subordinatesId.add(actorHierarchy.level2);
        subordinatesId.add(actorHierarchy.level3);
        subordinatesId.add(actorHierarchy.level4);
        subordinatesId.add(actorHierarchy.level5);
        subordinatesId.add(actorHierarchy.level6);
        subordinatesId.add(actorHierarchy.level7);
    }

    subordinatesId.remove(null);

    // set the result in the cache
    Cache.set(cacheKey, subordinatesId, CACHE_TTL);

    return subordinatesId;
}
 
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:36,代码来源:ActorHierarchy.java

示例15: getSubordinatesAsString

import play.cache.Cache; //导入方法依赖的package包/类
/**
 * Get the list of subordinates of an actor as a string.
 * 
 * @param actorId
 *            the actor id
 * @param separator
 *            the separator (data aggregate)
 */
public static String getSubordinatesAsString(Long actorId, String separator) {

    String cacheKey = ACTOR_HIERARCHY_CACHE_PREFIX + "subordinates.asstring." + actorId + "." + separator;
    String subordinatesString = (String) Cache.get(cacheKey);
    if (subordinatesString != null) {
        Logger.debug("actor hierarchy: '" + cacheKey + "' read from cache");
        return subordinatesString;
    }

    Set<Long> subordinatesId = getSubordinatesAsId(actorId);

    StringBuilder builder = new StringBuilder();

    boolean firstLoop = true;

    for (Long id : subordinatesId) {
        if (!firstLoop) {
            builder.append(separator);
        }
        builder.append(id.toString());
        firstLoop = false;
    }

    subordinatesString = builder.toString();

    // set the result in the cache
    Cache.set(cacheKey, subordinatesString, CACHE_TTL);

    return subordinatesString;

}
 
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:40,代码来源:ActorHierarchy.java


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