本文整理了Java中org.springframework.data.redis.connection.RedisConnection.serverCommands
方法的一些代码示例,展示了RedisConnection.serverCommands
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisConnection.serverCommands
方法的具体详情如下:
包路径:org.springframework.data.redis.connection.RedisConnection
类名称:RedisConnection
方法名:serverCommands
[英]Get RedisServerCommands.
[中]获取命令。
代码示例来源:origin: spring-projects/spring-integration
/**
* Perform an {@code INFO} command on the provided {@link RedisOperations} to check
* the Redis server version to be sure that {@code UNLINK} is available or not.
* @param redisOperations the {@link RedisOperations} to perform {@code INFO} command.
* @return true or false if {@code UNLINK} Redis command is available or not.
* @throws IllegalStateException when {@code INFO} returns null from the Redis.
*/
public static boolean isUnlinkAvailable(RedisOperations<?, ?> redisOperations) {
return unlinkAvailable.computeIfAbsent(redisOperations, key -> {
Properties info = redisOperations.execute(
(RedisCallback<Properties>) connection -> connection.serverCommands().info(SECTION));
if (info != null) {
int majorVersion = Integer.parseInt(info.getProperty(VERSION_PROPERTY).split("\\.")[0]);
return majorVersion >= 4;
}
else {
throw new IllegalStateException("The INFO command cannot be used in pipeline/transaction.");
}
});
}
代码示例来源:origin: org.springframework.integration/spring-integration-redis
/**
* Perform an {@code INFO} command on the provided {@link RedisOperations} to check
* the Redis server version to be sure that {@code UNLINK} is available or not.
* @param redisOperations the {@link RedisOperations} to perform {@code INFO} command.
* @return true or false if {@code UNLINK} Redis command is available or not.
* @throws IllegalStateException when {@code INFO} returns null from the Redis.
*/
public static boolean isUnlinkAvailable(RedisOperations<?, ?> redisOperations) {
return unlinkAvailable.computeIfAbsent(redisOperations, key -> {
Properties info = redisOperations.execute(
(RedisCallback<Properties>) connection -> connection.serverCommands().info(SECTION));
if (info != null) {
int majorVersion = Integer.parseInt(info.getProperty(VERSION_PROPERTY).split("\\.")[0]);
return majorVersion >= 4;
}
else {
throw new IllegalStateException("The INFO command cannot be used in pipeline/transaction.");
}
});
}
内容来源于网络,如有侵权,请联系作者删除!