use of org.springframework.data.redis.connection.RedisConnection in project rdbcache by rdbcache.
the class RedisOps method ensureNotifyKeySpaceEventsEx.
// make sure config set notify-keyspace-events Ex
//
public void ensureNotifyKeySpaceEventsEx() {
RedisConnection connection = AppCtx.getStringRedisTemplate().getConnectionFactory().getConnection();
Properties properties = connection.getConfig("notify-keyspace-events");
String config = "";
for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
if (value.equals("notify-keyspace-events")) {
config = value;
break;
}
}
if (config.contains("E") && (config.contains("A") || config.contains("x"))) {
return;
}
if (!config.contains("E")) {
config += "E";
}
if (!config.contains("A") && !config.contains("x")) {
config += "x";
}
connection.setConfig("notify-keyspace-events", config);
LOGGER.trace("setConfig notify-keyspace-events " + config);
}
use of org.springframework.data.redis.connection.RedisConnection in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationXmlCustomExpireTests method connectionFactory.
static RedisConnectionFactory connectionFactory() {
RedisConnectionFactory factory = mock(RedisConnectionFactory.class);
RedisConnection connection = mock(RedisConnection.class);
given(factory.getConnection()).willReturn(connection);
given(connection.getConfig(anyString())).willReturn(new Properties());
return factory;
}
use of org.springframework.data.redis.connection.RedisConnection in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationClassPathXmlApplicationContextTests method connectionFactory.
static RedisConnectionFactory connectionFactory() {
RedisConnectionFactory factory = mock(RedisConnectionFactory.class);
RedisConnection connection = mock(RedisConnection.class);
given(factory.getConnection()).willReturn(connection);
given(connection.getConfig(anyString())).willReturn(new Properties());
return factory;
}
use of org.springframework.data.redis.connection.RedisConnection in project spring-session by spring-projects.
the class RedisHttpSessionConfigurationTests method mockRedisConnectionFactory.
private static RedisConnectionFactory mockRedisConnectionFactory() {
RedisConnectionFactory connectionFactory = mock(RedisConnectionFactory.class);
RedisConnection connection = mock(RedisConnection.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.getConfig(anyString())).willReturn(new Properties());
return connectionFactory;
}
use of org.springframework.data.redis.connection.RedisConnection in project spring-security-oauth by spring-projects.
the class RedisTokenStore method getAccessToken.
@Override
public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication) {
String key = authenticationKeyGenerator.extractKey(authentication);
byte[] serializedKey = serializeKey(AUTH_TO_ACCESS + key);
byte[] bytes = null;
RedisConnection conn = getConnection();
try {
bytes = conn.get(serializedKey);
} finally {
conn.close();
}
OAuth2AccessToken accessToken = deserializeAccessToken(bytes);
if (accessToken != null) {
OAuth2Authentication storedAuthentication = readAuthentication(accessToken.getValue());
if ((storedAuthentication == null || !key.equals(authenticationKeyGenerator.extractKey(storedAuthentication)))) {
// Keep the stores consistent (maybe the same user is
// represented by this authentication but the details have
// changed)
storeAccessToken(accessToken, authentication);
}
}
return accessToken;
}
Aggregations