Skip to content

Commit

Permalink
This should be rolled back
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Sep 19, 2024
1 parent f19e778 commit afd8239
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
Expand Down Expand Up @@ -31,7 +35,7 @@ public class RedisClient {
private final String redisPassword;
private final int cacheExpiryInSecs;
private final int clientTimeoutInMillis;
private JedisPool pool;
public JedisPool pool;
private SetParams defaultSetParams;

@Resource
Expand Down Expand Up @@ -67,7 +71,7 @@ public RedisClient(String redisHost, int redisPort, String password, int cacheEx
@PostConstruct
private void init() {
try {
JedisClientConfig config = DefaultJedisClientConfig.builder().connectionTimeoutMillis(this.clientTimeoutInMillis).timeoutMillis(this.clientTimeoutInMillis)
JedisClientConfig config = DefaultJedisClientConfig.builder().connectionTimeoutMillis(this.clientTimeoutInMillis)
.socketTimeoutMillis(this.clientTimeoutInMillis).password(this.redisPassword).ssl(true).build();
pool = new JedisPool(new HostAndPort(this.redisHost, this.redisPort), config);
defaultSetParams = new SetParams().ex(this.cacheExpiryInSecs);
Expand Down Expand Up @@ -141,4 +145,33 @@ public boolean remove(String key) {
}
return true;
}

public static void main(String [] args) {
RedisClient client = new RedisClient("reg-qa-redis-001.reg-qa-redis.3zksuc.use2.cache.amazonaws.com", 6379, "aVerySimpleToken");
client.init();
System.out.println("Connected");
Jedis r = client.pool.getResource();

Set<String> keys = r.keys("spring:session:sessions:*");

for(String key : keys) {
System.out.println("----------------------------------------------");
System.out.println(key);
String keyType = r.type(key);
System.out.println(keyType);
if("hash".equals(keyType)) {
Map<String, String> myMap = r.hgetAll(key);
for(String tkey : myMap.keySet()) {
System.out.println(tkey + ": " + myMap.get(tkey));
}
}
if("string".equals(keyType)) {
System.out.println(key + ": " + r.get("key"));
}
System.out.println("----------------------------------------------");
}



}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.orcid.frontend.spring.configuration;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.security.jackson2.SecurityJackson2Modules;

@Configuration
public class OrcidBeanClassLoaderAware implements BeanClassLoaderAware {
private ClassLoader loader;

@Bean
public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
return new GenericJackson2JsonRedisSerializer(objectMapper());
}

/**
* Customized {@link ObjectMapper} to add mix-in for class that doesn't have default
* constructors
* @return the {@link ObjectMapper} to use
*/
private ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModules(SecurityJackson2Modules.getModules(this.loader));
return mapper;
}

@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.loader = classLoader;
}
}

0 comments on commit afd8239

Please sign in to comment.