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


Java Results.discard方法代码示例

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


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

示例1: getByDeviceClassId

import net.sf.ehcache.search.Results; //导入方法依赖的package包/类
@Override
public List<Device> getByDeviceClassId(Long deviceClassId) {
  List<Device> deviceCacheObjects = new ArrayList<>();

  Results results = null;

  try {
    Query query = getCache().createQuery();
    Attribute<Long> id = getCache().getSearchAttribute("deviceClassId");
    results = query.includeKeys().includeValues().addCriteria(id.eq(deviceClassId)).execute();

    if (results.size() == 0) {
      throw new CacheElementNotFoundException("Failed to get device ids from cache");
    }

    results.all().forEach((result) -> deviceCacheObjects.add((DeviceCacheObject) result.getValue()));
  } finally {
    if (results != null) {
      results.discard();
    }
  }

  return deviceCacheObjects;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:25,代码来源:DeviceCacheImpl.java

示例2: searchPartitionKeys

import net.sf.ehcache.search.Results; //导入方法依赖的package包/类
private List searchPartitionKeys(final Query query) {
	LinkedList<Object> keys = new LinkedList<Object>();
	System.out.println("Starting search...");
	long startTime = System.currentTimeMillis();
	Results results = query.execute();
	if(log.isDebugEnabled())
		log.debug(String.format("Search time: %d ms", System.currentTimeMillis() - startTime));

	// perform the refresh
	for (Result result : results.all()) {
		keys.add(result.getKey());
	}

	results.discard();

	return keys;
}
 
开发者ID:lanimall,项目名称:ehcache-extensions,代码行数:18,代码来源:CacheFailoverDecorator.java

示例3: getDeviceClassIdByName

import net.sf.ehcache.search.Results; //导入方法依赖的package包/类
@Override
public Long getDeviceClassIdByName(String deviceClassName) {
  Long deviceClassId;

  if (deviceClassName == null || deviceClassName.equalsIgnoreCase("")) {
    throw new IllegalArgumentException("Attempting to retrieve a DeviceClass from the cache with a NULL or empty name parameter.");
  }

  Results results = null;
  try {
    Attribute<String> className = getCache().getSearchAttribute("deviceClassName");
    Query query = getCache().createQuery();
    results = query.includeKeys().addCriteria(className.eq(deviceClassName)).maxResults(1).execute();

    if (results.size() == 0) {
      throw new CacheElementNotFoundException("Failed to find a device class with name " + deviceClassName + " in the cache.");
    }

    deviceClassId = (long) results.all().get(0).getKey();
  } finally {
    if (results != null) {
      results.discard();
    }
  }

  return deviceClassId;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:28,代码来源:DeviceClassCacheImpl.java

示例4: hasTagWithName

import net.sf.ehcache.search.Results; //导入方法依赖的package包/类
@Override
public boolean hasTagWithName(String name) {
  if (name == null || name.equalsIgnoreCase("")) {
    throw new IllegalArgumentException("Attempting to retrieve a Tag from the cache with a NULL or empty name parameter.");
  }

  // This will prevent wildcard searches
  if (name.contains("*")) {
    name = name.replace("*", "\\*");
  }
  if (name.contains("?")) {
    name = name.replace("?", "\\?");
  }

  Results results = null;

  try {
    Ehcache ehcache = getCache();
    Attribute<String> tagName = ehcache.getSearchAttribute("tagName");

    Query query = ehcache.createQuery();
    results = query.includeKeys().addCriteria(tagName.ilike(name)).maxResults(1).execute();

    return results.hasKeys();
  }
  finally {
    if (results != null) {
      // Discard the results when done to free up cache resources.
      results.discard();
    }
  }

}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:34,代码来源:AbstractTagCache.java

示例5: getDataTagIds

import net.sf.ehcache.search.Results; //导入方法依赖的package包/类
/**
 * Receives a list of all DataTag ids which are attached to the given equipment or sub-equipment.
 * @param id The id of the (sub-)equipment
 * @param searchAttribute The ehcache search attribute, which is specified in the wrapper method
 * @return A list of all DataTag ids belonging to the given (sub-)equipment
 */
private List<Long> getDataTagIds(Long id, String searchAttribute) {
  List<Long> tagIds = new LinkedList<>();
  Results results = null;

  if (id == null) {
    throw new IllegalArgumentException("Attempting to retrieve a List of DataTag ids from the cache with a NULL " +
        "parameter.");
  }

  try {
    Attribute<Long> cacheEquipmentId = getCache().getSearchAttribute(searchAttribute);
    results = getCache().createQuery().includeKeys().addCriteria(cacheEquipmentId.eq(id)).execute();

    if (results == null) {
      throw new CacheElementNotFoundException("Failed to execute query with (sub)EquipmentId " + id + " : " +
          "Result is null.");
    }

    results.all().forEach(r -> tagIds.add((Long) r.getKey()));

  } finally {
    if (results != null) {
      // Discard the results when done to free up cache resources.
      results.discard();
    }
  }
  return tagIds;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:35,代码来源:DataTagCacheImpl.java

示例6: getProcessId

import net.sf.ehcache.search.Results; //导入方法依赖的package包/类
@Override
public Long getProcessId(final String name) {
  Long processKey = null;
  Results results = null;

  if (name == null || name.equalsIgnoreCase("")) {
    throw new IllegalArgumentException("Attempting to retrieve a Process from the cache with a NULL or empty name parameter.");
  }

  try {
    Attribute<String> processName = getCache().getSearchAttribute("processName");
    // By limiting the query result list to 1 it is up to the administrator to
    // make
    // sure that the process name is unique. Otherwise this will result in an
    // unpredictable behaviour.
    Query query = getCache().createQuery();
    results = query.includeKeys().addCriteria(processName.eq(name)).maxResults(1).execute();

    // Find the number of results -- the number of hits.
    int size = results.size();
    if (size == 0) {
      throw new CacheElementNotFoundException("Failed to find a process with name " + name + " in the cache.");
    }

    processKey = (Long) results.all().get(0).getKey();
  }
  finally {
    if (results != null) {
      // Discard the results when done to free up cache resources.
      results.discard();
    }
  }

  return processKey;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:36,代码来源:ProcessCacheImpl.java

示例7: getCommandTagId

import net.sf.ehcache.search.Results; //导入方法依赖的package包/类
@Override
public Long getCommandTagId(final String name) {
  Long commandTagKey = null;
  Results results = null;

  if (name == null || name.equalsIgnoreCase("")) {
    throw new IllegalArgumentException("Attempting to retrieve a CommandTag from the cache with a NULL or empty name parameter.");
  }

  try {
    Attribute<String> commandTagName = getCache().getSearchAttribute("commandTagName");
    Query query = getCache().createQuery();
    results = query.includeKeys().addCriteria(commandTagName.eq(name)).maxResults(1).execute();

    // Find the number of results -- the number of hits.
    int size = results.size();
    if (size == 0) {
      log.info("Failed to find a command tag with name " + name + " in the cache.");
    }

    commandTagKey = results.all().size() > 0 ? (Long) results.all().get(0).getKey() : null;
  }
  finally {
    if (results != null) {
      // Discard the results when done to free up cache resources.
      results.discard();
    }
  }

  return commandTagKey;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:32,代码来源:CommandTagCacheImpl.java

示例8: performSearch

import net.sf.ehcache.search.Results; //导入方法依赖的package包/类
private int performSearch(Criteria... criteria) {
    Query query = createQuery(criteria);
    long start = System.currentTimeMillis();
    Results results = query.execute();
    int count = results.size();
    long duration = System.currentTimeMillis() - start;
    log.info("Searchresult: found {} persons in {} ms.", count, duration);
    results.discard();
    return count;
}
 
开发者ID:dasniko,项目名称:ehcache-search-example,代码行数:11,代码来源:CacheTest.java


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