本文整理汇总了Java中org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet方法的典型用法代码示例。如果您正苦于以下问题:Java JedisConnectionFactory.afterPropertiesSet方法的具体用法?Java JedisConnectionFactory.afterPropertiesSet怎么用?Java JedisConnectionFactory.afterPropertiesSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.redis.connection.jedis.JedisConnectionFactory
的用法示例。
在下文中一共展示了JedisConnectionFactory.afterPropertiesSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildRedisTemplate
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
public static RedisTemplate buildRedisTemplate(byte[] redisProperties){
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(
RedisConfUtils.getClusterConfiguration(
(RedisProperties) Serializer.INSTANCE.deserialize(redisProperties)));
RedisTemplate<String, Long> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(jedisConnectionFactory);
jedisConnectionFactory.afterPropertiesSet();
GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringRedisSerializer);
redisTemplate.setValueSerializer(genericJackson2JsonRedisSerializer);
redisTemplate.setHashKeySerializer(stringRedisSerializer);
redisTemplate.setHashValueSerializer(genericJackson2JsonRedisSerializer);
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
示例2: afterPropertiesSet
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
int redisCount = Integer.parseInt(RedisProperties.getPropertie("redis.count").toString());
factories = new ArrayList<JedisConnectionFactory>(redisCount);
for (int i = 0; i < redisCount; i++) {
int dbSize = 1;
Object dbSizeObj = RedisProperties.getPropertie("redis.db.size" + i);
if (dbSizeObj != null) {
dbSize = Integer.valueOf(dbSizeObj.toString());
}
for (int j = 0; j < dbSize; j++) {
JedisConnectionFactory factory = new JedisConnectionFactory(sentinelConfig,poolConfig);
factory.setHostName(RedisProperties.getPropertie("redis.host" + i).toString());
factory.setPort(Integer.parseInt(RedisProperties.getPropertie("redis.port" + i).toString()));
factory.setPassword(RedisProperties.getPropertie("reids.passwd" + i).toString());
factory.setTimeout(Integer.parseInt(RedisProperties.getPropertie("redis.timeout").toString()));
factory.setDatabase(j);
// 执行必要方法
factory.afterPropertiesSet();
factories.add(factory);
}
}
}
示例3: createRedisConnection
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
protected void createRedisConnection(String name, String host, int port, String password) {
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setHostName(host);
connectionFactory.setPort(port);
if(!StringUtils.isEmpty(password))
connectionFactory.setPassword(password);
connectionFactory.afterPropertiesSet();
RedisTemplate redisTemplate = new MyStringRedisTemplate();
redisTemplate.setConnectionFactory(connectionFactory);
redisTemplate.afterPropertiesSet();
RedisApplication.redisTemplatesMap.put(name, redisTemplate);
Map<String, Object> redisServerMap = new HashMap<String, Object>();
redisServerMap.put("name", name);
redisServerMap.put("host", host);
redisServerMap.put("port", port);
redisServerMap.put("password", password);
RedisApplication.redisServerCache.add(redisServerMap);
initRedisKeysCache(redisTemplate, name);
RedisZtreeUtil.initRedisNavigateZtree(name);
}
示例4: createJedisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
/**
* 建立
*
* i=0, port(6379)
*
* i=1, port(6379)+i=6380
*
* @param i
* @param jedisPoolConfig
* @return
*/
protected JedisConnectionFactory createJedisConnectionFactory(int i, JedisPoolConfig jedisPoolConfig)
throws Exception {
JedisConnectionFactory result = new JedisConnectionFactory();
String hostName = extendedProperties.getString(HOSTNAME, DEFAULT_HOSTNAME);
//
int port = extendedProperties.getInt(PORT, DEFAULT_PORT);
port += i;
LOGGER.info("redis[" + i + "]: " + hostName + ":" + port);
//
result.setHostName(hostName);
result.setPort(port);
//
result.setPassword(extendedProperties.getString(PASSWORD, DEFAULT_PASSWORD));
//
result.setPoolConfig(jedisPoolConfig);
result.afterPropertiesSet();
//
return result;
}
示例5: redisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
public JedisConnectionFactory redisConnectionFactory() {
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxTotal(5);
poolConfig.setTestOnBorrow(true);
poolConfig.setTestOnReturn(true);
JedisConnectionFactory ob = new JedisConnectionFactory(poolConfig);
ob.setUsePool(true);
String redishost = cacheProperties.getRedisHost(); //System.getenv("REDISCACHE_HOSTNAME");
LOG.info("REDISCACHE_HOSTNAME={}", redishost);
ob.setHostName(redishost);
String redisport = cacheProperties.getRedisPort().toString(); //System.getenv("REDISCACHE_PORT");
LOG.info("REDISCACHE_PORT= {}", redisport);
try {
ob.setPort(Integer.parseInt( redisport));
} catch (NumberFormatException e1) {
// if the port is not in the ENV, use the default
ob.setPort(6379);
}
String rediskey = cacheProperties.getPrimaryKey(); //System.getenv("REDISCACHE_PRIMARY_KEY");
LOG.info("REDISCACHE_PRIMARY_KEY= {}", rediskey);
ob.setPassword(rediskey);
ob.afterPropertiesSet();
RedisTemplate<Object,Object> tmp = new RedisTemplate<>();
tmp.setConnectionFactory(ob);
//make sure redis connection is working
try {
String msg = tmp.getConnectionFactory().getConnection().ping();
LOG.info("redis ping response="+msg);
//clear the cache before use
tmp.getConnectionFactory().getConnection().flushAll();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ob;
}
示例6: redisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
public RedisConnectionFactory redisConnectionFactory() {
JedisConnectionFactory cf = new JedisConnectionFactory();
cf.setHostName(getHost());
cf.setPort(getPort());
cf.afterPropertiesSet();
return cf;
}
示例7: createDefaultConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
private RedisConnectionFactory createDefaultConnectionFactory() {
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
managedConnectionFactory = true;
if (host != null) {
jedisConnectionFactory.setHostName(host);
}
if (port != null) {
jedisConnectionFactory.setPort(port);
}
jedisConnectionFactory.afterPropertiesSet();
connectionFactory = jedisConnectionFactory;
return jedisConnectionFactory;
}
示例8: createConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Override
protected RedisConnectionFactory createConnectionFactory( RedisShardSpec shardSpec ) {
JedisConnectionFactory factory = new JedisConnectionFactory();
factory.setHostName(shardSpec.getHost());
factory.setPort(shardSpec.getPort());
factory.setDatabase(shardSpec.getDb());
factory.afterPropertiesSet();
return factory;
}
开发者ID:Dennyss,项目名称:sharded-spring-data-redis,代码行数:10,代码来源:JedisShardedConnectionFactoryProvider.java
示例9: setUp
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
redisConnectionFactory.afterPropertiesSet();
redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setDefaultSerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
productCategoryEnricher = new ProductCategoryEnricher(redisTemplate);
}
示例10: setUp
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
redisConnectionFactory.afterPropertiesSet();
redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setDefaultSerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
productCategoriesCounter = new ProductCategoriesCounter(redisTemplate);
}
示例11: setUp
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Before
public void setUp() {
JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
redisConnectionFactory.afterPropertiesSet();
redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setDefaultSerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
userHistoryProcessor = new UserHistoryProcessor(redisTemplate);
}
示例12: obtainResource
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Override
protected void obtainResource() throws Exception {
resource = new JedisConnectionFactory();
resource.afterPropertiesSet();
resource.getConnection().close();
}
示例13: createConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
private JedisConnectionFactory createConnectionFactory() {
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.afterPropertiesSet();
testConnection(connectionFactory);
return connectionFactory;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:RedisTestServer.java
示例14: testRedisRoute
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void testRedisRoute() throws Exception {
Assume.assumeFalse("[#1701] Cannot start Redis server on Windows", EnvironmentUtils.isWindows());
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.afterPropertiesSet();
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(connectionFactory);
redisTemplate.afterPropertiesSet();
CamelContextFactory contextFactory = ServiceLocator.getRequiredService(CamelContextFactory.class);
WildFlyCamelContext camelctx = contextFactory.createCamelContext(getClass().getClassLoader());
Context jndictx = camelctx.getNamingContext();
jndictx.bind("redisTemplate", redisTemplate);
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
int port = Integer.parseInt(AvailablePortFinder.readServerData("redis-port"));
from("direct:start")
.to("spring-redis://localhost:" + port + "?redisTemplate=#redisTemplate");
}
});
camelctx.start();
try {
Object[] headers = new Object[] {
RedisConstants.COMMAND, "SET",
RedisConstants.KEY, "key1",
RedisConstants.VALUE, "value"
};
ProducerTemplate producer = camelctx.createProducerTemplate();
producer.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
for (int i = 0; i < headers.length; i = i + 2) {
in.setHeader(headers[i].toString(), headers[i + 1]);
}
}
});
Assert.assertEquals("value", redisTemplate.opsForValue().get("key1"));
} finally {
camelctx.stop();
}
}
示例15: RedisKeyValueAdapter
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
public RedisKeyValueAdapter(IndexConfiguration indexConfiguration) {
super(new RedisQueryEngine());
converter = new MappingRedisConverter(indexConfiguration, new ReferenceResolverImpl(this));
JedisConnectionFactory conFactory = new JedisConnectionFactory();
conFactory.afterPropertiesSet();
RedisTemplate<byte[], byte[]> template = new RedisTemplate<byte[], byte[]>();
template.setConnectionFactory(conFactory);
template.afterPropertiesSet();
this.redisOps = template;
}