當前位置: 首頁>>代碼示例>>Java>>正文


Java Transaction.hincrBy方法代碼示例

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

}
 
開發者ID:longcoding,項目名稱:undefined-gateway,代碼行數:20,代碼來源:ApplicationRatelimitInterceptor.java

示例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;
}
 
開發者ID:longcoding,項目名稱:undefined-gateway,代碼行數:12,代碼來源:ServiceCapacityInterceptor.java

示例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());
}
 
開發者ID:vdurmont,項目名稱:fake-jedis,代碼行數:21,代碼來源:FakeTransactionTest.java

示例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();
}
 
開發者ID:vdurmont,項目名稱:fake-jedis,代碼行數:13,代碼來源:FakeTransactionTest.java


注:本文中的redis.clients.jedis.Transaction.hincrBy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。