package com.vci.server.cache.redis;
|
|
import java.io.File;
|
import java.io.FileInputStream;
|
import java.util.Properties;
|
import com.vci.common.log.ServerWithLog4j;
|
|
/**
|
* 读取redis配置
|
*
|
* @author zhengzhiyuan
|
* @since May 20, 2016
|
*/
|
public final class RedisConfig {
|
private static final String DEFAULT_REDIS_PROPERTIES = "properties/redis.properties";
|
private static Properties redisProperties = null;
|
|
// private static final String DEFAULT_REDIS_PROPERTIES = "redis.properties";
|
// private static ResourceBundle REDIS_CONFIG = ResourceBundle.getBundle(DEFAULT_REDIS_PROPERTIES);
|
|
static {
|
try {
|
File file = new File(DEFAULT_REDIS_PROPERTIES);
|
|
ServerWithLog4j.logger.debug("初始化Redis配置文件");
|
|
if (file.exists()) {
|
FileInputStream confPropertiesStream = new FileInputStream(DEFAULT_REDIS_PROPERTIES);
|
redisProperties = new Properties();
|
redisProperties.load(confPropertiesStream);
|
}
|
} catch(Exception ee) {
|
ee.printStackTrace();
|
ServerWithLog4j.logger.info("初始化Redis配置文件出错,请检查文件后重新启动");
|
}
|
}
|
|
public static String getConfigProperty(String key) {
|
return redisProperties.getProperty(key);
|
}
|
}
|