本文整理匯總了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);
}