本文整理汇总了Java中org.apache.ignite.Ignite.cache方法的典型用法代码示例。如果您正苦于以下问题:Java Ignite.cache方法的具体用法?Java Ignite.cache怎么用?Java Ignite.cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.Ignite
的用法示例。
在下文中一共展示了Ignite.cache方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGenesForChromosome
import org.apache.ignite.Ignite; //导入方法依赖的package包/类
/**
*
* @param ignite
* @param chromosome
* @return List<Gene>
*/
public static List<Gene> getGenesForChromosome(Ignite ignite, Chromosome chromosome) {
List<Gene> genes = new ArrayList();
IgniteCache<Long, Gene> cache = ignite.cache(GAGridConstants.GENE_CACHE);
StringBuffer sbSqlClause = new StringBuffer();
sbSqlClause.append("_key IN ");
String sqlInClause = Arrays.toString(chromosome.getGenes());
sqlInClause = sqlInClause.replace("[", "(");
sqlInClause = sqlInClause.replace("]", ")");
sbSqlClause.append(sqlInClause);
SqlQuery sql = new SqlQuery(Gene.class, sbSqlClause.toString());
try (QueryCursor<Entry<Long, Gene>> cursor = cache.query(sql)) {
for (Entry<Long, Gene> e : cursor)
genes.add(e.getValue());
}
return genes;
}
示例2: getReference
import org.apache.ignite.Ignite; //导入方法依赖的package包/类
public static <V> Reference<V> getReference(Ignite ignite, final String name, boolean create) {
final IgniteCache<Object, Object> cache = create ? ignite.getOrCreateCache(NAME) : ignite.cache(NAME);
return new Reference<V>() {
@Override
public V get() {
return cache == null ? null : (V) cache.get(name);
}
@Override
public void set(V value) {
if (value == null) {
cache.remove(name);
} else {
cache.put(name, value);
}
}
};
}
示例3: IgniteOperationRepository
import org.apache.ignite.Ignite; //导入方法依赖的package包/类
@Autowired
public IgniteOperationRepository(@Qualifier("operationIgniteClient") Ignite ignite, KafkaTemplate kafkaTemplate) {
this.ignite = ignite;
operationCache = ignite.cache("operationCache");
this.kafkaTemplate = kafkaTemplate;
}
示例4: getGenesInOrderForChromosome
import org.apache.ignite.Ignite; //导入方法依赖的package包/类
/**
*
* Retrieve genes in order
*
* @param ignite
* @param chromosome
* @return List<Gene>
*/
public static List<Gene> getGenesInOrderForChromosome(Ignite ignite, Chromosome chromosome) {
List<Gene> genes = new ArrayList();
IgniteCache<Long, Gene> cache = ignite.cache(GAGridConstants.GENE_CACHE);
long[] primaryKeys = chromosome.getGenes();
for (int k =0; k< primaryKeys.length; k++)
{
StringBuffer sbSqlClause = new StringBuffer();
sbSqlClause.append("_key IN ");
sbSqlClause.append("(");
sbSqlClause.append(primaryKeys[k]);
sbSqlClause.append(")");
SqlQuery sql = new SqlQuery(Gene.class, sbSqlClause.toString());
try (QueryCursor<Entry<Long, Gene>> cursor = cache.query(sql)) {
for (Entry<Long, Gene> e : cursor)
genes.add(e.getValue());
}
}
return genes;
}
示例5: readValuesFromCache
import org.apache.ignite.Ignite; //导入方法依赖的package包/类
Map<Integer, Integer> readValuesFromCache(Ignite ignite) {
IgniteCache<Integer, Integer> cache = ignite.cache(CACHE_NAME);
Set<Integer> keys = new HashSet<>();
for (int i = startIndex; i < endIndex; i++) {
keys.add(i);
}
return cache.getAll(keys);
}
示例6: writeValuesToCache
import org.apache.ignite.Ignite; //导入方法依赖的package包/类
void writeValuesToCache(Ignite ignite, boolean withReplication, int startIdx, int endIdx, int modifier) {
try (Transaction tx = ignite.transactions().txStart()) {
IgniteCache<Integer, Integer> cache = ignite.cache(CACHE_NAME);
if (!withReplication) {
cache = cache.withSkipStore();
}
for (int i = startIdx; i < endIdx; i++) {
cache.put(i, i + modifier);
}
tx.commit();
}
}
示例7: getAtomic
import org.apache.ignite.Ignite; //导入方法依赖的package包/类
public static <V> Atomic<V> getAtomic(Ignite ignite, String name) {
return new CacheAtomic<>(ignite.cache(NAME), name);
}
示例8: getReference
import org.apache.ignite.Ignite; //导入方法依赖的package包/类
public static <V> Reference<V> getReference(Ignite ignite, final String name, boolean create) {
final IgniteCache<Object, Object> cache = create ? ignite.getOrCreateCache(NAME) : ignite.cache(NAME);
return new CacheReference<>(cache, name);
}