redis.clients.jedis.Client Java Examples
The following examples show how to use
redis.clients.jedis.Client.
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: RedisServiceImpl.java From FEBS-Security with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> getMemoryInfo() { String info = (String) this.excuteByJedis( j -> { Client client = j.getClient(); client.info(); return client.getBulkReply(); } ); String[] strs = Objects.requireNonNull(info).split("\n"); Map<String, Object> map = null; for (String s : strs) { String[] detail = s.split(":"); if ("used_memory".equals(detail[0])) { map = new HashMap<>(); map.put("used_memory", detail[1].substring(0, detail[1].length() - 1)); map.put("create_time", System.currentTimeMillis()); break; } } return map; }
Example #2
Source File: JedisClusterPipeline.java From AutoLoadCache with Apache License 2.0 | 6 votes |
private void innerSync(List<Object> formatted) { try { Response<?> response; Object data; for (Client client : clients) { response = generateResponse(client.getOne()); if (null != formatted) { data = response.get(); formatted.add(data); } } } catch (JedisRedirectionException jre) { throw jre; } finally { close(); } }
Example #3
Source File: TestJedisPoolFacade.java From HttpSessionReplacer with MIT License | 6 votes |
@Test public void testMetrics() { MetricRegistry metrics = mock(MetricRegistry.class); Client client = mock(Client.class); when(client.getHost()).thenReturn("myhost"); when(jedis.getClient()).thenReturn(client); when(pool.getNumActive()).thenReturn(1); when(pool.getNumIdle()).thenReturn(2); when(pool.getNumWaiters()).thenReturn(3); rf.startMonitoring(metrics); @SuppressWarnings("rawtypes") ArgumentCaptor<Gauge> gauge = ArgumentCaptor.forClass(Gauge.class); verify(metrics).register(eq("com.amadeus.session.redis.myhost.active"), gauge.capture()); verify(metrics).register(eq("com.amadeus.session.redis.myhost.idle"), gauge.capture()); verify(metrics).register(eq("com.amadeus.session.redis.myhost.waiting"), gauge.capture()); assertEquals(1, gauge.getAllValues().get(0).getValue()); assertEquals(2, gauge.getAllValues().get(1).getValue()); assertEquals(3, gauge.getAllValues().get(2).getValue()); }
Example #4
Source File: ListCommandsTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test public void linsert() { long status = jedis.linsert("foo", Client.LIST_POSITION.BEFORE, "bar", "car"); assertEquals(0, status); jedis.lpush("foo", "a"); status = jedis.linsert("foo", Client.LIST_POSITION.AFTER, "a", "b"); assertEquals(2, status); List<String> actual = jedis.lrange("foo", 0, 100); List<String> expected = new ArrayList<String>(); expected.add("a"); expected.add("b"); assertEquals(expected, actual); status = jedis.linsert("foo", Client.LIST_POSITION.BEFORE, "bar", "car"); assertEquals(-1, status); // Binary long bstatus = jedis.linsert(bfoo, Client.LIST_POSITION.BEFORE, bbar, bcar); assertEquals(0, bstatus); jedis.lpush(bfoo, bA); bstatus = jedis.linsert(bfoo, Client.LIST_POSITION.AFTER, bA, bB); assertEquals(2, bstatus); List<byte[]> bactual = jedis.lrange(bfoo, 0, 100); List<byte[]> bexpected = new ArrayList<byte[]>(); bexpected.add(bA); bexpected.add(bB); assertEquals(bexpected, bactual); bstatus = jedis.linsert(bfoo, Client.LIST_POSITION.BEFORE, bbar, bcar); assertEquals(-1, bstatus); }
Example #5
Source File: JedisPluginTest.java From pinpoint with Apache License 2.0 | 5 votes |
public JedisMock(String host, int port) { super(host, port); client = mock(Client.class); // for 'get' command when(client.isInMulti()).thenReturn(false); when(client.getBulkReply()).thenReturn("bar"); when(client.getBinaryBulkReply()).thenReturn("bar".getBytes()); }
Example #6
Source File: AttachEndPointInterceptor.java From pinpoint with Apache License 2.0 | 5 votes |
private boolean validate(final Object target, final Object[] args) { if (args == null || args.length == 0 || args[0] == null) { if (isDebug) { logger.debug("Invalid arguments. Null or not found args({}).", args); } return false; } if (!(args[0] instanceof Client)) { if (isDebug) { logger.debug("Invalid arguments. Expect Client but args[0]({}).", args[0]); } return false; } if (!(args[0] instanceof EndPointAccessor)) { if (isDebug) { logger.debug("Invalid args[0] object. Need field accessor({}).", EndPointAccessor.class.getName()); } return false; } if (!(target instanceof EndPointAccessor)) { if (isDebug) { logger.debug("Invalid target object. Need field accessor({}).", EndPointAccessor.class.getName()); } return false; } return true; }
Example #7
Source File: JedisAdapter.java From gameserver with Apache License 2.0 | 5 votes |
@Override public Client getClient() { redis.clients.jedis.Jedis delegate = pool.getResource(); try { return delegate.getClient(); } finally { pool.returnResource(delegate); } }
Example #8
Source File: JedisClusterPipeline.java From AutoLoadCache with Apache License 2.0 | 5 votes |
private Client getClient(int slot) { JedisPool pool = clusterInfoCache.getSlotPool(slot); // 根据pool从缓存中获取Jedis Jedis jedis = jedisMap.get(pool); if (null == jedis) { jedis = pool.getResource(); jedisMap.put(pool, jedis); } return jedis.getClient(); }
Example #9
Source File: RedisList.java From litchi with Apache License 2.0 | 5 votes |
/** * 在列表的元素前或者后插入元素 * @param key * @param where * @param pivot * @param value * @return */ public Long insert(String key, Client.LIST_POSITION where, String pivot, String value) { try { return jedis.linsert(key, where, pivot, value); } catch (Exception e) { LOGGER.error("", e); } finally { if (autoClose) { close(); } } return -1L; }
Example #10
Source File: RedisShardSubscriber.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
@Override public void proceed(Client client, String... channels) { if (channels.length == 0) { channels = placeholderChannel(); } super.proceed(client, channels); }
Example #11
Source File: ClusterClient.java From JRedisBloom with BSD 2-Clause "Simplified" License | 5 votes |
/** * Remove the filter * @param name * @return true if delete the filter, false is not delete the filter */ public boolean delete(String name) { return (new JedisClusterCommand<Boolean>(this.connectionHandler, this.maxAttempts) { public Boolean execute(Jedis connection) { Connection conn = connection.getClient(); ((Client) conn).del(name); return conn.getIntegerReply() != 0; } }).run(name); }
Example #12
Source File: ContextedRedisGraph.java From JRedisGraph with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Creates a new RedisGraphTransaction transactional object * @return new RedisGraphTransaction */ @Override public RedisGraphTransaction multi() { Jedis jedis = getConnection(); Client client = jedis.getClient(); client.multi(); client.getOne(); RedisGraphTransaction transaction = new RedisGraphTransaction(client,this); transaction.setRedisGraphCaches(caches); return transaction; }
Example #13
Source File: RedisServiceImpl.java From FEBS-Security with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> getKeysSize() { long dbSize = (long) this.excuteByJedis( j -> { Client client = j.getClient(); client.dbSize(); return client.getIntegerReply(); } ); Map<String, Object> map = new HashMap<>(); map.put("create_time", System.currentTimeMillis()); map.put("dbSize", dbSize); return map; }
Example #14
Source File: RedisServiceImpl.java From FEBS-Security with Apache License 2.0 | 5 votes |
@Override public List<RedisInfo> getRedisInfo() { String info = (String) this.excuteByJedis( j -> { Client client = j.getClient(); client.info(); return client.getBulkReply(); } ); List<RedisInfo> infoList = new ArrayList<>(); String[] strs = Objects.requireNonNull(info).split("\n"); RedisInfo redisInfo; if (strs.length > 0) { for (String str1 : strs) { redisInfo = new RedisInfo(); String[] str = str1.split(":"); if (str.length > 1) { String key = str[0]; String value = str[1]; redisInfo.setKey(key); redisInfo.setValue(value); infoList.add(redisInfo); } } } return infoList; }
Example #15
Source File: EnhancedJedisCluster.java From super-cloudops with Apache License 2.0 | 5 votes |
@Override public Long linsert(final byte[] key, final Client.LIST_POSITION where, final byte[] pivot, final byte[] value) { checkArgumentsSpecification(key); return new EnhancedJedisClusterCommand<Long>(connectionHandler, maxAttempts) { @Override public Long doExecute(Jedis connection) { return connection.linsert(key, where, pivot, value); } }.runBinary(key); }
Example #16
Source File: JedisClusterPipeline.java From AutoLoadCache with Apache License 2.0 | 4 votes |
@Override protected Client getClient(String key) { byte[] bKey = SafeEncoder.encode(key); return getClient(bKey); }
Example #17
Source File: JedisClusterPipeline.java From AutoLoadCache with Apache License 2.0 | 4 votes |
@Override protected Client getClient(byte[] key) { Client client = getClient(JedisClusterCRC16.getSlot(key)); clients.add(client); return client; }
Example #18
Source File: RedisGraphTransaction.java From JRedisGraph with BSD 3-Clause "New" or "Revised" License | 4 votes |
public RedisGraphTransaction(Client client, RedisGraph redisGraph){ // init as in Jedis super(client); this.redisGraph = redisGraph; }
Example #19
Source File: JedisDummyAdapter.java From gameserver with Apache License 2.0 | 4 votes |
@Override public Client getClient() { return null; }
Example #20
Source File: SyncPipeline.java From gameserver with Apache License 2.0 | 2 votes |
/** * @param client * @see redis.clients.jedis.Pipeline#setClient(redis.clients.jedis.Client) */ public void setClient(Client client) { delegate.setClient(client); }
Example #21
Source File: JedisAllCommand.java From gameserver with Apache License 2.0 | 2 votes |
/** * @return * @see redis.clients.jedis.BinaryJedis#getClient() */ public abstract Client getClient();