DATAREDIS-243 - Ensure compatibility with Spring Framework 4.0.
Updated dependency of XStream since Spring framework 4.0 requires a newer version. Spring 4 added another method to get cached object to the Cache interface. The method has been added to RedisCache in order to provide compatibility, while calling get internally and casting values to required type.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
* Copyright 2011-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
|
||||
* Cache implementation on top of Redis.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
class RedisCache implements Cache {
|
||||
@@ -84,7 +85,6 @@ class RedisCache implements Cache {
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
public ValueWrapper get(final Object key) {
|
||||
return (ValueWrapper) template.execute(new RedisCallback<ValueWrapper>() {
|
||||
|
||||
@@ -96,6 +96,21 @@ class RedisCache implements Cache {
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value to which this cache maps the specified key, generically specifying a type that return value will be cast to.
|
||||
*
|
||||
* @param key
|
||||
* @param type
|
||||
* @return
|
||||
*
|
||||
* @see DATAREDIS-243
|
||||
*/
|
||||
public <T> T get(Object key, Class<T> type) {
|
||||
|
||||
ValueWrapper wrapper = get(key);
|
||||
return wrapper == null ? null : (T) wrapper.get();
|
||||
}
|
||||
|
||||
|
||||
public void put(final Object key, final Object value) {
|
||||
|
||||
Reference in New Issue
Block a user