当前位置: 首页>>代码示例>>Java>>正文


Java Response类代码示例

本文整理汇总了Java中redis.clients.jedis.Response的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Response类属于redis.clients.jedis包,在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setJedisMultiCommand

import redis.clients.jedis.Response; //导入依赖的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.Response; //导入依赖的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: transactionResponseWithError

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void transactionResponseWithError() {
  Transaction t = jedis.multi();
  t.set("foo", "bar");
  Response<Set<String>> error = t.smembers("foo");
  Response<String> r = t.get("foo");
  List<Object> l = t.exec();
  assertEquals(JedisDataException.class, l.get(1).getClass());
  try {
    error.get();
    fail("We expect exception here!");
  } catch (JedisDataException e) {
    // that is fine we should be here
  }
  assertEquals(r.get(), "bar");
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:17,代码来源:TransactionCommandsTest.java

示例4: execGetResponse

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void execGetResponse() {
  Transaction t = jedis.multi();

  t.set("foo", "bar");
  t.smembers("foo");
  t.get("foo");

  List<Response<?>> lr = t.execGetResponse();
  try {
    lr.get(1).get();
    fail("We expect exception here!");
  } catch (JedisDataException e) {
    // that is fine we should be here
  }
  assertEquals("bar", lr.get(2).get());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:18,代码来源:TransactionCommandsTest.java

示例5: testExec

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void testExec() throws Exception {
  int rnd = ThreadLocalRandom.current().nextInt(0, presetElements.size());
  String key = presetElementKeys.get(rnd);
  String value = String.valueOf(presetElements.get(key));

  Transaction transaction = jedis.multi();

  Snapshot snapshot = commandTracker.snapshot();
  Snapshot discardSnapshot = discardTracker.snapshot();
  Snapshot txsnapshot = execTracker.snapshot();
  txsnapshot.increment();
  Response<Long> added = transaction.sadd(key, value);
  transaction.exec();
  assertEquals(1, (long) added.get());
  txsnapshot.validate();
  snapshot.validate();
  discardSnapshot.validate();
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:20,代码来源:JedisTransactionInstrumentationTest.java

示例6: testDiscard

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void testDiscard() throws Exception {
  int rnd = ThreadLocalRandom.current().nextInt(0, presetElements.size());
  String key = presetElementKeys.get(rnd);
  String value = String.valueOf(presetElements.get(key));

  Transaction transaction = jedis.multi();

  Snapshot snapshot = commandTracker.snapshot();
  Snapshot discardSnapshot = discardTracker.snapshot();
  Snapshot txsnapshot = execTracker.snapshot();
  discardSnapshot.increment();
  Response<Long> added = transaction.sadd(key, value);
  transaction.discard();
  assertNull(jedis.get(key));
  txsnapshot.validate();
  snapshot.validate();
  discardSnapshot.validate();
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:20,代码来源:JedisTransactionInstrumentationTest.java

示例7: testCloseDiscards

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void testCloseDiscards() throws Exception {
  int rnd = ThreadLocalRandom.current().nextInt(0, presetElements.size());
  String key = presetElementKeys.get(rnd);
  String value = String.valueOf(presetElements.get(key));

  Transaction transaction = jedis.multi();

  Snapshot snapshot = commandTracker.snapshot();
  Snapshot discardSnapshot = discardTracker.snapshot();
  Snapshot txsnapshot = execTracker.snapshot();
  discardSnapshot.increment();
  Response<Long> added = transaction.sadd(key, value);
  transaction.close();
  assertNull(jedis.get(key));
  txsnapshot.validate();
  snapshot.validate();
  discardSnapshot.validate();
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:20,代码来源:JedisTransactionInstrumentationTest.java

示例8: testSync

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void testSync() throws Exception {
  int rnd = ThreadLocalRandom.current().nextInt(0, presetElements.size());
  String key = presetElementKeys.get(rnd);
  String value = String.valueOf(presetElements.get(key));

  Pipeline pipeline = jedis.pipelined();

  Snapshot snapshot = commandTracker.snapshot();
  Snapshot discardSnapshot = discardTracker.snapshot();
  Snapshot txsnapshot = execTracker.snapshot();
  Snapshot pipelineSnapshot = pipelineTracker.snapshot();
  pipelineSnapshot.increment();
  Response<Long> added = pipeline.sadd(key, value);
  pipeline.sync();
  assertEquals(1, (long) added.get());
  pipelineSnapshot.validate();
  txsnapshot.validate();
  snapshot.validate();
  discardSnapshot.validate();
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:22,代码来源:JedisPipelineInstrumentationTest.java

示例9: testCloseSyncs

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void testCloseSyncs() throws Exception {
  int rnd = ThreadLocalRandom.current().nextInt(0, presetElements.size());
  String key = presetElementKeys.get(rnd);
  String value = String.valueOf(presetElements.get(key));

  Pipeline pipeline = jedis.pipelined();

  Snapshot snapshot = commandTracker.snapshot();
  Snapshot discardSnapshot = discardTracker.snapshot();
  Snapshot txsnapshot = execTracker.snapshot();
  Snapshot pipelineSnapshot = pipelineTracker.snapshot();
  pipelineSnapshot.increment();
  Response<Long> added = pipeline.sadd(key, value);
  pipeline.close();
  assertEquals(1, (long) added.get());
  pipelineSnapshot.validate();
  txsnapshot.validate();
  snapshot.validate();
  discardSnapshot.validate();
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:22,代码来源:JedisPipelineInstrumentationTest.java

示例10: containsKeys

import redis.clients.jedis.Response; //导入依赖的package包/类
@Override
public boolean containsKeys(Collection<K> keys) {
    if (keys == null || keys.size() == 0) {
        return false;
    }
    // 使用 Redis 提供的管道进行批处理,提高效率
    Pipeline pipeline = jedisProxy.pipelined();
    Set<Response<Boolean>> responses = new HashSet<Response<Boolean>>(keys.size());
    for (K key : keys) {
        if (localMapCache != null && localMapCache.containsKey(key)) {
            continue;
        }
        responses.add(pipeline.hexists(SerializeUtil.serialize(getName()), SerializeUtil.serialize(key)));
    }
    if (responses.size() < 1) {
        return true;
    }
    pipeline.sync();
    for (Response<Boolean> response : responses) {
        if (!response.get()) {
            return false;
        }
    }
    return true;
}
 
开发者ID:ganpengyu,项目名称:gedis,代码行数:26,代码来源:ServerMapCache.java

示例11: gets

import redis.clients.jedis.Response; //导入依赖的package包/类
@Override
public Map<K, V> gets(Collection<K> keys) {
    Map<K, V> result = new HashMap<>(keys.size());
    Pipeline pipeline = jedisProxy.pipelined();
    byte[] keyBytes = SerializeUtil.serialize(getName());
    Map<K, Response<byte[]>> responseMap = new HashMap<>(keys.size());
    for (K key : keys) {
        if (localMapCache != null && localMapCache.containsKey(key)) {
            result.put(key, localMapCache.get(key));
            continue;
        }
        responseMap.put(key, pipeline.hget(keyBytes, SerializeUtil.serialize(key)));
    }
    if (responseMap.size() < 1) {
        return result;
    }
    pipeline.sync();
    for (Map.Entry<K, Response<byte[]>> entry : responseMap.entrySet()) {
        result.put(entry.getKey(), (V) SerializeUtil.deserialize(entry.getValue().get()));
    }
    return result;
}
 
开发者ID:ganpengyu,项目名称:gedis,代码行数:23,代码来源:ServerMapCache.java

示例12: multiWithMassiveRequests

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void multiWithMassiveRequests() {
  Pipeline p = jedis.pipelined();
  p.multi();

  List<Response<?>> responseList = new ArrayList<Response<?>>();
  for (int i = 0; i < 100000; i++) {
    // any operation should be ok, but shouldn't forget about timeout
    responseList.add(p.setbit("test", 1, true));
  }

  Response<List<Object>> exec = p.exec();
  p.sync();

  // we don't need to check return value
  // if below codes run without throwing Exception, we're ok
  exec.get();

  for (Response<?> resp : responseList) {
    resp.get();
  }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:23,代码来源:PipeliningTest.java

示例13: testCloseable

import redis.clients.jedis.Response; //导入依赖的package包/类
@Test
public void testCloseable() throws IOException {
  // we need to test with fresh instance of Jedis
  Jedis jedis2 = new Jedis(hnp.getHost(), hnp.getPort(), 500);
  jedis2.auth("foobared");

  Pipeline pipeline = jedis2.pipelined();
  Response<String> retFuture1 = pipeline.set("a", "1");
  Response<String> retFuture2 = pipeline.set("b", "2");

  pipeline.close();

  // it shouldn't meet any exception
  retFuture1.get();
  retFuture2.get();
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:17,代码来源:PipeliningTest.java

示例14: getAllById

import redis.clients.jedis.Response; //导入依赖的package包/类
@Override
public Map<String, UserPermission> getAllById() {
  Table<String, ResourceType, Response<Map<String, String>>> responseTable = getAllFromRedis();
  if (responseTable == null) {
    return new HashMap<>(0);
  }

  Map<String, UserPermission> allById = new HashMap<>(responseTable.rowKeySet().size());

  RawUserPermission rawUnrestricted = new RawUserPermission(responseTable.row(UNRESTRICTED));
  UserPermission unrestrictedUser = getUserPermission(UNRESTRICTED, rawUnrestricted);

  for (String userId : responseTable.rowKeySet()) {
    RawUserPermission rawUser = new RawUserPermission(responseTable.row(userId));
    UserPermission permission = getUserPermission(userId, rawUser);
    allById.put(userId, permission.merge(unrestrictedUser));
  }
  return allById;
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:20,代码来源:RedisPermissionsRepository.java

示例15: getAllFromRedis

import redis.clients.jedis.Response; //导入依赖的package包/类
private Table<String, ResourceType, Response<Map<String, String>>> getAllFromRedis(Set<String> userIds) {
  if (userIds.size() == 0) {
    return HashBasedTable.create();
  }
  try (Jedis jedis = jedisSource.getJedis()) {
    Table<String, ResourceType, Response<Map<String, String>>> responseTable =
        ArrayTable.create(userIds, new ArrayIterator<>(ResourceType.values()));

    Pipeline p = jedis.pipelined();
    for (String userId : userIds) {
      for (ResourceType r : ResourceType.values()) {
        responseTable.put(userId, r, p.hgetAll(userKey(userId, r)));
      }
    }
    p.sync();
    return responseTable;
  } catch (Exception e) {
    log.error("Storage exception reading all entries.", e);
  }
  return null;
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:22,代码来源:RedisPermissionsRepository.java


注:本文中的redis.clients.jedis.Response类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。