@Override public Set<byte[]> keys(byte[] pattern) { return convertAndReturn(delegate.keys(pattern), identityConverter); }
/** * Removes all indexes. */ public void removeAllIndexes(String keyspace) { Set<byte[]> potentialIndex = connection.keys(toBytes(keyspace + ":*")); if (!potentialIndex.isEmpty()) { connection.del(potentialIndex.toArray(new byte[potentialIndex.size()][])); } }
@Override public Collection<String> keys(String pattern) { return convertAndReturn(delegate.keys(serialize(pattern)), byteSetToStringSet); }
@Override @SuppressWarnings("unchecked") public Set<K> keys(K pattern) { byte[] rawKey = rawKey(pattern); Set<byte[]> rawKeys = execute(connection -> connection.keys(rawKey), true); return keySerializer != null ? SerializationUtils.deserialize(rawKeys, keySerializer) : (Set<K>) rawKeys; }
@Override public void clean(String name, byte[] pattern) { Assert.notNull(name, "Name must not be null!"); Assert.notNull(pattern, "Pattern must not be null!"); execute(name, connection -> { boolean wasLocked = false; try { if (isLockingCacheWriter()) { doLock(name, connection); wasLocked = true; } byte[][] keys = Optional.ofNullable(connection.keys(pattern)).orElse(Collections.emptySet()) .toArray(new byte[0][]); if (keys.length > 0) { connection.del(keys); } } finally { if (wasLocked && isLockingCacheWriter()) { doUnlock(name, connection); } } return "OK"; }); }
/** * Remove given key from all indexes matching {@link IndexedData#getIndexName()}: * * @param key * @param indexedData */ protected void removeKeyFromExistingIndexes(byte[] key, IndexedData indexedData) { Assert.notNull(indexedData, "IndexedData must not be null!"); Set<byte[]> existingKeys = connection .keys(toBytes(indexedData.getKeyspace() + ":" + indexedData.getIndexName() + ":*")); if (!CollectionUtils.isEmpty(existingKeys)) { for (byte[] existingKey : existingKeys) { if (indexedData instanceof GeoIndexedPropertyValue) { connection.geoRemove(existingKey, key); } else { connection.sRem(existingKey, key); } } } }
@Override public Set<byte[]> keys(byte[] pattern) { return redisConnection.keys(pattern); }
@Override public Set<String> doInRedis(RedisConnection connection) throws DataAccessException { byte[] prefixToUse = Arrays.copyOf(prefix, prefix.length + WILD_CARD.length); System.arraycopy(WILD_CARD, 0, prefixToUse, prefix.length, WILD_CARD.length); Set<byte[]> keys = connection.keys(prefixToUse); return deserializeByte2String(keys); } }
@Override public Integer doInRedis(RedisConnection connection) throws DataAccessException { byte[] prefixToUse = Arrays.copyOf(prefix, prefix.length + WILD_CARD.length); System.arraycopy(WILD_CARD, 0, prefixToUse, prefix.length, WILD_CARD.length); Set<byte[]> keys = connection.keys(prefixToUse); return keys.size(); } }
@Override public Set<byte[]> keys(byte[] pattern) { return convertAndReturn(delegate.keys(pattern), identityConverter); }
@Override public Set<byte[]> keys(byte[] pattern) { return convertAndReturn(delegate.keys(pattern), identityConverter); }
@Override public Set<String> getSessionIdList() { Set<String> strings = (Set) sessionRedisTemplate.execute((RedisCallback<Set<String>>) connection -> { Set<byte[]> keys = connection.keys("http.session.user:*".getBytes()); return keys.stream().map(key -> { String sessionId = new String(connection.get(key)); return sessionId; }).collect(Collectors.toSet()); }); return strings; }
/** * Removes all indexes. */ public void removeAllIndexes(String keyspace) { Set<byte[]> potentialIndex = connection.keys(toBytes(keyspace + ":*")); if (!potentialIndex.isEmpty()) { connection.del(potentialIndex.toArray(new byte[potentialIndex.size()][])); } }
/** * Removes all indexes. */ public void removeAllIndexes(String keyspace) { Set<byte[]> potentialIndex = connection.keys(toBytes(keyspace + ":*")); if (!potentialIndex.isEmpty()) { connection.del(potentialIndex.toArray(new byte[potentialIndex.size()][])); } }
@Override public Set<byte[]> doInRedis(RedisConnection connection) throws DataAccessException { if (usePrefix) { byte[] prefixToUse = Arrays.copyOf(prefix, prefix.length + WILD_CARD.length); System.arraycopy(WILD_CARD, 0, prefixToUse, prefix.length, WILD_CARD.length); return connection.keys(prefixToUse); } else { return connection.zRevRangeByScore(setOfKnownKeys, RedisZSetCommands.Range.unbounded()); } } });
@Override public Collection<String> keys(String pattern) { return convertAndReturn(delegate.keys(serialize(pattern)), byteSetToStringSet); }
@Override public Collection<String> keys(String pattern) { return convertAndReturn(delegate.keys(serialize(pattern)), byteSetToStringSet); }
@Override @SuppressWarnings("unchecked") public Set<K> keys(K pattern) { byte[] rawKey = rawKey(pattern); Set<byte[]> rawKeys = execute(connection -> connection.keys(rawKey), true); return keySerializer != null ? SerializationUtils.deserialize(rawKeys, keySerializer) : (Set<K>) rawKeys; }
@Override @SuppressWarnings("unchecked") public Set<K> keys(K pattern) { byte[] rawKey = rawKey(pattern); Set<byte[]> rawKeys = execute(connection -> connection.keys(rawKey), true); return keySerializer != null ? SerializationUtils.deserialize(rawKeys, keySerializer) : (Set<K>) rawKeys; }
@Override public Collection<Session> getActiveSessions() { List<Session> list = ArrayUtils.newArrayList(); RedisConnectionFactory factory = redisTemplate.getConnectionFactory(); RedisConnection conn = null; try { conn = RedisConnectionUtils.getConnection(factory); Set<byte[]> set = conn.keys((Constants.REDIS_SHIRO_SESSION + "*").getBytes()); for (byte[] key : set) { list.add(deserialize(conn.get(key), SimpleSession.class)); } } finally { RedisConnectionUtils.releaseConnection(conn, factory); } return list; }