instanceMap = new ConcurrentHashMap<>();
+
+ /**
+ * Creates CacheManager supplied by Redisson instance
+ */
+ public PlusSpringCacheManager() {
+ }
+
+
+ /**
+ * Defines possibility of storing {@code null} values.
+ *
+ * Default is true
+ *
+ * @param allowNullValues stores if true
+ */
+ public void setAllowNullValues(boolean allowNullValues) {
+ this.allowNullValues = allowNullValues;
+ }
+
+ /**
+ * Defines if cache aware of Spring-managed transactions.
+ * If {@code true} put/evict operations are executed only for successful transaction in after-commit phase.
+ *
+ * Default is false
+ *
+ * @param transactionAware cache is transaction aware if true
+ */
+ public void setTransactionAware(boolean transactionAware) {
+ this.transactionAware = transactionAware;
+ }
+
+ /**
+ * Defines 'fixed' cache names.
+ * A new cache instance will not be created in dynamic for non-defined names.
+ *
+ * `null` parameter setups dynamic mode
+ *
+ * @param names of caches
+ */
+ public void setCacheNames(Collection names) {
+ if (names != null) {
+ for (String name : names) {
+ getCache(name);
+ }
+ dynamic = false;
+ } else {
+ dynamic = true;
+ }
+ }
+
+ /**
+ * Set cache config mapped by cache name
+ *
+ * @param config object
+ */
+ public void setConfig(Map config) {
+ this.configMap = (Map) config;
+ }
+
+ protected CacheConfig createDefaultConfig() {
+ return new CacheConfig();
+ }
+
+ @Override
+ public Cache getCache(String name) {
+ // 重写 cacheName 支持多参数
+ String[] array = StringUtils.delimitedListToStringArray(name, "#");
+ name = array[0];
+
+ Cache cache = instanceMap.get(name);
+ if (cache != null) {
+ return cache;
+ }
+ if (!dynamic) {
+ return cache;
+ }
+
+ CacheConfig config = configMap.get(name);
+ if (config == null) {
+ config = createDefaultConfig();
+ configMap.put(name, config);
+ }
+
+ if (array.length > 1) {
+ config.setTTL(DurationStyle.detectAndParse(array[1]).toMillis());
+ }
+ if (array.length > 2) {
+ config.setMaxIdleTime(DurationStyle.detectAndParse(array[2]).toMillis());
+ }
+ if (array.length > 3) {
+ config.setMaxSize(Integer.parseInt(array[3]));
+ }
+ int local = 1;
+ if (array.length > 4) {
+ local = Integer.parseInt(array[4]);
+ }
+
+ if (config.getMaxIdleTime() == 0 && config.getTTL() == 0 && config.getMaxSize() == 0) {
+ return createMap(name, config, local);
+ }
+
+ return createMapCache(name, config, local);
+ }
+
+ private Cache createMap(String name, CacheConfig config, int local) {
+ RMap