List of usage examples for org.springframework.data.redis.connection RedisConnection scan
Cursor<byte[]> scan(ScanOptions options);
From source file:io.gravitee.repository.redis.management.internal.impl.ApplicationRedisRepositoryImpl.java
@Override public Set<RedisApplication> findByName(final String partialName) { List<String> matchedNames = redisTemplate.execute(new RedisCallback<List<String>>() { @Override//from w ww .j a va 2 s . c om public List<String> doInRedis(RedisConnection redisConnection) throws DataAccessException { ScanOptions options = ScanOptions.scanOptions() .match(REDIS_KEY + ":search-by:name:*" + partialName.toUpperCase() + "*").build(); Cursor<byte[]> cursor = redisConnection.scan(options); List<String> result = new ArrayList<>(); if (cursor != null) { while (cursor.hasNext()) { result.add(new String(cursor.next())); } } return result; } }); if (matchedNames == null || matchedNames.isEmpty()) { return Collections.emptySet(); } Set<Object> applicationIds = new HashSet<>(); matchedNames.forEach(matchedName -> applicationIds.addAll(redisTemplate.opsForSet().members(matchedName))); return find(applicationIds.stream().map(Object::toString).collect(Collectors.toList())); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Use a {@link Cursor} to iterate over keys. * <p>/*from ww w . ja v a2 s. c om*/ * See http://redis.io/commands/scan * * @param options options * @return Cursor<byte[]> * @since 1.4 */ public static Cursor<byte[]> scan(ScanOptions options) { return redisTemplate.execute(new RedisCallback<Cursor<byte[]>>() { @Override public Cursor<byte[]> doInRedis(RedisConnection redis) throws DataAccessException { return redis.scan(options); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Use a {@link Cursor} to iterate over keys. * <p>/* w ww. ja v a 2s. c o m*/ * See http://redis.io/commands/scan * * @param options options * @return Cursor<byte[]> * @since 1.4 */ public Cursor<byte[]> scan(ScanOptions options) { return redisTemplate.execute(new RedisCallback<Cursor<byte[]>>() { @Override public Cursor<byte[]> doInRedis(RedisConnection redis) throws DataAccessException { return redis.scan(options); } }); }