Removed depracated code and added Javadoc
This commit is contained in:
@@ -4,8 +4,11 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It's generic Spring context starter. Move along...
|
||||||
|
*
|
||||||
|
* @author Rafał Żukowicz
|
||||||
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class KlausApplication {
|
public class KlausApplication {
|
||||||
|
|
||||||
@@ -14,5 +17,3 @@ public class KlausApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//TODO JedisPool jedisPool = new JedisPool(jedisPoolConfig, redisHost, redisPort, timeout, redisPassword)
|
|
||||||
//TODO JedisPool optimalization https://partners-intl.aliyun.com/help/doc-detail/98726.htm
|
|
||||||
|
|||||||
@@ -15,11 +15,9 @@ import redis.clients.jedis.JedisPool;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RedisConfig is a class that reads properties from Environment singleton instance and builds beans based on them.
|
* Class containing configuration for Redis db client
|
||||||
* JedisPool ?- an instance of the JedisPool class that contains info about host and port of Reddis
|
*
|
||||||
* JedisConnectionFactory - ConnectionFactory created based on host and port provided by Environment
|
* @author Rafał Żukowicz
|
||||||
* RedisTemplate - Creates map-like object which contains ConnectionFactory and sets parameters. Uses Jackson
|
|
||||||
* deserialiazer
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableRedisRepositories
|
@EnableRedisRepositories
|
||||||
@@ -29,15 +27,25 @@ public class RedisConfig {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bean of JedisPool - the Redis client. It stores requests in "the pool" and then fires them at Redis.
|
||||||
|
* It's considered super lightweight and fast client variant
|
||||||
|
*
|
||||||
|
* @return lightweight client of the Redis - the JedisPool
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
JedisPool jedisPool(){
|
JedisPool jedisPool(){
|
||||||
//TODO JedisPool jedisPool = new JedisPool(jedisPoolConfig, redisHost, redisPort, timeout, redisPassword)
|
|
||||||
//TODO JedisPool optimalization https://partners-intl.aliyun.com/help/doc-detail/98726.htm
|
|
||||||
final JedisPool pool = new JedisPool(environment.getProperty("redis.host"),
|
final JedisPool pool = new JedisPool(environment.getProperty("redis.host"),
|
||||||
Integer.parseInt(environment.getProperty("redis.port")));
|
Integer.parseInt(environment.getProperty("redis.port")));
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bean of a factory for connenction object.
|
||||||
|
* It's initialized with Redis db url property and is fed to other methods.
|
||||||
|
*
|
||||||
|
* @return the factory for RedisTemplates
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
JedisConnectionFactory jedisConnectionFactory() {
|
JedisConnectionFactory jedisConnectionFactory() {
|
||||||
RedisStandaloneConfiguration redisStandaloneConfiguration =
|
RedisStandaloneConfiguration redisStandaloneConfiguration =
|
||||||
@@ -46,6 +54,13 @@ public class RedisConfig {
|
|||||||
return new JedisConnectionFactory(redisStandaloneConfiguration);
|
return new JedisConnectionFactory(redisStandaloneConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RedisTemplate is the tool to store and retrieve given type (object) of hash from the database.
|
||||||
|
* It's like you could store your Java object by just naming it inside database. You might thing about it
|
||||||
|
* as of DAO.
|
||||||
|
*
|
||||||
|
* @return RedisTemplate the redis dao.
|
||||||
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public RedisTemplate<String, Object> redisTemplate() {
|
public RedisTemplate<String, Object> redisTemplate() {
|
||||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user