fuint-framework/fuint-cache/src/main/java/com/fuint/cache/config/CacheConfig.java

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.fuint.cache.config;

import com.fuint.cache.redis.RedissonFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.Jedis;


import java.util.ArrayList;
import java.util.List;

/**
 * 缓存配置类
 * Created by FSQ
 * Contact wx fsq_better
 */
@Configuration
public class CacheConfig {

    @Autowired
    private Environment env;

    @Bean
    public JedisPoolConfig createJedisPoolConfig() {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(Integer.parseInt(env.getProperty("redis.maxTotal")));
        jedisPoolConfig.setMaxIdle(Integer.parseInt(env.getProperty("redis.maxIdle")));
        jedisPoolConfig.setMinIdle(Integer.parseInt(env.getProperty("redis.minIdle")));
        jedisPoolConfig.setMaxWaitMillis(Integer.parseInt(env.getProperty("redis.maxWaitMillis")));
        jedisPoolConfig.setTestOnBorrow(Boolean.valueOf(env.getProperty("redis.testOnBorrow")));
        return jedisPoolConfig;
    }

    @Bean(name = "jedisPool")
    public JedisPool createJedisPool() {
        String address = env.getProperty("redis.address");
        int port = Integer.parseInt(env.getProperty("redis.port"));
        int timeout = Integer.parseInt(env.getProperty("redis.timeout"));
        String auth = env.getProperty("redis.auth");

        //20190920 richard add redis 访问密码和timeout时间
        //JedisPool jedisPool = new JedisPool(createJedisPoolConfig(), address, port);
        JedisPool jedisPool;
        if(auth==null || auth.length()==0) {
             jedisPool = new JedisPool(createJedisPoolConfig(), address, port);
        }
        else
        {
             jedisPool = new JedisPool(createJedisPoolConfig(), address, port, timeout, auth);
        }
        return jedisPool;
    }

    @Bean
    public RedissonFactoryBean createRedissonFactoryBean() {
        RedissonFactoryBean redissonFactoryBean = new RedissonFactoryBean();
后面还有 10 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。