-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IN40068837
authored and
IN40068837
committed
Dec 19, 2024
1 parent
9484afb
commit eb2f985
Showing
5 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.iemr.hwc.config; | ||
|
||
import org.springframework.cache.annotation.EnableCaching; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
import org.springframework.session.data.redis.config.ConfigureRedisAction; | ||
|
||
import com.iemr.hwc.data.login.Users; | ||
|
||
@Configuration | ||
@EnableCaching | ||
public class RedisConfig { | ||
|
||
@Bean | ||
public ConfigureRedisAction configureRedisAction() { | ||
return ConfigureRedisAction.NO_OP; | ||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, Users> redisTemplate(RedisConnectionFactory factory) { | ||
RedisTemplate<String, Users> template = new RedisTemplate<>(); | ||
template.setConnectionFactory(factory); | ||
|
||
// Use StringRedisSerializer for keys (userId) | ||
template.setKeySerializer(new StringRedisSerializer()); | ||
|
||
// Use Jackson2JsonRedisSerializer for values (Users objects) | ||
Jackson2JsonRedisSerializer<Users> serializer = new Jackson2JsonRedisSerializer<>(Users.class); | ||
template.setValueSerializer(serializer); | ||
|
||
return template; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters