本文整理了Java中org.springframework.data.redis.connection.RedisConnection.keys
方法的一些代码示例,展示了RedisConnection.keys
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisConnection.keys
方法的具体详情如下:
包路径:org.springframework.data.redis.connection.RedisConnection
类名称:RedisConnection
方法名:keys
暂无
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Set<byte[]> keys(byte[] pattern) {
return convertAndReturn(delegate.keys(pattern), identityConverter);
}
代码示例来源:origin: spring-projects/spring-data-redis
/**
* 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()][]));
}
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Collection<String> keys(String pattern) {
return convertAndReturn(delegate.keys(serialize(pattern)), byteSetToStringSet);
}
代码示例来源:origin: spring-projects/spring-data-redis
@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;
}
代码示例来源:origin: spring-projects/spring-data-redis
@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";
});
}
代码示例来源:origin: spring-projects/spring-data-redis
/**
* 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);
}
}
}
}
代码示例来源:origin: 1991wangliang/tx-lcn
@Override
public Set<byte[]> keys(byte[] pattern) {
return redisConnection.keys(pattern);
}
代码示例来源:origin: com.github.nic-luo/rober-base
@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);
}
}
代码示例来源:origin: com.github.nic-luo/rober-base
@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();
}
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Set<byte[]> keys(byte[] pattern) {
return convertAndReturn(delegate.keys(pattern), identityConverter);
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Set<byte[]> keys(byte[] pattern) {
return convertAndReturn(delegate.keys(pattern), identityConverter);
}
代码示例来源:origin: org.hsweb/hsweb-web-core
@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;
}
代码示例来源:origin: org.springframework.data/spring-data-redis
/**
* 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()][]));
}
}
代码示例来源:origin: apache/servicemix-bundles
/**
* 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()][]));
}
}
代码示例来源:origin: com.github.nic-luo/rober-base
@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());
}
}
});
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Collection<String> keys(String pattern) {
return convertAndReturn(delegate.keys(serialize(pattern)), byteSetToStringSet);
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Collection<String> keys(String pattern) {
return convertAndReturn(delegate.keys(serialize(pattern)), byteSetToStringSet);
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@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;
}
代码示例来源:origin: apache/servicemix-bundles
@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;
}
代码示例来源:origin: huangjian888/jeeweb-mybatis-springboot
@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;
}
内容来源于网络,如有侵权,请联系作者删除!