org.springframework.data.redis.connection.RedisConnection.serverCommands()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(227)

本文整理了Java中org.springframework.data.redis.connection.RedisConnection.serverCommands方法的一些代码示例,展示了RedisConnection.serverCommands的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisConnection.serverCommands方法的具体详情如下:
包路径:org.springframework.data.redis.connection.RedisConnection
类名称:RedisConnection
方法名:serverCommands

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.");
    }
  });
}

相关文章

微信公众号

最新文章

更多

RedisConnection类方法