List of usage examples for org.springframework.data.redis.connection RedisConnection keys
@Nullable Set<byte[]> keys(byte[] pattern);
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Find all keys matching the given {@code pattern}. * <p>//from w w w. ja v a 2 s . c o m * See http://redis.io/commands/keys * * @param pattern pattern * @return Set<byte[]> */ public static Set<byte[]> keys(byte[] pattern) { return redisTemplate.execute(new RedisCallback<Set<byte[]>>() { @Override public Set<byte[]> doInRedis(RedisConnection redis) throws DataAccessException { return redis.keys(pattern); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Find all keys matching the given {@code pattern}. * <p>/*from ww w . j a v a2s . co m*/ * See http://redis.io/commands/keys * * @param pattern pattern * @return Set<byte[]> */ public Set<byte[]> keys(byte[] pattern) { return redisTemplate.execute(new RedisCallback<Set<byte[]>>() { @Override public Set<byte[]> doInRedis(RedisConnection redis) throws DataAccessException { return redis.keys(pattern); } }); }
From source file:org.redis.cache.RedisCacheManager.java
@SuppressWarnings("unchecked") protected Set<String> loadRemoteCacheKeys() { return (Set<String>) redisOperations.execute(new RedisCallback<Set<String>>() { @Override//from w ww.j ava 2s.com public Set<String> doInRedis(RedisConnection connection) throws DataAccessException { // we are using the ~keys postfix as defined in // RedisCache#setName Set<byte[]> keys = connection.keys(redisOperations.getKeySerializer().serialize("*~keys")); Set<String> cacheKeys = new LinkedHashSet<String>(); if (!CollectionUtils.isEmpty(keys)) { for (byte[] key : keys) { cacheKeys.add(redisOperations.getKeySerializer().deserialize(key).toString() .replace("~keys", "")); } } return cacheKeys; } }); }
From source file:org.springframework.data.redis.cache.RedisCacheManager.java
@SuppressWarnings("unchecked") protected Set<String> loadRemoteCacheKeys() { return (Set<String>) redisOperations.execute(new RedisCallback<Set<String>>() { @Override/*from w w w . j a v a2 s .c o m*/ public Set<String> doInRedis(RedisConnection connection) throws DataAccessException { // we are using the ~keys postfix as defined in RedisCache#setName Set<byte[]> keys = connection.keys(redisOperations.getKeySerializer().serialize("*~keys")); Set<String> cacheKeys = new LinkedHashSet<String>(); if (!CollectionUtils.isEmpty(keys)) { for (byte[] key : keys) { cacheKeys.add(redisOperations.getKeySerializer().deserialize(key).toString() .replace("~keys", "")); } } return cacheKeys; } }); }