List of usage examples for org.springframework.data.redis.connection RedisConnection bLPop
@Nullable List<byte[]> bLPop(int timeout, byte[]... keys);
From source file:com.mauersu.util.redis.DefaultListOperations.java
public V leftPop(K key, long timeout, TimeUnit unit) { final int tm = (int) TimeoutUtils.toSeconds(timeout, unit); return execute(new ValueDeserializingRedisCallback(key) { protected byte[] inRedis(byte[] rawKey, RedisConnection connection) { connection.select(dbIndex);//from www . j a v a 2s . c o m List<byte[]> lPop = connection.bLPop(tm, rawKey); return (CollectionUtils.isEmpty(lPop) ? null : lPop.get(1)); } }, true); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Removes and returns first element from lists stored at {@code keys} (see: {@link #lPop(byte[])}). <br> * <b>Blocks connection</b> until element available or {@code timeout} reached. * <p>//from w ww .j a v a 2 s . c o m * See http://redis.io/commands/blpop * * @param timeout timeout * @param keys keys * @return List<byte[]> */ public static List<byte[]> bLPop(int timeout, byte[]... keys) { return redisTemplate.execute(new RedisCallback<List<byte[]>>() { @Override public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException { return redis.bLPop(timeout, keys); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Removes and returns first element from lists stored at {@code keys} (see: {@link #lPop(byte[])}). <br> * <b>Blocks connection</b> until element available or {@code timeout} reached. * <p>//from w ww . j av a2s.c o m * See http://redis.io/commands/blpop * * @param timeout timeout * @param keys keys * @return List<byte[]> */ public List<byte[]> bLPop(int timeout, byte[]... keys) { return redisTemplate.execute(new RedisCallback<List<byte[]>>() { @Override public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException { return redis.bLPop(timeout, keys); } }); }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Ignore("Redis must have requirepass set to run this test") @Test//from w w w . j a va 2 s .c o m public void testConnectWithPassword() { factory.setPassword("foo"); factory.afterPropertiesSet(); RedisConnection conn = factory.getConnection(); // Test shared and dedicated conns conn.ping(); conn.bLPop(1, "key".getBytes()); conn.close(); }