本文整理汇总了Java中redis.clients.jedis.Pipeline.zadd方法的典型用法代码示例。如果您正苦于以下问题:Java Pipeline.zadd方法的具体用法?Java Pipeline.zadd怎么用?Java Pipeline.zadd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.Pipeline
的用法示例。
在下文中一共展示了Pipeline.zadd方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scheduleMulti
import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
/**
* Add multiple jobs to the TimeBasedJobScheduler, using a pipeline command to avoid O(n) network round trips.
* Note that this implementation does not support quiescence.
* @see #schedule(String, String, long, long)
*
* @param tube Used in conjunction with the redisPrefixKey (constructor) to make up the full redis key name.
* @param jobStrs String representations of the jobs to be scheduled
* @param millisInFuture The "priority" of the job in terms of the number of millis in the future that this job should become available.
* @return number of newly scheduled jobs
*/
public int scheduleMulti(final String tube, final Iterable<String> jobStrs, final long millisInFuture) {
try (Handle handle = rdbi.open()) {
final Pipeline pl = handle.jedis().pipelined();
for (String jobStr : jobStrs) {
pl.zadd(getReadyQueue(tube),
Instant.now().getMillis() + millisInFuture,
jobStr);
}
int numAdded = 0;
for (Object rslt : pl.syncAndReturnAll()) {
numAdded += (Long) rslt;
}
return numAdded;
}
}
示例2: indexNumeric
import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
void indexNumeric(String fieldName, String docId, Number value, Pipeline pipe) {
Jedis conn = null;
if (pipe == null) {
conn = pool.getResource();
pipe = conn.pipelined();
}
pipe.zadd(fieldKey(fieldName), value.doubleValue(), docId);
// only if the connection was not provided to us - commit everything
if (conn != null) {
pipe.sync();
conn.close();
}
}
示例3: indexFulltextFields
import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
void indexFulltextFields(Spec.FulltextField spec, Document doc, Pipeline pipe) {
Jedis conn = null;
if (pipe == null) {
conn = pool.getResource();
pipe = conn.pipelined();
}
TokenSet mergedTokens = new TokenSet();
for (Map.Entry<String, Double> entry : spec.fields.entrySet()) {
if (doc.hasProperty(entry.getKey())) {
Object p = doc.property(entry.getKey());
if (p != null && p instanceof String) {
List<Token> tokens = tokenizer.tokenize((String)p);
mergedTokens.addAll(tokens, entry.getValue());
}
}
}
mergedTokens.normalize(mergedTokens.getMaxFreq());
for (Token tok : mergedTokens.values()) {
pipe.zadd(tokenKey(tok.text), doc.getScore() * (0.5 + 0.5*tok.frequency), doc.getId());
}
// only if the connection was not provided to us - commit everything
if (conn != null) {
pipe.sync();
conn.close();
}
}
示例4: internalPipelinedAdd
import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
private void internalPipelinedAdd(final ValueType value, final Pipeline pl, final double score) {
final String valueAsString = serializationHelper.encode(value);
pl.zadd(redisSetKey, score, valueAsString);
}
示例5: indexGeoPoint
import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
void indexGeoPoint(String docId, Double lat, Double lon, int precision, Pipeline pipe) {
GeoHash coarse = GeoHash.withCharacterPrecision(lat, lon, precision);
GeoHash fine = GeoHash.withBitPrecision(lat, lon, 53);
pipe.zadd(geoKey(coarse.toBase32()), fine.longValue(), docId);
}