本文整理匯總了Java中redis.clients.jedis.Transaction.hincrBy方法的典型用法代碼示例。如果您正苦於以下問題:Java Transaction.hincrBy方法的具體用法?Java Transaction.hincrBy怎麽用?Java Transaction.hincrBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.Transaction
的用法示例。
在下文中一共展示了Transaction.hincrBy方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setJedisMultiCommand
import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Override
public Map<String, Response<Long>> setJedisMultiCommand(Transaction jedisMulti) {
Response<Long> applicationDailyRateLimit =
jedisMulti.hincrBy(Const.REDIS_APP_RATELIMIT_DAILY, this.requestInfo.getAppId(), -1);
Response<Long> applicationMinutelyRateLimit =
jedisMulti.hincrBy(Const.REDIS_APP_RATELIMIT_MINUTELY, this.requestInfo.getAppId(), -1);
Response<Long> applicationDailyRateLimitTTL = jedisMulti.ttl(Const.REDIS_APP_RATELIMIT_DAILY);
Response<Long> applicationMinutelyRateLimitTTL = jedisMulti.ttl(Const.REDIS_APP_RATELIMIT_MINUTELY);
Map<String, Response<Long>> appRatelimit = Maps.newHashMap();
appRatelimit.put(Const.REDIS_APP_RATELIMIT_DAILY, applicationDailyRateLimit);
appRatelimit.put(Const.REDIS_APP_RATELIMIT_MINUTELY, applicationMinutelyRateLimit);
appRatelimit.put(Const.REDIS_APP_RATELIMIT_DAILY_TTL, applicationDailyRateLimitTTL);
appRatelimit.put(Const.REDIS_APP_RATELIMIT_MINUTELY_TTL, applicationMinutelyRateLimitTTL);
return appRatelimit;
}
示例2: setJedisMultiCommand
import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Override
public Map<String, Response<Long>> setJedisMultiCommand(Transaction jedisMulti) {
Response<Long> serviceDailyRatelimit = jedisMulti.hincrBy(Const.REDIS_SERVICE_CAPACITY_DAILY, this.requestInfo.getServiceId(), -1);
Response<Long> serviceDailyTTL = jedisMulti.ttl(Const.REDIS_SERVICE_CAPACITY_DAILY);
Map<String, Response<Long>> serviceRatelimit = Maps.newHashMap();
serviceRatelimit.put(Const.REDIS_SERVICE_CAPACITY_DAILY, serviceDailyRatelimit);
serviceRatelimit.put(Const.REDIS_SERVICE_CAPACITY_DAILY_TTL, serviceDailyTTL);
return serviceRatelimit;
}
示例3: hincrby
import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test public void hincrby() {
// GIVEN
Transaction tr = this.jedis.multi();
// WHEN
Response<Long> result1 = tr.hincrBy(KEY, FIELD, 3);
Response<Long> result2 = tr.hincrBy(KEY, FIELD, 4);
List<Object> results = tr.exec();
// THEN
String value = this.jedis.hget(KEY, FIELD);
assertEquals("7", value);
assertEquals(2, results.size());
assertEquals(3, (long) results.get(0));
assertEquals(7, (long) results.get(1));
assertEquals(3, (long) result1.get());
assertEquals(7, (long) result2.get());
}
示例4: responseget_before_exec
import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test public void responseget_before_exec() {
// GIVEN
Transaction tr = this.jedis.multi();
// THEN
this.expectedException.expect(JedisDataException.class);
this.expectedException.expectMessage("Please close pipeline or multi block before calling this method.");
// WHEN
Response<Long> response = tr.hincrBy(KEY, FIELD, 3);
response.get();
}