OCI Redis Cluster, a new managed service on OCI (English)

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 3

  • @DarioSoprano
    @DarioSoprano 7 หลายเดือนก่อน

    Hi, I'm using OCI redis on cloud, but jedisConnectionFactory returns the error org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection. Why? thanks

    • @christophepruvost44
      @christophepruvost44  7 หลายเดือนก่อน +1

      Hi Sorry I have no time for debugging. You can have a look to the OCI doc or may be my code there will show you something : package com.example.redis;
      import org.springframework.context.annotation.Bean;
      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.context.annotation.PropertySource;
      import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
      import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
      import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
      import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
      @Configuration
      @ComponentScan("com.example.redis")
      @EnableRedisRepositories(basePackages = "com.example.redis")
      @PropertySource("classpath:application.properties")
      public class RedisConfig {
      @Bean
      JedisConnectionFactory jedisConnectionFactory() {
      RedisStandaloneConfiguration redisStandaloneConfiguration = null;
      JedisClientConfiguration jedisConfig = null;
      JedisConnectionFactory jedisConnectionFactory = null;

      //Local Redis
      if (Environment._PROFILE.equals("REDIS")) {
      redisStandaloneConfiguration = new RedisStandaloneConfiguration(Environment._ENDPOINT, Integer.parseInt(Environment._PORT));
      redisStandaloneConfiguration.setPassword(Environment._PASSWORD);
      jedisConnectionFactory = new JedisConnectionFactory(redisStandaloneConfiguration);
      }
      //OCI Env
      else {
      redisStandaloneConfiguration = new RedisStandaloneConfiguration(Environment._ENDPOINT, Integer.parseInt(Environment._PORT));
      jedisConfig = JedisClientConfiguration
      .builder()
      .useSsl()
      .build();
      jedisConnectionFactory = new JedisConnectionFactory(redisStandaloneConfiguration, jedisConfig);
      }
      return jedisConnectionFactory;
      }
      }

    • @DarioSoprano
      @DarioSoprano 7 หลายเดือนก่อน

      @@christophepruvost44 thanks, for quickly reply. The error occured when use opsForValues().get
      RedisTemplate template = new RedisTemplate();
      System.out.println( "=>>>0");
      template.setConnectionFactory(jedisConnectionFactory);
      template.setKeySerializer(new StringRedisSerializer());
      template.setHashKeySerializer(new StringRedisSerializer());
      template.setHashKeySerializer(new JdkSerializationRedisSerializer());
      template.setValueSerializer(new JdkSerializationRedisSerializer());
      template.setEnableTransactionSupport(true);
      template.afterPropertiesSet();

      System.out.println( "=>>>1");
      Object valobj = template.opsForValue().get("TEST");