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; | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * It's generic Spring context starter. Move along... | ||||
|  * | ||||
|  * @author Rafał Żukowicz | ||||
|  */ | ||||
| @SpringBootApplication | ||||
| 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; | ||||
|  | ||||
| /** | ||||
|  * RedisConfig is a class that reads properties from Environment singleton instance and builds beans based on them. | ||||
|  * 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 | ||||
|  * RedisTemplate - Creates map-like object which contains ConnectionFactory and sets parameters. Uses Jackson | ||||
|  * deserialiazer | ||||
|  * Class containing configuration for Redis db client | ||||
|  * | ||||
|  * @author Rafał Żukowicz | ||||
|  */ | ||||
| @Configuration | ||||
| @EnableRedisRepositories | ||||
| @@ -29,15 +27,25 @@ public class RedisConfig { | ||||
|     @Autowired | ||||
|     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 | ||||
|     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"), | ||||
|                 Integer.parseInt(environment.getProperty("redis.port"))); | ||||
|         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 | ||||
|     JedisConnectionFactory jedisConnectionFactory() { | ||||
|         RedisStandaloneConfiguration redisStandaloneConfiguration = | ||||
| @@ -46,6 +54,13 @@ public class RedisConfig { | ||||
|         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 | ||||
|     public RedisTemplate<String, Object> redisTemplate() { | ||||
|         RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user