redis.clients.jedis.Protocol Java Examples
The following examples show how to use
redis.clients.jedis.Protocol.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisMessenger.java From LuckPerms with MIT License | 6 votes |
public void init(String address, String password, boolean ssl) { String[] addressSplit = address.split(":"); String host = addressSplit[0]; int port = addressSplit.length > 1 ? Integer.parseInt(addressSplit[1]) : Protocol.DEFAULT_PORT; this.jedisPool = new JedisPool(new JedisPoolConfig(), host, port, Protocol.DEFAULT_TIMEOUT, password, ssl); this.plugin.getBootstrap().getScheduler().executeAsync(() -> { this.sub = new Subscription(this); try (Jedis jedis = this.jedisPool.getResource()) { jedis.subscribe(this.sub, CHANNEL); } catch (Exception e) { e.printStackTrace(); } }); }
Example #2
Source File: RedisDeployCenterImpl.java From cachecloud with Apache License 2.0 | 6 votes |
private boolean slaveOf(final long appId, final String masterHost, final int masterPort, final String slaveHost, final int slavePort) { final Jedis slave = redisCenter.getJedis(appId, slaveHost, slavePort, Protocol.DEFAULT_TIMEOUT * 3, Protocol.DEFAULT_TIMEOUT * 3); try { boolean isSlave = new IdempotentConfirmer() { @Override public boolean execute() { String result = slave.slaveof(masterHost, masterPort); return result != null && result.equalsIgnoreCase("OK"); } }.run(); if (!isSlave) { logger.error(String.format("modifyAppConfig:ip=%s,port=%s failed", slaveHost, slavePort)); return false; } redisCenter.configRewrite(appId, slaveHost, slavePort); } catch (Exception e) { logger.error(e.getMessage(), e); return false; } finally { if (slave != null) slave.close(); } return true; }
Example #3
Source File: JedisFactory.java From pippo with Apache License 2.0 | 6 votes |
/** * Create a Jedis poll with pippo settings. URL format: * 'redis://[:password@]host[:port][/db-number][?option=value]' * * @param settings pippo settings * @return Jedis pool */ public static JedisPool create(final PippoSettings settings) { String host = settings.getString(HOST, Protocol.DEFAULT_HOST).trim(); int minIdle = settings.getInteger(MIN_IDLE, GenericObjectPoolConfig.DEFAULT_MIN_IDLE); int maxIdle = settings.getInteger(MAX_IDLE, GenericObjectPoolConfig.DEFAULT_MAX_IDLE); int maxTotal = settings.getInteger(MAX_TOTAL, GenericObjectPoolConfig.DEFAULT_MAX_TOTAL); JedisPoolConfig config = new JedisPoolConfig(); config.setMinIdle(minIdle); config.setMaxIdle(maxIdle); config.setMaxTotal(maxTotal); try { return new JedisPool(config, new URI(host)); } catch (URISyntaxException e) { throw new PippoRuntimeException("Malformed redis URI", e); } }
Example #4
Source File: RedisAdapterCaseBase.java From calcite with Apache License 2.0 | 6 votes |
private void readModelByJson() { String strResult = null; try { ObjectMapper objMapper = new ObjectMapper(); objMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true) .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true) .configure(JsonParser.Feature.ALLOW_COMMENTS, true); File file = new File(filePath); if (file.exists()) { JsonNode rootNode = objMapper.readTree(file); strResult = rootNode.toString().replace(Integer.toString(Protocol.DEFAULT_PORT), Integer.toString(PORT)); } } catch (Exception ignored) { } model = strResult; }
Example #5
Source File: RedisQParserPlugin.java From solr-redis with Apache License 2.0 | 6 votes |
@Override public void init(final NamedList args) { final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setMaxTotal(getInt(args, MAX_CONNECTIONS_FIELD, DEFAULT_MAX_CONNECTIONS)); final String host = getString(args, HOST_FIELD, HostAndPort.LOCALHOST_STR); final int timeout = getInt(args, TIMEOUT_FIELD, Protocol.DEFAULT_TIMEOUT); final String password = getString(args, PASSWORD_FIELD, null); final int database = getInt(args, DATABASE_FIELD, Protocol.DEFAULT_DATABASE); final int retries = getInt(args, RETRIES_FIELD, DEFAULT_RETRIES); final String[] hostAndPort = host.split(":"); final JedisPool jedisConnectionPool = createPool(poolConfig, hostAndPort[0], hostAndPort.length == 2 ? Integer.parseInt(hostAndPort[1]) : Protocol.DEFAULT_PORT, timeout, password, database); connectionHandler = createCommandHandler(jedisConnectionPool, retries); log.info("Initialized RedisQParserPlugin with host: " + host); }
Example #6
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 6 votes |
@Test public void buildACommand() throws IOException { PipedInputStream pis = new PipedInputStream(); BufferedInputStream bis = new BufferedInputStream(pis); PipedOutputStream pos = new PipedOutputStream(pis); RedisOutputStream ros = new RedisOutputStream(pos); Protocol.sendCommand(ros, Protocol.Command.GET, "SOMEKEY".getBytes(Protocol.CHARSET)); ros.flush(); pos.close(); String expectedCommand = "*2\r\n$3\r\nGET\r\n$7\r\nSOMEKEY\r\n"; int b; StringBuilder sb = new StringBuilder(); while ((b = bis.read()) != -1) { sb.append((char) b); } assertEquals(expectedCommand, sb.toString()); }
Example #7
Source File: BaseTest.java From quartz-redis-jobstore with Apache License 2.0 | 6 votes |
@Before public void setUpRedis() throws IOException, SchedulerConfigException { port = getPort(); logger.debug("Attempting to start embedded Redis server on port " + port); redisServer = RedisServer.builder() .port(port) .build(); redisServer.start(); final short database = 1; JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); jedisPoolConfig.setTestOnBorrow(true); jedisPool = new JedisPool(jedisPoolConfig, host, port, Protocol.DEFAULT_TIMEOUT, null, database); jobStore = new RedisJobStore(); jobStore.setHost(host); jobStore.setLockTimeout(2000); jobStore.setPort(port); jobStore.setInstanceId("testJobStore1"); jobStore.setDatabase(database); mockScheduleSignaler = mock(SchedulerSignaler.class); jobStore.initialize(null, mockScheduleSignaler); schema = new RedisJobStoreSchema(); jedis = jedisPool.getResource(); jedis.flushDB(); }
Example #8
Source File: ShardedJedisTest.java From cachecloud with Apache License 2.0 | 6 votes |
@Test public void testMasterSlaveShardingConsistencyWithShardNaming() { List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT, "HOST1:1234")); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1, "HOST2:1234")); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2, "HOST3:1234")); Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(shards, Hashing.MURMUR_HASH); List<JedisShardInfo> otherShards = new ArrayList<JedisShardInfo>(3); otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT, "HOST2:1234")); otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT + 1, "HOST3:1234")); otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT + 2, "HOST1:1234")); Sharded<Jedis, JedisShardInfo> sharded2 = new Sharded<Jedis, JedisShardInfo>(otherShards, Hashing.MURMUR_HASH); for (int i = 0; i < 1000; i++) { JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer.toString(i)); JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer.toString(i)); assertEquals(jedisShardInfo.getName(), jedisShardInfo2.getName()); } }
Example #9
Source File: ShardedJedisTest.java From cachecloud with Apache License 2.0 | 6 votes |
@Test public void testMasterSlaveShardingConsistency() { List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT)); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1)); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2)); Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(shards, Hashing.MURMUR_HASH); List<JedisShardInfo> otherShards = new ArrayList<JedisShardInfo>(3); otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT)); otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT + 1)); otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT + 2)); Sharded<Jedis, JedisShardInfo> sharded2 = new Sharded<Jedis, JedisShardInfo>(otherShards, Hashing.MURMUR_HASH); for (int i = 0; i < 1000; i++) { JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer.toString(i)); JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer.toString(i)); assertEquals(shards.indexOf(jedisShardInfo), otherShards.indexOf(jedisShardInfo2)); } }
Example #10
Source File: RedisConnectionInfo.java From kayenta with Apache License 2.0 | 6 votes |
static RedisConnectionInfo parseConnectionUri(String connection) { URI redisConnection = URI.create(connection); String host = redisConnection.getHost(); int port = redisConnection.getPort() == -1 ? Protocol.DEFAULT_PORT : redisConnection.getPort(); int database = JedisURIHelper.getDBIndex(redisConnection); String password = JedisURIHelper.getPassword(redisConnection); boolean ssl = connection.startsWith(REDIS_SSL_SCHEME); return RedisConnectionInfo.builder() .host(host) .port(port) .database(database) .password(password) .ssl(ssl) .build(); }
Example #11
Source File: RedisGelfSenderProvider.java From xian with Apache License 2.0 | 6 votes |
@Override public GelfSender create(GelfSenderConfiguration configuration) throws IOException { String graylogHost = configuration.getHost(); URI hostUri = URI.create(graylogHost); int port = hostUri.getPort(); if (port <= 0) { port = configuration.getPort(); } if (port <= 0) { port = Protocol.DEFAULT_PORT; } if (hostUri.getFragment() == null || hostUri.getFragment().trim().equals("")) { throw new IllegalArgumentException("Redis URI must specify fragment"); } if (hostUri.getHost() == null) { throw new IllegalArgumentException("Redis URI must specify host"); } Pool<Jedis> pool = RedisSenderPoolProvider.getJedisPool(hostUri, port); return new GelfREDISSender(pool, hostUri.getFragment(), configuration.getErrorReporter()); }
Example #12
Source File: ProtocolBenchmark.java From cachecloud with Apache License 2.0 | 6 votes |
private static long measureInputMulti() throws Exception { long duration = 0; InputStream is = new ByteArrayInputStream( "*4\r\n$3\r\nfoo\r\n$13\r\nbarbarbarfooz\r\n$5\r\nHello\r\n$5\r\nWorld\r\n".getBytes()); RedisInputStream in = new RedisInputStream(is); for (int n = 0; n <= TOTAL_OPERATIONS; n++) { long start = System.nanoTime(); Protocol.read(in); duration += (System.nanoTime() - start); in.reset(); } return duration; }
Example #13
Source File: RedisConfig.java From springboot-learn with MIT License | 6 votes |
@Bean(name = "jedis.pool") @Autowired public JedisSentinelPool jedisPool(@Qualifier("jedis.pool.config") JedisPoolConfig config, @Value("${spring.redis.sentinel.master}") String clusterName, @Value("${spring.redis.sentinel.nodes}") String sentinelNodes, @Value("${spring.redis.timeout}") int timeout, @Value("${spring.redis.password}") String password) { logger.info("缓存服务器的主服务名称:" + clusterName + ", 主从服务ip&port:" + sentinelNodes); Assert.isTrue(StringUtils.isNotEmpty(clusterName), "主服务名称配置为空"); Assert.isTrue(StringUtils.isNotEmpty(sentinelNodes), "主从服务地址配置为空"); Set<String> sentinels = Sets.newHashSet(StringUtils.split(sentinelNodes, ",")); JedisSentinelPool sentinelJedisPool = new JedisSentinelPool(clusterName, sentinels, config, Protocol.DEFAULT_TIMEOUT, password); return sentinelJedisPool; }
Example #14
Source File: JedisPoolFactory.java From kork with Apache License 2.0 | 6 votes |
public Pool<Jedis> build( String name, JedisDriverProperties properties, GenericObjectPoolConfig objectPoolConfig) { if (properties.connection == null || "".equals(properties.connection)) { throw new MissingRequiredConfiguration("Jedis client must have a connection defined"); } URI redisConnection = URI.create(properties.connection); String host = redisConnection.getHost(); int port = redisConnection.getPort() == -1 ? Protocol.DEFAULT_PORT : redisConnection.getPort(); int database = parseDatabase(redisConnection.getPath()); String password = parsePassword(redisConnection.getUserInfo()); GenericObjectPoolConfig poolConfig = Optional.ofNullable(properties.poolConfig).orElse(objectPoolConfig); boolean isSSL = redisConnection.getScheme().equals("rediss"); return new InstrumentedJedisPool( registry, // Pool name should always be "null", as setting this is incompat with some SaaS Redis // offerings new JedisPool( poolConfig, host, port, properties.timeoutMs, password, database, null, isSSL), name); }
Example #15
Source File: TestRedisQParserPlugin.java From solr-redis with Apache License 2.0 | 5 votes |
@Test public void shouldConfigurePoolWithCustomHost() { final NamedList<String> list = new NamedList<>(); list.add("host", "127.0.0.1"); parserPlugin.init(list); verify(parserPlugin).createPool(poolConfigArgument.capture(), eq("127.0.0.1"), eq(Protocol.DEFAULT_PORT), eq(Protocol.DEFAULT_TIMEOUT), passwordArgument.capture(), eq(Protocol.DEFAULT_DATABASE)); verify(parserPlugin).createCommandHandler(poolArgument.capture(), eq(1)); assertNull(passwordArgument.getValue()); assertEquals(5, poolConfigArgument.getValue().getMaxTotal()); }
Example #16
Source File: ProtocolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test public void fragmentedBulkReply() { FragmentedByteArrayInputStream fis = new FragmentedByteArrayInputStream( "$30\r\n012345678901234567890123456789\r\n".getBytes()); byte[] response = (byte[]) Protocol.read(new RedisInputStream(fis)); assertArrayEquals(SafeEncoder.encode("012345678901234567890123456789"), response); }
Example #17
Source File: JedisClusterClientTest.java From session-managers with Apache License 2.0 | 5 votes |
@Test public void get() throws UnsupportedEncodingException { byte[] expected = "result".getBytes(); when(this.jedisCluster.get("key".getBytes(Protocol.CHARSET))).thenReturn(expected); byte[] result = this.jedisPoolTemplate.get("key"); assertEquals(expected, result); verify(this.jedisCluster, times(1)).get("key".getBytes(Protocol.CHARSET)); }
Example #18
Source File: JedisNodeClientTest.java From session-managers with Apache License 2.0 | 5 votes |
@Test public void get() throws UnsupportedEncodingException { byte[] expected = "result".getBytes(); when(this.jedis.get("key".getBytes(Protocol.CHARSET))).thenReturn(expected); byte[] result = this.jedisNodeClient.get("key"); assertEquals(expected, result); verify(this.jedis, times(1)).get("key".getBytes(Protocol.CHARSET)); verify(this.jedis, times(1)).close(); }
Example #19
Source File: JedisClusterClientTest.java From session-managers with Apache License 2.0 | 5 votes |
@Test public void set() throws UnsupportedEncodingException { byte[] session = "session".getBytes(); this.jedisPoolTemplate.set("key", SESSIONS_KEY, session, timeout); verify(this.jedisCluster, times(1)).setex("key".getBytes(Protocol.CHARSET), timeout, session); verify(this.jedisCluster, times(1)).sadd(SESSIONS_KEY, "key"); }
Example #20
Source File: RedisClientConfiguration.java From kork with Apache License 2.0 | 5 votes |
private JedisCluster getJedisCluster( GenericObjectPoolConfig objectPoolConfig, ClientConfigurationWrapper config, URI cx) { int port = cx.getPort() == -1 ? Protocol.DEFAULT_PORT : cx.getPort(); String password = (cx.getUserInfo() != null && cx.getUserInfo().contains(":")) ? cx.getUserInfo().substring(cx.getUserInfo().indexOf(":")) : null; return new JedisCluster( new HostAndPort(cx.getHost(), port), config.getTimeoutMs(), config.getTimeoutMs(), config.getMaxAttempts(), objectPoolConfig); }
Example #21
Source File: RedisSentinelSinkFunction.java From alchemy with Apache License 2.0 | 5 votes |
@Override protected Jedis create(RedisProperties redisProperties) { Set<String> sentinelset = new HashSet<>(Arrays.asList(redisProperties.getSentinel().getSentinels().split(","))); this.pool = new JedisSentinelPool(redisProperties.getSentinel().getMaster(), sentinelset, redisProperties.getConfig(), redisProperties.getTimeout() == null ? Protocol.DEFAULT_TIMEOUT : redisProperties.getTimeout(), redisProperties.getPassword(), redisProperties.getDatabase()); return this.pool.getResource(); }
Example #22
Source File: RedisConnectionConfiguration.java From beam with Apache License 2.0 | 5 votes |
public static RedisConnectionConfiguration create() { return new AutoValue_RedisConnectionConfiguration.Builder() .setHost(ValueProvider.StaticValueProvider.of(Protocol.DEFAULT_HOST)) .setPort(ValueProvider.StaticValueProvider.of(Protocol.DEFAULT_PORT)) .setTimeout(ValueProvider.StaticValueProvider.of(Protocol.DEFAULT_TIMEOUT)) .setSsl(ValueProvider.StaticValueProvider.of(Boolean.FALSE)) .build(); }
Example #23
Source File: JedisNodeClient.java From session-managers with Apache License 2.0 | 5 votes |
@Override public void set(String key, String sessionsKey, byte[] session, int timeout) throws UnsupportedEncodingException { try(Jedis jedis = this.jedisPool.getResource()) { Transaction t = jedis.multi(); t.setex(key.getBytes(Protocol.CHARSET), timeout, session); t.sadd(sessionsKey, key); t.exec(); } }
Example #24
Source File: TestRedisQParserPlugin.java From solr-redis with Apache License 2.0 | 5 votes |
@Test public void shouldConfigurePoolWithDefaultParametersIfNoSpecificConfigurationIsGiven() { parserPlugin.init(new NamedList()); verify(parserPlugin).createPool(poolConfigArgument.capture(), eq(HostAndPort.LOCALHOST_STR), eq(Protocol.DEFAULT_PORT), eq(Protocol.DEFAULT_TIMEOUT), passwordArgument.capture(), eq(Protocol.DEFAULT_DATABASE)); assertNull(passwordArgument.getValue()); assertEquals(5, poolConfigArgument.getValue().getMaxTotal()); }
Example #25
Source File: TestRedisQParserPlugin.java From solr-redis with Apache License 2.0 | 5 votes |
@Test public void shouldConfigurePoolWithCustomDatabase() { final NamedList<String> list = new NamedList<>(); list.add("database", "1"); parserPlugin.init(list); verify(parserPlugin).createPool(poolConfigArgument.capture(), eq(HostAndPort.LOCALHOST_STR), eq(Protocol.DEFAULT_PORT), eq(Protocol.DEFAULT_TIMEOUT), passwordArgument.capture(), eq(1)); verify(parserPlugin).createCommandHandler(poolArgument.capture(), eq(1)); assertNull(passwordArgument.getValue()); assertEquals(5, poolConfigArgument.getValue().getMaxTotal()); }
Example #26
Source File: BinaryJedisque.java From jedisque with MIT License | 5 votes |
public String addJob(byte[] queueName, byte[] job, long mstimeout, JobParams params) { List<byte[]>addJobCommand = new ArrayList<byte[]>(); addJobCommand.add(queueName); addJobCommand.add(job); addJobCommand.add(Protocol.toByteArray(mstimeout)); addJobCommand.addAll(params.getParams()); sendCommand(Command.ADDJOB, addJobCommand.toArray(new byte[addJobCommand.size()][])); return getBulkReply(); }
Example #27
Source File: TestRedisQParserPlugin.java From solr-redis with Apache License 2.0 | 5 votes |
@Test public void shouldConfigurePoolWithCustomMaxConnections() { final NamedList<String> list = new NamedList<>(); list.add("maxConnections", "100"); parserPlugin.init(list); verify(parserPlugin).createPool(poolConfigArgument.capture(), eq(HostAndPort.LOCALHOST_STR), eq(Protocol.DEFAULT_PORT), eq(Protocol.DEFAULT_TIMEOUT), passwordArgument.capture(), eq(Protocol.DEFAULT_DATABASE)); verify(parserPlugin).createCommandHandler(poolArgument.capture(), eq(1)); assertNull(passwordArgument.getValue()); assertEquals(100, poolConfigArgument.getValue().getMaxTotal()); }
Example #28
Source File: ShardedJedisTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test public void testMurmurSharding() { List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT)); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1)); shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2)); Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(shards, Hashing.MURMUR_HASH); int shard_6379 = 0; int shard_6380 = 0; int shard_6381 = 0; for (int i = 0; i < 1000; i++) { JedisShardInfo jedisShardInfo = sharded.getShardInfo(Integer.toString(i)); switch (jedisShardInfo.getPort()) { case 6379: shard_6379++; break; case 6380: shard_6380++; break; case 6381: shard_6381++; break; default: fail("Attempting to use a non-defined shard!!:" + jedisShardInfo); break; } } assertTrue(shard_6379 > 300 && shard_6379 < 400); assertTrue(shard_6380 > 300 && shard_6380 < 400); assertTrue(shard_6381 > 300 && shard_6381 < 400); }
Example #29
Source File: RedisDataSet.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void testStarted(String distributedHost) { JedisPoolConfig config = new JedisPoolConfig(); config.setMaxActive(getMaxActive()); config.setMaxIdle(getMaxIdle()); config.setMinIdle(getMinIdle()); config.setMaxWait(getMaxWait()); config.setWhenExhaustedAction((byte)getWhenExhaustedAction()); config.setTestOnBorrow(getTestOnBorrow()); config.setTestOnReturn(getTestOnReturn()); config.setTestWhileIdle(getTestWhileIdle()); config.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis()); config.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun()); config.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis()); config.setSoftMinEvictableIdleTimeMillis(getSoftMinEvictableIdleTimeMillis()); int port = Protocol.DEFAULT_PORT; if(!JOrphanUtils.isBlank(this.port)) { port = Integer.parseInt(this.port); } int timeout = Protocol.DEFAULT_TIMEOUT; if(!JOrphanUtils.isBlank(this.timeout)) { timeout = Integer.parseInt(this.timeout); } int database = Protocol.DEFAULT_DATABASE; if(!JOrphanUtils.isBlank(this.database)) { database = Integer.parseInt(this.database); } String password = null; if(!JOrphanUtils.isBlank(this.password)) { password = this.password; } this.pool = new JedisPool(config, this.host, port, timeout, password, database); }
Example #30
Source File: ProtocolBenchmark.java From cachecloud with Apache License 2.0 | 5 votes |
private static long measureCommand() throws Exception { long duration = 0; byte[] KEY = "123456789".getBytes(); byte[] VAL = "FooBar".getBytes(); for (int n = 0; n <= TOTAL_OPERATIONS; n++) { RedisOutputStream out = new RedisOutputStream(new ByteArrayOutputStream(8192)); long start = System.nanoTime(); Protocol.sendCommand(out, Protocol.Command.SET, KEY, VAL); duration += (System.nanoTime() - start); } return duration; }