diff --git a/pom.xml b/pom.xml
index 315c5e1c9..96b7de00b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -193,20 +193,25 @@
1.7.12
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-yaml
+ 2.6.5
+
com.fasterxml.jackson.core
jackson-core
- 2.6.3
+ 2.6.5
com.fasterxml.jackson.core
jackson-databind
- 2.6.3
+ 2.6.5
com.fasterxml.jackson.dataformat
jackson-dataformat-cbor
- 2.6.3
+ 2.6.5
provided
diff --git a/src/main/java/org/redisson/spring/cache/CacheConfig.java b/src/main/java/org/redisson/spring/cache/CacheConfig.java
index f89208e17..ce947a6c0 100644
--- a/src/main/java/org/redisson/spring/cache/CacheConfig.java
+++ b/src/main/java/org/redisson/spring/cache/CacheConfig.java
@@ -154,4 +154,69 @@ public class CacheConfig {
return new CacheConfigSupport().toJSON(configs);
}
+ /**
+ * Read config objects stored in YAML format from String
+ *
+ * @param content
+ * @return
+ * @throws IOException
+ */
+ public static Map fromYAML(String content) throws IOException {
+ return new CacheConfigSupport().fromYAML(content);
+ }
+
+ /**
+ * Read config objects stored in YAML format from InputStream
+ *
+ * @param inputStream
+ * @return
+ * @throws IOException
+ */
+ public static Map fromYAML(InputStream inputStream) throws IOException {
+ return new CacheConfigSupport().fromYAML(inputStream);
+ }
+
+ /**
+ * Read config objects stored in YAML format from File
+ *
+ * @param file
+ * @return
+ * @throws IOException
+ */
+ public static Map fromYAML(File file) throws IOException {
+ return new CacheConfigSupport().fromYAML(file);
+ }
+
+ /**
+ * Read config objects stored in YAML format from URL
+ *
+ * @param url
+ * @return
+ * @throws IOException
+ */
+ public static Map fromYAML(URL url) throws IOException {
+ return new CacheConfigSupport().fromYAML(url);
+ }
+
+ /**
+ * Read config objects stored in YAML format from Reader
+ *
+ * @param reader
+ * @return
+ * @throws IOException
+ */
+ public static Map fromYAML(Reader reader) throws IOException {
+ return new CacheConfigSupport().fromYAML(reader);
+ }
+
+ /**
+ * Convert current configuration to YAML format
+ *
+ * @return
+ * @throws IOException
+ */
+ public static String toYAML(Map configs) throws IOException {
+ return new CacheConfigSupport().toYAML(configs);
+ }
+
}
diff --git a/src/main/java/org/redisson/spring/cache/CacheConfigSupport.java b/src/main/java/org/redisson/spring/cache/CacheConfigSupport.java
index e1a042d24..840101d64 100644
--- a/src/main/java/org/redisson/spring/cache/CacheConfigSupport.java
+++ b/src/main/java/org/redisson/spring/cache/CacheConfigSupport.java
@@ -24,33 +24,60 @@ import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
public class CacheConfigSupport {
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper jsonMapper = new ObjectMapper();
+ ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
public Map fromJSON(String content) throws IOException {
- return mapper.readValue(content, new TypeReference